diff --git a/bin/wsim b/bin/wsim index fc0755164..9c4cce68f 100755 --- a/bin/wsim +++ b/bin/wsim @@ -57,9 +57,12 @@ if (args.sim == "questa"): args.args = " -GTEST=\"" + args.testsuite + "\" " + args.args cmd = "do wally.do " + args.config + " " + args.testsuite + " " + args.tb + " " + args.args if (args.coverage): - cmd += " -coverage" + cmd += " --coverage" if (args.gui): # launch Questa with GUI; add +acc to keep variables accessible - cmd = cd + "; vsim -do \"" + cmd + " +acc -GDEBUG=1\"" + if(args.tb == "testbench"): + cmd = cd + "; vsim -do \"" + cmd + " +acc -GDEBUG=1\"" + elif(args.tb == "testbench_fp"): + cmd = cd + "; vsim -do \"" + cmd + " +acc\"" else: # launch Questa in batch mode cmd = cd + "; vsim -c -do \"" + cmd + "\"" print("Running Questa with command: " + cmd) diff --git a/sim/questa/imperas.ic b/sim/questa/imperas.ic new file mode 100644 index 000000000..51344b75a --- /dev/null +++ b/sim/questa/imperas.ic @@ -0,0 +1,115 @@ +#--mpdconsole +#--gdbconsole +#--showoverrides +#--showcommands + +# Core settings +--override cpu/priv_version=1.12 +--override cpu/user_version=20191213 +# arch +--override cpu/mimpid=0x100 +--override cpu/mvendorid=0x602 +--override cpu/marchid=0x24 +--override refRoot/cpu/tvec_align=64 +--override refRoot/cpu/envcfg_mask=1 # dh 1/26/24 this should be deleted when ImperasDV is updated to allow envcfg.FIOM to be written + +# bit manipulation +--override cpu/add_Extensions=B +#--override cpu/add_implicit_Extensions=B +--override cpu/bitmanip_version=1.0.0 + +# More extensions +--override cpu/Zcb=T +--override cpu/Zicond=T +--override cpu/Zfh=T +--override cpu/Zfa=T + +# Cache block operations +--override cpu/Zicbom=T +--override cpu/Zicbop=T +--override cpu/Zicboz=T +--override cmomp_bytes=64 # Zic64b +--override cmoz_bytes=64 # Zic64b +--override lr_sc_grain=8 # Za64rs requires <=64; we use native word size + +# 64 KiB continuous huge pages supported +--override cpu/Svpbmt=T +--override cpu/Svnapot_page_mask=65536 + +# SV39 and SV48 supported +--override cpu/Sv_modes=768 + +--override cpu/Svinval=T + + +# clarify +#--override refRoot/cpu/mtvec_sext=F + +--override cpu/tval_ii_code=T + +#--override cpu/time_undefined=T +#--override cpu/cycle_undefined=T +#--override cpu/instret_undefined=T +#--override cpu/hpmcounter_undefined=T + +--override cpu/reset_address=0x80000000 + +--override cpu/unaligned=T # Zicclsm (should be true) +--override cpu/ignore_non_leaf_DAU=1 +--override cpu/wfi_is_nop=T +--override cpu/misa_Extensions_mask=0x0 # MISA not writable +--override cpu/Sstc=T + +# unsuccessfully attempt to add B extension (DH 12/21/23) +#--override cpu/add_Extensions="B" +#--override cpu/misa_Extensions=0x0014112F + +# Enable SVADU hardware update of A/D bits when menvcfg.ADUE=1 +--override cpu/Svadu=T +#--override cpu/updatePTEA=F +#--override cpu/updatePTED=F + + +# THIS NEEDS FIXING to 16 +--override cpu/PMP_registers=16 +--override cpu/PMP_undefined=T + +# PMA Settings +# 'r': read access allowed +# 'w': write access allowed +# 'x': execute access allowed +# 'a': aligned access required +# 'A': atomic instructions NOT allowed (actually USER1 privilege needed) +# 'P': push/pop instructions NOT allowed (actually USER2 privilege needed) +# '1': 1-byte accesses allowed +# '2': 2-byte accesses allowed +# '4': 4-byte accesses allowed +# '8': 8-byte accesses allowed +# '-', space: ignored (use for input string formatting). +# +# SVxx Memory 0x0000000000 0x7FFFFFFFFF +# +--callcommand refRoot/cpu/setPMA -lo 0x0000000000 -hi 0x7FFFFFFFFF -attributes " ---a-- ---- " # INITIAL +--callcommand refRoot/cpu/setPMA -lo 0x0000001000 -hi 0x0000001FFF -attributes " r-x-A- 1248 " # BOOTROM +--callcommand refRoot/cpu/setPMA -lo 0x0000012100 -hi 0x000001211F -attributes " rw-aA- --48 " # SDC +--callcommand refRoot/cpu/setPMA -lo 0x0002000000 -hi 0x000200FFFF -attributes " rw-aA- 1248 " # CLINT +--callcommand refRoot/cpu/setPMA -lo 0x000C000000 -hi 0x000FFFFFFF -attributes " rw-aA- --4- " # PLIC +--callcommand refRoot/cpu/setPMA -lo 0x0010000000 -hi 0x0010000007 -attributes " rw-aA- 1--- " # UART0 error - 0x10000000 - 0x100000FF +--callcommand refRoot/cpu/setPMA -lo 0x0010060000 -hi 0x00100600FF -attributes " rw-aA- --4- " # GPIO error - 0x10069000 - 0x100600FF +--callcommand refRoot/cpu/setPMA -lo 0x0010040000 -hi 0x0010040FFF -attributes " rw-aA- --4- " # SPI error - 0x10040000 - 0x10040FFF +#--callcommand refRoot/cpu/setPMA -lo 0x0080000000 -hi 0x008FFFFFFF -attributes " rwxaA- 1248 " # UNCORE_RAM +--callcommand refRoot/cpu/setPMA -lo 0x0080000000 -hi 0x008FFFFFFF -attributes " rwx--- 1248 " # UNCORE_RAM + +# Enable the Imperas instruction coverage +#-extlib refRoot/cpu/cv=imperas.com/intercept/riscvInstructionCoverage/1.0 +#-override refRoot/cpu/cv/cover=basic +#-override refRoot/cpu/cv/extensions=RV32I + +# Add Imperas simulator application instruction tracing +--verbose +#--trace --tracechange --traceshowicount --tracemode -tracemem ASX --monitornetschange --traceafter 300000000 +--override cpu/debugflags=6 --override cpu/verbose=1 +--override cpu/show_c_prefix=T + +# Store simulator output to logfile +--output imperas.log diff --git a/sim/questa/run-imperas-linux.sh b/sim/questa/run-imperas-linux.sh index 7192adb81..d0f3981c4 100755 --- a/sim/questa/run-imperas-linux.sh +++ b/sim/questa/run-imperas-linux.sh @@ -7,4 +7,4 @@ export OTHERFLAGS="+TRACE2LOG_ENABLE=1 +TRACE2LOG_AFTER=100" #export OTHERFLAGS="+TRACE2LOG_ENABLE=1 +TRACE2LOG_AFTER=10500000" #export OTHERFLAGS="" -vsim -c -do "do questa/wally-linux-imperas.do buildroot buildroot $::env(RISCV) 0 0 0" +vsim -c -do "do wally.do buildroot buildroot testbench --lockstep" diff --git a/sim/questa/wally-linux-imperas.do b/sim/questa/wally-linux-imperas.do deleted file mode 100644 index 1165676a0..000000000 --- a/sim/questa/wally-linux-imperas.do +++ /dev/null @@ -1,84 +0,0 @@ -# wally.do -# SPDX-License-Identifier: Apache-2.0 WITH SHL-2.1 -# -# Modification by Oklahoma State University & Harvey Mudd College -# Use with Testbench -# James Stine, 2008; David Harris 2021 -# Go Cowboys!!!!!! -# -# Takes 1:10 to run RV64IC tests using gui - -# run with vsim -do "do wally-pipelined.do rv64ic riscvarchtest-64m" - -# Use this wally-pipelined.do file to run this example. -# Either bring up ModelSim and type the following at the "ModelSim>" prompt: -# do wally.do -# or, to run from a shell, type the following at the shell prompt: -# vsim -do wally.do -c -# (omit the "-c" to see the GUI while running from the shell) - -onbreak {resume} - -# create library -if [file exists work] { - vdel -all -} -vlib work - -# compile source files -# suppress spurious warnngs about -# "Extra checking for conflicts with always_comb done at vopt time" -# because vsim will run vopt - -# start and run simulation -# remove +acc flag for faster sim during regressions if there is no need to access internal signals -if {$2 eq "buildroot"} { - vlog -lint -work work_${1}_${2} \ - +define+USE_IMPERAS_DV \ - +incdir+../config/deriv/$1 \ - +incdir+../config/shared \ - +incdir+$env(IMPERAS_HOME)/ImpPublic/include/host \ - +incdir+$env(IMPERAS_HOME)/ImpProprietary/include/host \ - $env(IMPERAS_HOME)/ImpPublic/source/host/rvvi/rvviApiPkg.sv \ - $env(IMPERAS_HOME)/ImpPublic/source/host/rvvi/rvviTrace.sv \ - $env(IMPERAS_HOME)/ImpProprietary/source/host/idv/idvApiPkg.sv \ - $env(IMPERAS_HOME)/ImpProprietary/source/host/idv/idvPkg.sv \ - $env(IMPERAS_HOME)/ImpProprietary/source/host/idv/idvApiPkg.sv \ - $env(IMPERAS_HOME)/ImpProprietary/source/host/idv/trace2api.sv \ - $env(IMPERAS_HOME)/ImpProprietary/source/host/idv/trace2log.sv \ - $env(IMPERAS_HOME)/ImpProprietary/source/host/idv/trace2cov.sv \ - $env(IMPERAS_HOME)/ImpProprietary/source/host/idv/trace2bin.sv \ - ../src/cvw.sv \ - ../testbench/testbench.sv \ - ../testbench/common/*.sv ../src/*/*.sv \ - ../src/*/*/*.sv -suppress 2583 - - # - # start and run simulation - # for profiling add - # vopt -fprofile - # vsim -fprofile+perf - # visualizer -fprofile+perf+dir=fprofile - # - eval vopt +acc work_${1}_${2}.testbench -work work_${1}_${2} -G RISCV_DIR=$3 \ - -G TEST=$2 -o testbenchopt - eval vsim -lib work_${1}_${2} testbenchopt -suppress 8852,12070,3084,3829,13286 -fatal 7 \ - -sv_lib $env(IMPERAS_HOME)/lib/Linux64/ImperasLib/imperas.com/verification/riscv/1.0/model \ - $env(OTHERFLAGS) - - #-- Run the Simulation - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - echo "Don't forget to change DEBUG_LEVEL = 0." - echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" - #run 100 ns - #force -deposit testbench/dut/core/priv/priv/csr/csri/IE_REGW 16'h2aa - #force -deposit testbench/dut/uncore/uncore/clint/clint/MTIMECMP 64'h1000 - run 9800 ms - add log -recursive /testbench/dut/* - do wave.do - run 200 ms - #run -all - - exec ./slack-notifier/slack-notifier.py - -} diff --git a/sim/questa/wally.do b/sim/questa/wally.do index 8a21282ce..0e717f730 100644 --- a/sim/questa/wally.do +++ b/sim/questa/wally.do @@ -18,6 +18,8 @@ # vsim -do wally-batch.do -c # (omit the "-c" to see the GUI while running from the shell) +set DEBUG 1 + onbreak {resume} onerror {quit -f} @@ -42,6 +44,22 @@ set coverage 0 set CoverageVoptArg "" set CoverageVsimArg "" +set lockstep 0 +# ok this is annoying. vlog, vopt, and vsim are very picky about how arguments are passed. +# unforunately it won't allow these to be grouped as one argument per command so they are broken +# apart. +set lockstepvoptstring "" +set SVLib "" +set SVLibPath "" +set OtherFlags "" +set ImperasPubInc "" +set ImperasPrivInc "" +set rvviFiles "" +set idvFiles "" + +set GUI 0 +set accFlag "" + # Need to be able to pass arguments to vopt. Unforunately argv does not work because # it takes on different values if vsim and the do file are called from the command line or # if the do file isd called from questa sim directly. This chunk of code uses the $4 through $n @@ -50,10 +68,9 @@ set tbArgs "" set from 4 set step 1 set lst {} -set GUI 0 + set PlusArgs {} set ParamArgs {} -set accFlag "" for {set i 0} true {incr i} { set x [expr {$i*$step + $from}] if {$x > $argc} break @@ -61,66 +78,74 @@ for {set i 0} true {incr i} { lappend lst $arg } -if {$argc >= 3} { - echo "got at least 3 args" - set AccPosition [lsearch $lst "+acc"] - echo $AccPosition - if {$AccPosition != -1} { - set GUI 1 - set accFlag "+acc" - set tbArgs [lreplace $lst $AccPosition $AccPosition] - } else { - set tbArgs $lst - } - set tbArgsLst [split $tbArgs " "] +echo "number of args = $argc" +echo "lst = $lst" - set index [lsearch -exact $tbArgsLst "-coverage"] - if {$index >= 0} { - set coverage 1 - set CoverageVoptArg "+cover=sbecf" - set CoverageVsimArg "-coverage" - echo $tbArgsLst - set tbArgsLst [lreplace $tbArgsLst $index $index ] - #echo "help help help !!!!!!!!!!!!!!!!!!!!!!!!!!!" - #echo $tbArgsLst - #echo "help help help !!!!!!!!!!!!!!!!!!!!!!!!!!!" - } - - # separate the +args from the -G parameters - foreach otherArg $tbArgsLst { - if {[string index $otherArg 0] eq "+"} { - lappend PlusArgs $otherArg - } else { - lappend ParamArgs $otherArg - } +# if +acc found set flag and remove from list +set AccIndex [lsearch -exact $lst "+acc"] +if {$AccIndex >= 0} { + set GUI 1 + set accFlag "+acc" + set lst [lreplace $lst $AccIndex $AccIndex] +} + +# if +coverage found set flag and remove from list +set CoverageIndex [lsearch -exact $lst "--coverage"] +if {$CoverageIndex >= 0} { + set coverage 1 + set CoverageVoptArg "+cover=sbecf" + set CoverageVsimArg "-coverage" + set lst [lreplace $lst $CoverageIndex $CoverageIndex] +} + +set LockStepIndex [lsearch -exact $lst "--lockstep"] +if {$LockStepIndex >= 0} { + set lockstep 1 + + # ideally this would all be one or two variables, but questa is having a real hard time + # with this. For now they have to be separate. + set lockstepvoptstring "+define+USE_IMPERAS_DV" + set ImperasPubInc +incdir+$env(IMPERAS_HOME)/ImpPublic/include/host + set ImperasPrivInc +incdir+$env(IMPERAS_HOME)/ImpProprietary/include/host + set rvviFiles $env(IMPERAS_HOME)/ImpPublic/source/host/rvvi/*.sv + set idvFiles $env(IMPERAS_HOME)/ImpProprietary/source/host/idv/*.sv + set SVLib "-sv_lib" + set SVLibPath $env(IMPERAS_HOME)/lib/Linux64/ImperasLib/imperas.com/verification/riscv/1.0/model + set OtherFlags $env(OTHERFLAGS) + + set lst [lreplace $lst $LockStepIndex $LockStepIndex] +} + +# separate the +args from the -G parameters +foreach otherArg $lst { + if {[string index $otherArg 0] eq "+"} { + lappend PlusArgs $otherArg + } else { + lappend ParamArgs $otherArg } } -# helpful debug code remove later -#echo "help me!!!!!!! GUI =" -#echo $GUI -#echo "help me!!!!!!! lst =" -#echo $lst -#echo "help me!!!!!!! = accFlag =" -#echo $accFlag -#echo "help me!!!!!!! PlusArgs =" -#echo $PlusArgs -#echo "help me!!!!!!! ParamArgs =" -#echo $ParamArgs -#echo "help me!!!!!!!" + +if {$DEBUG > 0} { + echo "GUI = $GUI" + echo "coverage = $coverage" + echo "lockstep = $lockstep" + echo "remaining list = \'$lst\'" + echo "Extra +args = \'$PlusArgs\'" + echo "Extra -args = \'$ParamArgs\'" +} # compile source files # suppress spurious warnngs about # "Extra checking for conflicts with always_comb done at vopt time" # because vsim will run vopt -vlog -lint -work ${WKDIR} +incdir+${CONFIG}/${CFG} +incdir+${CONFIG}/deriv/${CFG} +incdir+${CONFIG}/shared ${SRC}/cvw.sv ${TB}/${TESTBENCH}.sv ${TB}/common/*.sv ${SRC}/*/*.sv ${SRC}/*/*/*.sv -suppress 2583 -suppress 7063,2596,13286 +vlog -lint -work ${WKDIR} +incdir+${CONFIG}/${CFG} +incdir+${CONFIG}/deriv/${CFG} ${lockstepvoptstring} ${ImperasPubInc} ${ImperasPrivInc} +incdir+${CONFIG}/shared ${rvviFiles} ${idvFiles} ${SRC}/cvw.sv ${TB}/${TESTBENCH}.sv ${TB}/common/*.sv ${SRC}/*/*.sv ${SRC}/*/*/*.sv -suppress 2583 -suppress 7063,2596,13286 # start and run simulation # remove +acc flag for faster sim during regressions if there is no need to access internal signals -vopt $accFlag wkdir/${CFG}_${TESTSUITE}.${TESTBENCH} -work ${WKDIR} ${tbArgsLst} -o testbenchopt ${CoverageVoptArg} +vopt $accFlag wkdir/${CFG}_${TESTSUITE}.${TESTBENCH} -work ${WKDIR} ${lst} -o testbenchopt ${CoverageVoptArg} -# *** tbArgs producees a warning that TEST not found in design when running sim-testfloat-batch. Need to separate -G and + arguments to pass separately to vopt and vsim -vsim -lib ${WKDIR} testbenchopt +TEST=${TESTSUITE} ${PlusArgs} -fatal 7 -suppress 3829 ${CoverageVsimArg} +vsim -lib ${WKDIR} testbenchopt +TEST=${TESTSUITE} ${PlusArgs} -fatal 7 ${SVLib} ${SVLibPath} ${OtherFlags} -suppress 3829 ${CoverageVsimArg} # vsim -lib wkdir/work_${1}_${2} testbenchopt -fatal 7 -suppress 3829 # power add generates the logging necessary for said generation. @@ -137,7 +162,6 @@ if { ${GUI} } { run -all # power off -r /dut/core/* - if {$coverage} { set UCDB cov/${CFG}_${TESTSUITE}.ucdb echo "Saving coverage to ${UCDB}"