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
						0baa004bb4
					
				@ -1,3 +1,3 @@
 | 
			
		||||
vsim -c <<!
 | 
			
		||||
do wally-busybear.do 
 | 
			
		||||
do wally-busybear-batch.do 
 | 
			
		||||
!
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										46
									
								
								wally-pipelined/regression/wally-busybear-batch.do
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										46
									
								
								wally-pipelined/regression/wally-busybear-batch.do
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,46 @@
 | 
			
		||||
# wally-pipelined.do 
 | 
			
		||||
#
 | 
			
		||||
# Modification by Oklahoma State University & Harvey Mudd College
 | 
			
		||||
# Use with testbench_busybear 
 | 
			
		||||
# James Stine, 2008; David Harris 2021
 | 
			
		||||
# Go Cowboys!!!!!!
 | 
			
		||||
#
 | 
			
		||||
# Takes 1:10 to run RV64IC tests using gui
 | 
			
		||||
 | 
			
		||||
# Use this wally-pipelined.do file to run this example.
 | 
			
		||||
# Either bring up ModelSim and type the following at the "ModelSim>" prompt:
 | 
			
		||||
#     do wally-pipelined.do
 | 
			
		||||
# or, to run from a shell, type the following at the shell prompt:
 | 
			
		||||
#     vsim -do wally-pipelined.do -c
 | 
			
		||||
# (omit the "-c" to see the GUI while running from the shell)
 | 
			
		||||
 | 
			
		||||
onbreak {resume}
 | 
			
		||||
 | 
			
		||||
# create library
 | 
			
		||||
if [file exists work-busybear] {
 | 
			
		||||
    vdel -all -lib work-busybear
 | 
			
		||||
}
 | 
			
		||||
vlib work-busybear
 | 
			
		||||
 | 
			
		||||
# compile source files
 | 
			
		||||
# suppress spurious warnngs about 
 | 
			
		||||
# "Extra checking for conflicts with always_comb done at vopt time"
 | 
			
		||||
# because vsim will run vopt
 | 
			
		||||
vlog +incdir+../config/busybear ../testbench/*.sv ../src/*/*.sv -suppress 2583
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# start and run simulation
 | 
			
		||||
# remove +acc flag for faster sim during regressions if there is no need to access internal signals
 | 
			
		||||
vopt +acc=+/testbench_busybear/dut/hart/ifu/bpred/DirPredictor/memory/memory +acc=+/testbench_busybear/dut/hart/ifu/bpred/TargetPredictor/memory/memory work.testbench_busybear -o workopt 
 | 
			
		||||
 | 
			
		||||
vsim workopt -suppress 8852,12070
 | 
			
		||||
# load the branch predictors with known data. The value of the data is not important for function, but
 | 
			
		||||
# is important for perventing pessimistic x propagation.
 | 
			
		||||
mem load -infile twoBitPredictor.txt -format bin testbench_busybear/dut/hart/ifu/bpred/DirPredictor/memory/memory
 | 
			
		||||
