mirror of
				https://github.com/openhwgroup/cvw
				synced 2025-02-11 06:05:49 +00:00 
			
		
		
		
	Merge branch 'main' of https://github.com/davidharrishmc/riscv-wally into main
This commit is contained in:
		
						commit
						86ff349baf
					
				@ -34,7 +34,8 @@ stateGDBpath = outDir+'intermediate-outputs/stateGDB.txt'
 | 
			
		||||
if not os.path.exists(stateGDBpath):
 | 
			
		||||
    sys.exit('Error input file '+stateGDBpath+'not found')
 | 
			
		||||
 | 
			
		||||
singleCSRs = ['pc','mip','mie','mscratch','mcause','mepc','mtvec','medeleg','mideleg','sscratch','scause','sepc','stvec','sedeleg','sideleg','satp','mstatus']
 | 
			
		||||
singleCSRs = ['pc','mip','mie','mscratch','mcause','mepc','mtvec','medeleg','mideleg','sscratch','scause','sepc','stvec','sedeleg','sideleg','satp','mstatus','priv']
 | 
			
		||||
# priv (current privilege mode) isn't technically a CSR but we can log it with the same machinery
 | 
			
		||||
thirtyTwoBitCSRs = ['mcounteren','scounteren']
 | 
			
		||||
listCSRs = ['hpmcounter','pmpaddr']
 | 
			
		||||
pmpcfg = ['pmpcfg']
 | 
			
		||||
@ -75,7 +76,7 @@ with open(stateGDBpath, 'r') as stateGDB:
 | 
			
		||||
                outFile = open(outDir+outFileName, 'w')
 | 
			
		||||
                outFile.write(val+'\n')
 | 
			
		||||
                outFile.close()
 | 
			
		||||
            if name in thirtyTwoBitCSRs: 
 | 
			
		||||
            elif name in thirtyTwoBitCSRs: 
 | 
			
		||||
                outFileName = 'checkpoint-'+name.upper() 
 | 
			
		||||
                outFile = open(outDir+outFileName, 'w')
 | 
			
		||||
                val = int(val,16) & 0xffffffff
 | 
			
		||||
 | 
			
		||||
@ -197,7 +197,7 @@ module testbench();
 | 
			
		||||
  `define STATUS_MIE  `CSR_BASE.csrsr.STATUS_MIE
 | 
			
		||||
  `define STATUS_SIE  `CSR_BASE.csrsr.STATUS_SIE
 | 
			
		||||
  `define STATUS_UIE  `CSR_BASE.csrsr.STATUS_UIE
 | 
			
		||||
  `define CURR_PRIV   dut.hart.priv.privmodereg.q
 | 
			
		||||
  `define PRIV        dut.hart.priv.privmodereg.q
 | 
			
		||||
  `define INSTRET     dut.hart.priv.csr.genblk1.counters.genblk1.genblk2.INSTRETreg.q
 | 
			
		||||
  // Common Macros
 | 
			
		||||
  `define checkCSR(CSR) \
 | 
			
		||||
@ -289,11 +289,11 @@ module testbench();
 | 
			
		||||
  `INIT_CHECKPOINT_VAL(MTVEC,      [`XLEN-1:0]);
 | 
			
		||||
  `INIT_CHECKPOINT_VAL(STVEC,      [`XLEN-1:0]);
 | 
			
		||||
  `INIT_CHECKPOINT_VAL(SATP,       [`XLEN-1:0]);
 | 
			
		||||
  `INIT_CHECKPOINT_VAL(PRIV,       [1:0]);
 | 
			
		||||
  `MAKE_CHECKPOINT_INIT_SIGNAL(MSTATUS, [`XLEN-1:0],0,0);
 | 
			
		||||
 | 
			
		||||
  integer ramFile;
 | 
			
		||||
  integer readResult;
 | 
			
		||||
  assign initPriv = (initPC[0][`XLEN-1]) ? 2'h1 : 2'h3; // *** a hacky way to detect initial privilege level
 | 
			
		||||
  initial begin
 | 
			
		||||
    force dut.hart.priv.SwIntM = 0;
 | 
			
		||||
    force dut.hart.priv.TimerIntM = 0;
 | 
			
		||||
