Exemple #1
0
void MipsEnv::PrintOperand (std::stringstream *operand_str)
{
    uint32_t trace_count;

    for (trace_count = 0; trace_count < GetTrace()->GetMax (); trace_count ++) {
        switch (GetTrace()->GetTraceType(trace_count)) {
        case traceInfo::trace_regwrite :
            if (GetTrace()->GetTraceAddr (trace_count) == REG_PC) {
                (*operand_str) << "pc<=" << std::hex << std::setw(8) << GetTrace()->GetTraceValue (trace_count) << " ";
            } else {
                (*operand_str) << "r"  << std::dec << std::setw(2) << std::setfill('0') << GetTrace()->GetTraceAddr (trace_count)
                               << "<=" << std::hex << std::setw(8) << std::setfill('0') << GetTrace()->GetTraceValue (trace_count) << " ";
            }
            break;
        case traceInfo::trace_regread :
            (*operand_str) << "r"  << std::dec << std::setw(2) << std::setfill('0') << GetTrace()->GetTraceAddr (trace_count)
                           << "=>" << std::hex << std::setw(8) << std::setfill('0') << GetTrace()->GetTraceValue (trace_count) << ' ';
            break;
        case traceInfo::trace_memwrite :
            (*operand_str) << "("  << std::hex << std::setw(8) << std::setfill('0') << GetTrace()->GetTraceAddr (trace_count) << ")"
                           << "<=" << std::hex << std::setw(8) << std::setfill('0') << GetTrace()->GetTraceValue (trace_count) << " ";
            break;
        case traceInfo::trace_memread : {
            (*operand_str) << "("  << std::hex << std::setw(8) << std::setfill('0') << GetTrace()->GetTraceAddr (trace_count) << ")"
                           << "=>" << std::hex << std::setw(8) << std::setfill('0') << GetTrace()->GetTraceValue (trace_count) << " ";
            break;
        }
        }
    }
}
// GetElasticModuli() ---------------------------------------------
void
ManzariDafaliasRO::GetElasticModuli(const Vector& sigma, const double& en, double &K, double &G)
// Calculates G, K
{
	double p, pSR, Gmax, T, temp;
	Vector r(6), rSR(6);

	p = one3 * GetTrace(sigma);
	p = (p <= m_Pmin) ? m_Pmin : p;
	r = GetDevPart(sigma) / p;

	pSR = one3 * GetTrace(mSigmaSR);
	pSR = (pSR <= m_Pmin) ? m_Pmin : pSR;
	rSR = GetDevPart(mSigmaSR) / pSR;

	Gmax = m_B * m_P_atm / (0.3 + 0.7 * en * en) * sqrt(p / m_P_atm);
	if (mElastFlag == 0) {
		mIsFirstShear = true;
		T = 1.0;
	} else {
		mChi_r = sqrt(0.5 * DoubleDot2_2_Contr(r-rSR, r-rSR));
		temp = m_kappa * (1.0 / m_a1 - 1);
		if (mIsFirstShear)
			T = 1 + temp * pow(mChi_r / mEta1, m_kappa - 1);
		else
			T = 1 + temp * pow(mChi_r / mEta1 / 2.0, m_kappa - 1);
		T = (T < (1.0+temp)) ? T : (1.0+temp);
		T = (T < 1.0) ? 1.0 : T;
	}

	G = Gmax / T;
	K = two3 * (1 + m_nu) / (1 - 2 * m_nu) * G;	
}
void 
ManzariDafaliasRO::integrate()
{
	double chi_e, chi_en;
	Vector devEps(6), devEps_n(6);
	//
	devEps		= GetDevPart(mEpsilon);
	devEps_n	= GetDevPart(mEpsilon_n);
	chi_e		= sqrt(0.5 * DoubleDot2_2_Cov(devEps   - mDevEpsSR, devEps   - mDevEpsSR));
	chi_en		= sqrt(0.5 * DoubleDot2_2_Cov(devEps_n - mDevEpsSR, devEps_n - mDevEpsSR));
	if (mIsFirstShear && fabs(chi_e - chi_en) < 1.0e-10) { // This is required in case of consolidation (mEta1 should be updated)
		// how small should 1.0e-10 be?
		double p = one3 * GetTrace(mSigma_n);
		double Gmax  = m_B * m_P_atm / (0.3 + 0.7 * mVoidRatio*mVoidRatio) * sqrt(p / m_P_atm);
		mEta1 = m_a1 * Gmax * m_gamma1 / p;
		chi_e = chi_en = 0.0;
	}
	if ((chi_e - chi_en) * mDChi_e < -1.0e-14) { // how small should be -1.0e-14?
		mSigmaSR  = mSigma_n;

		//mSigmaSR(3) = mSigmaSR(4) = mSigmaSR(5) -= 0.1;
		mDevEpsSR = GetDevPart(mEpsilon_n);
		double pSR = one3 * GetTrace(mSigmaSR);
		double GmaxSR  = m_B * m_P_atm / (0.3 + 0.7 * mVoidRatio*mVoidRatio) * sqrt(pSR / m_P_atm);
		mEta1 = m_a1 * GmaxSR * m_gamma1 / pSR;
		mIsFirstShear = false;
		GetElasticModuli(mSigma_n, mVoidRatio, mK, mG);
	}
	ManzariDafalias::integrate();
}
void SIM_PLOT_PANEL::EnableCursor( const wxString& aName, bool aEnable )
{
    TRACE* t = GetTrace( aName );

    if( t == nullptr || t->HasCursor() == aEnable )
        return;

    if( aEnable )
    {
        CURSOR* c = new CURSOR( t );
        int plotCenter = GetMarginLeft() + ( GetXScreen() - GetMarginLeft() - GetMarginRight() ) / 2;
        c->SetX( plotCenter );
        t->SetCursor( c );
        AddLayer( c );
    }
    else
    {
        CURSOR* c = t->GetCursor();
        t->SetCursor( NULL );
        DelLayer( c, true );
    }

    // Notify the parent window about the changes
    wxQueueEvent( GetParent(), new wxCommandEvent( EVT_SIM_CURSOR_UPDATE ) );
}
Exemple #5
0
/*!
 * step instruction
 */