switch $argc {
 | 
			
		||||
    0 {mem load -infile ../config/rv64ic/BTBPredictor.txt -format bin testbench_busybear/dut/hart/ifu/bpred/TargetPredictor/memory/memory}
 | 
			
		||||
    1 {mem load -infile ../config/$1/BTBPredictor.txt -format bin testbench_busybear/dut/hart/ifu/bpred/TargetPredictor/memory/memory}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
run -all
 | 
			
		||||
quit
 | 
			
		||||
@ -42,15 +42,6 @@ switch $argc {
 | 
			
		||||
    1 {mem load -infile ../config/$1/BTBPredictor.txt -format bin testbench_busybear/dut/hart/ifu/bpred/TargetPredictor/memory/memory}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
mem load -startaddress 0 -endaddress 2047 -filltype value -fillradix hex -filldata 0 /testbench_busybear/dut/uncore/bootdtim/RAM
 | 
			
		||||
mem load -startaddress 512 -i "/courses/e190ax/busybear_boot/bootmem.txt" -format hex /testbench_busybear/dut/uncore/bootdtim/RAM
 | 
			
		||||
mem load -startaddress 0 -endaddress 2047 -filltype value -fillradix hex -filldata 0 /testbench_busybear/dut/imem/bootram
 | 
			
		||||
mem load -startaddress 512 -i "/courses/e190ax/busybear_boot/bootmem.txt" -format hex /testbench_busybear/dut/imem/bootram
 | 
			
		||||
mem load -startaddress 268435456 -endaddress 285212671 -filltype value -fillradix hex -filldata 0 /testbench_busybear/dut/uncore/dtim/RAM
 | 
			
		||||
mem load -startaddress 268435456 -i "/courses/e190ax/busybear_boot/ram.txt" -format hex /testbench_busybear/dut/uncore/dtim/RAM
 | 
			
		||||
mem load -startaddress 268435456 -endaddress 285212671 -filltype value -fillradix hex -filldata 0 /testbench_busybear/dut/imem/RAM
 | 
			
		||||
mem load -startaddress 268435456 -i "/courses/e190ax/busybear_boot/ram.txt" -format hex /testbench_busybear/dut/imem/RAM
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
view wave
 | 
			
		||||
 | 
			
		||||
@ -63,7 +54,9 @@ add wave -hex /testbench_busybear/PCtext
 | 
			
		||||
add wave -hex /testbench_busybear/pcExpected
 | 
			
		||||
add wave -hex /testbench_busybear/dut/hart/ifu/PCF
 | 
			
		||||
add wave -hex /testbench_busybear/dut/hart/ifu/InstrF
 | 
			
		||||
add wave -hex /testbench_busybear/dut/InstrF
 | 
			
		||||
add wave -hex /testbench_busybear/dut/hart/ifu/StallD
 | 
			
		||||
add wave -hex /testbench_busybear/dut/hart/ifu/FlushD
 | 
			
		||||
add wave -hex /testbench_busybear/dut/hart/ifu/InstrRawD
 | 
			
		||||
add wave /testbench_busybear/CheckInstrF
 | 
			
		||||
add wave /testbench_busybear/lastCheckInstrF
 | 
			
		||||
add wave /testbench_busybear/speculative
 | 
			
		||||
 | 
			
		||||
@ -95,6 +95,14 @@ module testbench_busybear();
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  // initial loading of memories
 | 
			
		||||
  initial begin
 | 
			
		||||
    $readmemh("/courses/e190ax/busybear_boot/bootmem.txt", dut.uncore.bootdtim.RAM, 'h1000 >> 3);
 | 
			
		||||
    $readmemh("/courses/e190ax/busybear_boot/ram.txt", dut.uncore.dtim.RAM);
 | 
			
		||||
    $readmemh("/courses/e190ax/busybear_boot/bootmem.txt", dut.imem.bootram, 'h1000 >> 3);
 | 
			
		||||
    $readmemh("/courses/e190ax/busybear_boot/ram.txt", dut.imem.RAM);
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  integer warningCount = 0;
 | 
			
		||||
 | 
			
		||||
  //logic[63:0] adrTranslation[4:0];
 | 
			
		||||
@ -154,10 +162,10 @@ module testbench_busybear();
 | 
			
		||||
            $display("%0t ps, instr %0d: rf[%0d] does not equal rf expected: %x, %x", $time, instrs, i, dut.hart.ieu.dp.regf.rf[i], regExpected);
 | 
			
		||||
            `ERROR
 | 
			
		||||
          end
 | 
			
		||||
          if (dut.hart.ieu.dp.regf.rf[i] !== regExpected) begin
 | 
			
		||||
            force dut.hart.ieu.dp.regf.rf[i] = regExpected;
 | 
			
		||||
            release dut.hart.ieu.dp.regf.rf[i];
 | 
			
		||||
          end
 | 
			
		||||
          //if (dut.hart.ieu.dp.regf.rf[i] !== regExpected) begin
 | 
			
		||||
          //  force dut.hart.ieu.dp.regf.rf[i] = regExpected;
 | 
			
		||||
          //  release dut.hart.ieu.dp.regf.rf[i];
 | 
			
		||||
          //end
 | 
			
		||||
        end
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
@ -179,8 +187,8 @@ module testbench_busybear();
 | 
			
		||||
 | 
			
		||||
  logic [`XLEN-1:0] readAdrExpected;
 | 
			
		||||
 | 
			
		||||
  always @(dut.hart.MemRWM[1] or HADDR) begin
 | 
			
		||||
    if (dut.hart.MemRWM[1] && HADDR != dut.PCF) begin
 | 
			
		||||
  always @(dut.hart.MemRWM[1] or HADDR or dut.HRDATA) begin
 | 
			
		||||
    if (dut.hart.MemRWM[1] && HADDR != dut.PCF && dut.HRDATA != {64{1'bx}}) begin
 | 
			
		||||
      if($feof(data_file_memR)) begin
 | 
			
		||||
        $display("no more memR data to read");
 | 
			
		||||
        `ERROR
 | 
			
		||||
@ -194,7 +202,7 @@ module testbench_busybear();
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      if (((readMask & HRDATA) !== (readMask & dut.HRDATA)) && (HADDR >= 'h80000000 && HADDR <= 'h87FFFFFF)) begin
 | 
			
		||||
        $display("warning %0t ps, instr %0d: HRDATA does not equal dut.HRDATA: %x, %x from address %x, %x", $time, instrs, HRDATA, dut.HRDATA, HADDR, HSIZE);
 | 
			
		||||
        $display("warning %0t ps, instr %0d: ExpectedHRDATA does not equal dut.HRDATA: %x, %x from address %x, %x", $time, instrs, HRDATA, dut.HRDATA, HADDR, HSIZE);
 | 
			
		||||
        warningCount += 1;
 | 
			
		||||
        `ERROR
 | 
			
		||||
      end
 | 
			
		||||
@ -340,13 +348,40 @@ module testbench_busybear();
 | 
			
		||||
  always @(dut.PCF or dut.hart.ifu.InstrF or reset) begin
 | 
			
		||||
    if(~HWRITE) begin
 | 
			
		||||
    #3;
 | 
			
		||||
    if (~reset && dut.hart.ifu.InstrF[15:0] !== {16{1'bx}}) begin
 | 
			
		||||
    if (~reset && dut.hart.ifu.InstrF[15:0] !== {16{1'bx}} && ~dut.hart.StallD) begin
 | 
			
		||||
      if (dut.PCF !== lastPCF) begin
 | 
			
		||||
        lastCheckInstrF = CheckInstrF;
 | 
			
		||||
        lastPC <= dut.PCF;
 | 
			
		||||
        lastPC2 <= lastPC;
 | 
			
		||||
        if (speculative && (lastPC != pcExpected)) begin
 | 
			
		||||
          speculative = ~equal(dut.PCF,pcExpected,3);
 | 
			
		||||
          if(dut.PCF===pcExpected) begin
 | 
			
		||||
            if(dut.hart.ifu.InstrF[6:0] == 7'b1010011) begin // for now, NOP out any float instrs
 | 
			
		||||
              force CheckInstrF = 32'b0010011;
 | 
			
		||||
              release CheckInstrF;
 | 
			
		||||
              force dut.hart.ifu.InstrF = 32'b0010011;
 | 
			
		||||
              #7;
 | 
			
		||||
              release dut.hart.ifu.InstrF;
 | 
			
		||||
              $display("warning: NOPing out %s at PC=%0x, instr %0d, time %0t", PCtext, dut.PCF, instrs, $time);
 | 
			
		||||
              warningCount += 1;
 | 
			
		||||
              forcedInstr = 1;
 | 
			
		||||
            end
 | 
			
		||||
            else begin
 | 
			
		||||
              if(dut.hart.ifu.InstrF[28:27] != 2'b11 && dut.hart.ifu.InstrF[6:0] == 7'b0101111) begin //for now, replace non-SC A instrs with LD
 | 
			
		||||
                force CheckInstrF = {12'b0, CheckInstrF[19:7], 7'b0000011};
 | 
			
		||||
                release CheckInstrF;
 | 
			
		||||
                force dut.hart.ifu.InstrF = {12'b0, dut.hart.ifu.InstrF[19:7], 7'b0000011};
 | 
			
		||||
                #7;
 | 
			
		||||
                release dut.hart.ifu.InstrF;
 | 
			
		||||
                $display("warning: replacing AMO instr %s at PC=%0x with ld", PCtext, dut.PCF);
 | 
			
		||||
                warningCount += 1;
 | 
			
		||||
                forcedInstr = 1;
 | 
			
		||||
              end
 | 
			
		||||
              else begin
 | 
			
		||||
                forcedInstr = 0;
 | 
			
		||||
              end
 | 
			
		||||
            end
 | 
			
		||||
          end
 | 
			
		||||
        end
 | 
			
		||||
        else begin
 | 
			
		||||
          if($feof(data_file_PC)) begin
 | 
			
		||||
@ -359,15 +394,24 @@ module testbench_busybear();
 | 
			
		||||
            PCtext = {PCtext, " ", PCtext2};
 | 
			
		||||
          end
 | 
			
		||||
          scan_file_PC = $fscanf(data_file_PC, "%x\n", CheckInstrF);
 | 
			
		||||
          if(CheckInstrF[6:0] == 7'b1010011) begin // for now, NOP out any float instrs
 | 
			
		||||
            CheckInstrF = 32'b0010011;
 | 
			
		||||
            $display("warning: NOPing out %s at PC=%0x", PCtext, dut.PCF);
 | 
			
		||||
          if(dut.PCF === pcExpected) begin
 | 
			
		||||
            if(dut.hart.ifu.InstrF[6:0] == 7'b1010011) begin // for now, NOP out any float instrs
 | 
			
		||||
              force CheckInstrF = 32'b0010011;
 | 
			
		||||
              release CheckInstrF;
 | 
			
		||||
              force dut.hart.ifu.InstrF = 32'b0010011;
 | 
			
		||||
              #7;
 | 
			
		||||
              release dut.hart.ifu.InstrF;
 | 
			
		||||
              $display("warning: NOPing out %s at PC=%0x, instr %0d, time %0t", PCtext, dut.PCF, instrs, $time);
 | 
			
		||||
              warningCount += 1;
 | 
			
		||||
              forcedInstr = 1;
 | 
			
		||||
            end
 | 
			
		||||
            else begin
 | 
			
		||||
            if(CheckInstrF[28:27] != 2'b11 && CheckInstrF[6:0] == 7'b0101111) begin //for now, replace non-SC A instrs with LD
 | 
			
		||||
              CheckInstrF = {12'b0, CheckInstrF[19:7], 7'b0000011};
 | 
			
		||||
              if(dut.hart.ifu.InstrF[28:27] != 2'b11 && dut.hart.ifu.InstrF[6:0] == 7'b0101111) begin //for now, replace non-SC A instrs with LD
 | 
			
		||||
                force CheckInstrF = {12'b0, CheckInstrF[19:7], 7'b0000011};
 | 
			
		||||
                release CheckInstrF;
 | 
			
		||||
                force dut.hart.ifu.InstrF = {12'b0, dut.hart.ifu.InstrF[19:7], 7'b0000011};
 | 
			
		||||
                #7;
 | 
			
		||||
                release dut.hart.ifu.InstrF;
 | 
			
		||||
                $display("warning: replacing AMO instr %s at PC=%0x with ld", PCtext, dut.PCF);
 | 
			
		||||
                warningCount += 1;
 | 
			
		||||
                forcedInstr = 1;
 | 
			
		||||
@ -376,6 +420,7 @@ module testbench_busybear();
 | 
			
		||||
                forcedInstr = 0;
 | 
			
		||||
              end
 | 
			
		||||
            end
 | 
			
		||||
          end
 | 
			
		||||
          // then expected PC value
 | 
			
		||||
          scan_file_PC = $fscanf(data_file_PC, "%x\n", pcExpected);
 | 
			
		||||
          if (instrs <= 10 || (instrs <= 100 && instrs % 10 == 0) ||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user