@ -325,7 +325,6 @@ module testbench();
 | 
			
		||||
      force {`STATUS_SPIE,`STATUS_UPIE,`STATUS_MIE} = initMSTATUS[0][5:3];
 | 
			
		||||
      force {`STATUS_SIE,`STATUS_UIE} = initMSTATUS[0][1:0];
 | 
			
		||||
      force `INSTRET = CHECKPOINT;
 | 
			
		||||
      force `CURR_PRIV = initPriv;
 | 
			
		||||
      while (reset!==1) #1;
 | 
			
		||||
      while (reset!==0) #1;
 | 
			
		||||
      #1;
 | 
			
		||||
@ -335,7 +334,6 @@ module testbench();
 | 
			
		||||
      release {`STATUS_SPIE,`STATUS_UPIE,`STATUS_MIE};
 | 
			
		||||
      release {`STATUS_SIE,`STATUS_UIE};
 | 
			
		||||
      release `INSTRET;
 | 
			
		||||
      release `CURR_PRIV;
 | 
			
		||||
    end
 | 
			
		||||
    // Get the E-stage trace reader ahead of the M-stage trace reader
 | 
			
		||||
    matchCountE = $fgets(lineE,traceFileE);
 | 
			
		||||
@ -421,18 +419,6 @@ module testbench();
 | 
			
		||||
              CheckMIPFutureE = 1; \
 | 
			
		||||
              NextMIPexpected = ExpectedCSRArrayValueE[NumCSRE]; \
 | 
			
		||||
            end \
 | 
			
		||||
            //   $display("%tn: ExpectedCSRArrayM[7] (MEPC) = %x",$time,ExpectedCSRArrayM[7]); \
 | 
			
		||||
            //   $display("%tn: ExpectedPCM = %x",$time,ExpectedPCM); \
 | 
			
		||||
            //   // if PC does not equal MEPC, request delayed MIP is True \
 | 
			
		||||
            //   if(ExpectedPCM != ExpectedCSRArrayM[7]) begin \
 | 
			
		||||
            //     RequestDelayedMIP = 1; \
 | 
			
		||||
            //   end else begin \
 | 
			
		||||
            //     $display("%tns: Updating MIP to %x",$time,ExpectedCSRArrayValueM[NumCSRM]); \
 | 
			
		||||
            //     MIPexpected = ExpectedCSRArrayValueM[NumCSRM]; \
 | 
			
		||||
            //     force dut.hart.priv.csr.genblk1.csri.MIP_REGW = MIPexpected; \
 | 
			
		||||
            //   end \
 | 
			
		||||
            // end  \
 | 
			
		||||
            // $display("%tns: ExpectedCSRArrayM::: %p",$time,ExpectedCSRArrayM); \
 | 
			
		||||
            if(ExpectedCSRArrayE[NumCSRE].substr(0,3) == "mepc") begin \
 | 
			
		||||
              $display("hello! we are here."); \
 | 
			
		||||
              MepcExpected = ExpectedCSRArrayValueE[NumCSRE]; \
 | 
			
		||||
