From 17cbdb53dfdc66f134275675f9ada548f36d4a6f Mon Sep 17 00:00:00 2001 From: David Harris Date: Sun, 31 Dec 2023 09:53:13 -0800 Subject: [PATCH] Progress on Verilator simulation. Full adder compiles and runs. Wally builds. --- .gitignore | 2 ++ bin/wally-tool-chain-install.sh | 2 +- examples/verilog/fulladder/fulladder.sv | 9 +++++++-- examples/verilog/fulladder/verilate | 5 +++++ sim/verilate | 4 +++- 5 files changed, 18 insertions(+), 4 deletions(-) create mode 100755 examples/verilog/fulladder/verilate diff --git a/.gitignore b/.gitignore index 1664b939f..26cfe6b84 100644 --- a/.gitignore +++ b/.gitignore @@ -182,3 +182,5 @@ benchmarks/embench/run* sim/cfi.log sim/cfi/* sim/branch/* +sim/obj_dir +examples/verilog/fulladder/obj_dir diff --git a/bin/wally-tool-chain-install.sh b/bin/wally-tool-chain-install.sh index ca9fdaa0e..ad19f224e 100755 --- a/bin/wally-tool-chain-install.sh +++ b/bin/wally-tool-chain-install.sh @@ -166,7 +166,7 @@ sudo ln -sf $RISCV/sail-riscv/c_emulator/riscv_sim_RV32 /usr/bin/riscv_sim_RV32 # riscof 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 sudo mkdir -p $RISCV/cad/lib diff --git a/examples/verilog/fulladder/fulladder.sv b/examples/verilog/fulladder/fulladder.sv index 4122b4978..478c3db82 100644 --- a/examples/verilog/fulladder/fulladder.sv +++ b/examples/verilog/fulladder/fulladder.sv @@ -3,6 +3,7 @@ module testbench(); logic a, b, c, s, cout, sexpected, coutexpected; logic [31:0] vectornum, errors; logic [4:0] testvectors[10000:0]; + integer cycle; // instantiate device under test fulladder dut(a, b, c, s, cout); @@ -11,12 +12,15 @@ module testbench(); always begin clk = 1; #5; clk = 0; #5; + cycle = cycle + 1; + $display("cycle: %x vectornum %x testvectors[vectornum]: %b", cycle, vectornum, testvectors[vectornum]); end // at start of test, load vectors and pulse reset initial begin $readmemb("fulladder.tv", testvectors); + cycle = 0; vectornum = 0; errors = 0; reset = 1; #22; reset = 0; end @@ -36,10 +40,11 @@ module testbench(); errors = errors + 1; end 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", vectornum, errors); - $stop; + $finish; end end endmodule diff --git a/examples/verilog/fulladder/verilate b/examples/verilog/fulladder/verilate new file mode 100755 index 000000000..2b6d7908d --- /dev/null +++ b/examples/verilog/fulladder/verilate @@ -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 + diff --git a/sim/verilate b/sim/verilate index c59494c1d..71a017404 100755 --- a/sim/verilate +++ b/sim/verilate @@ -8,9 +8,11 @@ basepath=$(dirname $0)/.. #for config in rv32e rv64gc rv32gc rv32imc rv32i rv64i rv64fpquad; do for config in rv64gc; do 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" exit 1 fi + ./obj_dir/Vtestbench done echo "Verilation complete"