Progress on Verilator simulation. Full adder compiles and runs. Wally builds.

This commit is contained in:
David Harris 2023-12-31 09:53:13 -08:00
parent 2c2f692f3a
commit 17cbdb53df
5 changed files with 18 additions and 4 deletions

2
.gitignore vendored
View File

@ -182,3 +182,5 @@ benchmarks/embench/run*
sim/cfi.log sim/cfi.log
sim/cfi/* sim/cfi/*
sim/branch/* sim/branch/*
sim/obj_dir
examples/verilog/fulladder/obj_dir

View File

@ -166,7 +166,7 @@ sudo ln -sf $RISCV/sail-riscv/c_emulator/riscv_sim_RV32 /usr/bin/riscv_sim_RV32
# riscof # riscof
sudo pip3 install -U testresources riscv_config sudo pip3 install -U testresources riscv_config
pip3 install git+https://github.com/riscv/riscof.git sudo pip3 install git+https://github.com/riscv/riscof.git
# Download OSU Skywater 130 cell library # Download OSU Skywater 130 cell library
sudo mkdir -p $RISCV/cad/lib sudo mkdir -p $RISCV/cad/lib

View File

@ -3,6 +3,7 @@ module testbench();
logic a, b, c, s, cout, sexpected, coutexpected; logic a, b, c, s, cout, sexpected, coutexpected;
logic [31:0] vectornum, errors; logic [31:0] vectornum, errors;
logic [4:0] testvectors[10000:0]; logic [4:0] testvectors[10000:0];
integer cycle;
// instantiate device under test // instantiate device under test
fulladder dut(a, b, c, s, cout); fulladder dut(a, b, c, s, cout);
@ -11,12 +12,15 @@ module testbench();
always always
begin begin
clk = 1; #5; clk = 0; #5; clk = 1; #5; clk = 0; #5;
cycle = cycle + 1;
$display("cycle: %x vectornum %x testvectors[vectornum]: %b", cycle, vectornum, testvectors[vectornum]);
end end
// at start of test, load vectors and pulse reset // at start of test, load vectors and pulse reset
initial initial
begin begin
$readmemb("fulladder.tv", testvectors); $readmemb("fulladder.tv", testvectors);
cycle = 0;
vectornum = 0; errors = 0; vectornum = 0; errors = 0;
reset = 1; #22; reset = 0; reset = 1; #22; reset = 0;
end end
@ -36,10 +40,11 @@ module testbench();
errors = errors + 1; errors = errors + 1;
end end
vectornum = vectornum + 1; vectornum = vectornum + 1;
if (testvectors[vectornum] === 5'bx) begin //if (testvectors[vectornum] === 5'bx) begin
if (vectornum === 10) begin
$display("%d tests completed with %d errors", $display("%d tests completed with %d errors",
vectornum, errors); vectornum, errors);
$stop; $finish;
end end
end end
endmodule endmodule

View File

@ -0,0 +1,5 @@
#verilator --timescale "1ns/1ns" --timing -cc --exe --build --top-module testbench fulladder.sv
#verilator --timescale "1ns/1ns" --timing -cc --exe --top-module testbench fulladder.sv
#verilator --binary --top-module testbench fulladder.sv
verilator --timescale "1ns/1ns" --timing --binary --top-module testbench fulladder.sv

View File

@ -8,9 +8,11 @@ basepath=$(dirname $0)/..
#for config in rv32e rv64gc rv32gc rv32imc rv32i rv64i rv64fpquad; do #for config in rv32e rv64gc rv32gc rv32imc rv32i rv64i rv64fpquad; do
for config in rv64gc; do for config in rv64gc; do
echo "$config simulating..." echo "$config simulating..."
if !($verilator --timescale "1ns/1ns" --timing --exe --cc "$@" --top-module testbench "-I$basepath/config/shared" "-I$basepath/config/$config" $basepath/src/cvw.sv $basepath/testbench/testbench.sv $basepath/testbench/common/*.sv $basepath/src/*/*.sv $basepath/src/*/*/*.sv --relative-includes ); then # not working: -GTEST="arch64i"
if !($verilator --timescale "1ns/1ns" --timing --binary "$@" --top-module testbench "-I$basepath/config/shared" "-I$basepath/config/$config" $basepath/src/cvw.sv $basepath/testbench/testbench.sv $basepath/testbench/common/*.sv $basepath/src/*/*.sv $basepath/src/*/*/*.sv --relative-includes ); then
echo "Exiting after $config lint due to errors or warnings" echo "Exiting after $config lint due to errors or warnings"
exit 1 exit 1
fi fi
./obj_dir/Vtestbench
done done
echo "Verilation complete" echo "Verilation complete"