@ -470,37 +456,29 @@ module testbench();
 | 
			
		||||
    if(CheckMIPFutureE) CheckMIPFutureE <= 0;
 | 
			
		||||
    CheckMIPFutureM <= CheckMIPFutureE;
 | 
			
		||||
    if(CheckMIPFutureM) begin
 | 
			
		||||
      if((ExpectedPCM != MepcExpected) & ((MepcExpected - ExpectedPCM) * (MepcExpected - ExpectedPCM) <= 16)) begin
 | 
			
		||||
        RequestDelayedMIP = 1;
 | 
			
		||||
      // $display("%tns: ExpectedPCM %x",$time,ExpectedPCM);
 | 
			
		||||
      // $display("%tns: ExpectedPCE %x",$time,ExpectedPCE);
 | 
			
		||||
      // $display("%tns: ExpectedPCW %x",$time,ExpectedPCW);
 | 
			
		||||
      if((ExpectedPCE != MepcExpected) & ((MepcExpected - ExpectedPCE) * (MepcExpected - ExpectedPCE) <= 16)) begin
 | 
			
		||||
        RequestDelayedMIP <= 1;
 | 
			
		||||
        $display("%tns: Requesting Delayed MIP. Current MEPC value is %x",$time,MepcExpected);
 | 
			
		||||
      end else begin // update MIP immediately
 | 
			
		||||
        $display("%tns: Updating MIP to %x",$time,NextMIPexpected);
 | 
			
		||||
        MIPexpected = NextMIPexpected;
 | 
			
		||||
        force dut.hart.priv.csr.genblk1.csri.MIP_REGW = MIPexpected;
 | 
			
		||||
      end
 | 
			
		||||
      $display("%tn: ExpectedCSRArrayM = %p",$time,ExpectedCSRArrayM);
 | 
			
		||||
      $display("%tn: ExpectedCSRArrayValueM = %p",$time,ExpectedCSRArrayValueM);
 | 
			
		||||
      $display("%tn: ExpectedTokens = %p",$time,ExpectedTokensM);
 | 
			
		||||
      $display("%tn: MepcExpected = %x",$time,MepcExpected);
 | 
			
		||||
      $display("%tn: ExpectedPCM = %x",$time,ExpectedPCM);
 | 
			
		||||
      // if PC does not equal MEPC, request delayed MIP is True
 | 
			
		||||
      $display("%tns: Difference/multiplication thing: %x",$time,(MepcExpected - ExpectedPCM) * (MepcExpected - ExpectedPCM));
 | 
			
		||||
      $display("%tn: ExpectedCSRArrayM[NumCSRM] %x",$time,ExpectedCSRArrayM[NumCSRM]);
 | 
			
		||||
      $display("%tn: ExpectedCSRArrayValueM[NumCSRM] %x",$time,ExpectedCSRArrayValueM[NumCSRM]);
 | 
			
		||||
        
 | 
			
		||||
      if((ExpectedPCM != MepcExpected) & ((MepcExpected - ExpectedPCM) * (MepcExpected - ExpectedPCM) <= 16)) begin
 | 
			
		||||
        RequestDelayedMIP = 1;
 | 
			
		||||
        $display("%tns: Requesting Delayed MIP. Current MEPC value is %x",$time,MepcExpected);
 | 
			
		||||
      end else begin
 | 
			
		||||
        $display("%tns: Updating MIP to %x",$time,NextMIPexpected);
 | 
			
		||||
        MIPexpected = NextMIPexpected;
 | 
			
		||||
        force dut.hart.priv.csr.genblk1.csri.MIP_REGW = MIPexpected;
 | 
			
		||||
      // $display("%tn: ExpectedCSRArrayM = %p",$time,ExpectedCSRArrayM);
 | 
			
		||||
      // $display("%tn: ExpectedCSRArrayValueM = %p",$time,ExpectedCSRArrayValueM);
 | 
			
		||||
      // $display("%tn: ExpectedTokens = %p",$time,ExpectedTokensM);
 | 
			
		||||
      // $display("%tn: MepcExpected = %x",$time,MepcExpected);
 | 
			
		||||
      // $display("%tn: ExpectedPCE = %x",$time,ExpectedPCE);
 | 
			
		||||
      // $display("%tns: Difference/multiplication thing: %x",$time,(MepcExpected - ExpectedPCE) * (MepcExpected - ExpectedPCE));
 | 
			
		||||
      // $display("%tn: ExpectedCSRArrayM[NumCSRM] %x",$time,ExpectedCSRArrayM[NumCSRM]);
 | 
			
		||||
      // $display("%tn: ExpectedCSRArrayValueM[NumCSRM] %x",$time,ExpectedCSRArrayValueM[NumCSRM]);
 | 
			
		||||
    end
 | 
			
		||||
    end
 | 
			
		||||
    if(RequestDelayedMIP) begin
 | 
			
		||||
    if(RequestDelayedMIP & checkInstrM) begin
 | 
			
		||||
      $display("%tns: Executing Delayed MIP. Current MEPC value is %x",$time,dut.hart.priv.csr.genblk1.csrm.MEPC_REGW);
 | 
			
		||||
      $display("%tns: Updating MIP to %x",$time,NextMIPexpected);
 | 
			
		||||
      $display("%tns: MepcExpected %x",$time,MepcExpected);
 | 
			
		||||
      MIPexpected = NextMIPexpected;
 | 
			
		||||
      force dut.hart.priv.csr.genblk1.csri.MIP_REGW = MIPexpected;
 | 
			
		||||
      $display("%tns: Finished Executing Delayed MIP. Current MEPC value is %x",$time,dut.hart.priv.csr.genblk1.csrm.MEPC_REGW);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user