void MipsEnv::StepSimulation (int32_t stepCount)
{
    for (int32_t i = 0; (i < stepCount) && (IsStopSim () == false); i++) {
        GetTrace()->clearTraceInfo ();
        StepExec ();
    }
    return;
}
Exemple #6
0
void MipsEnv::StepExec (void)
{
    if (IsStopSim() == true) {
        return;
    }

    SetJumped (false);

    Word_t inst_hex;
    int32_t fetch_res;
    Addr_t  fetch_pc = GetPC();
    fetch_res = FetchMemory (fetch_pc, &inst_hex);

    if (fetch_res == -1) {
        DebugPrint ("<Error: Instructino is Misaligned>\n");
        return;
    }

    std::string func_symbol;
    if ((IsDebugFunc () == true) &&
        (FindSymbol (fetch_pc, &func_symbol) == true)) {
        DebugPrint ("<Func: %s>\n", func_symbol.c_str());
    }

    GetTrace()->SetInstHex (inst_hex);
    GetTrace()->SetTracePC (GetPC());
    GetTrace()->SetStep(GetStep());

    AdvanceStep ();    // Update Step Information

    uint32_t  inst_idx = MIPS_DEC (inst_hex);
    GetTrace()->SetInstIdx (inst_idx);

    if (inst_idx == static_cast<uint32_t>(-1)) {
        DebugPrint ("<Error: instruction is not decoded. [%08x]=%08x\n", GetPC (), inst_hex);
        exit (EXIT_FAILURE);
    } else {

        m_inst_env->MIPS_Inst_Exec (inst_idx, inst_hex);

        if (IsDebugTrace() == true) {
            if (GetTrace()->IsDelayedSlot() == false) {

                DebugPrint ("%10d : ", GetTrace()->GetStep ());
                DebugPrint ("[%08x] %08x : ", GetTrace()->GetTracePC (), GetTrace()->GetInstHex ());
                char inst_string[31];
                PrintInst (GetTrace()->GetInstHex(), GetTrace()->GetInstIdx(),
                           inst_string, 30);
                DebugPrint ("%-30s  ", inst_string);
                std::stringstream operand_str;
                PrintOperand (&operand_str);

                DebugPrint ("%s\n", operand_str.str().c_str());

                if (GetTrace()->IsDelayedSlotExecuted () != 0) {
                    GetTrace()->SetDelayedSlot ();
                    DebugPrint ("%10d : ", GetTrace()->GetStep ());
                    DebugPrint ("[%08x] %08x : ", GetTrace()->GetTracePC (), GetTrace()->GetInstHex());
                    char inst_string[31];
                    PrintInst (GetTrace()->GetInstHex(), GetTrace()->GetInstIdx(),
                               inst_string, 30);
                    DebugPrint ("%-30s  ", inst_string);
                    std::stringstream operand_str;
                    PrintOperand (&operand_str);
                    DebugPrint ("%s\n", operand_str.str().c_str());
                    GetTrace()->ClearDelayedSlot ();
                }
            }
        }
    }

    if ((GetTrace()->IsDelayedSlot() == false) && (GetJumped () == false)) {
        ProceedPC ();      // Update PC
    }
}
bool SIM_PLOT_PANEL::HasCursorEnabled( const wxString& aName ) const
{
    TRACE* t = GetTrace( aName );

    return t ? t->HasCursor() : false;
}