diff options
author | functionpointersuss <joshua@joshuayun.com> | 2023-12-23 13:36:04 +0800 |
---|---|---|
committer | functionpointersuss <joshua@joshuayun.com> | 2023-12-23 13:36:04 +0800 |
commit | dec5747241d15fca0b94117205a139b4ba692a9d (patch) | |
tree | c7e61055b703eef47bbf032d252135cc1d1c592e /multiplier/hvl | |
parent | 5b04327dfa7a3005819045c9cc19e558e86d59d5 (diff) | |
download | riscv-processor-dec5747241d15fca0b94117205a139b4ba692a9d.tar.gz |
updated gitignore, updated testbench, added beginnings of synthesis testing
Diffstat (limited to 'multiplier/hvl')
-rw-r--r-- | multiplier/hvl/tb_multiplier.sv | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/multiplier/hvl/tb_multiplier.sv b/multiplier/hvl/tb_multiplier.sv new file mode 100644 index 0000000..f9dcf2c --- /dev/null +++ b/multiplier/hvl/tb_multiplier.sv @@ -0,0 +1,48 @@ +`default_nettype none +`timescale 1ns/1ps +`define NUMTESTS 100000 + +module tb_multiplier(); + +logic [31:0] a; +logic [31:0] b; +logic [63:0] c; +logic [63:0] product; + +multiplier dut (a, b, c); + +int i; +initial begin + + $fsdbDumpfile("dump.fsdb"); + $fsdbDumpvars(0, "+all"); + + for (i = 0; i < `NUMTESTS; i=i+1) begin + a = $urandom(); + b = $urandom(); + product = a * b; + #10; + if (product != c) begin + $displayh("A: %0d", a); + $displayh("B: %0d", b); + $displayh("C: %0d", c); + $displayh("EXPTECTED: %0d", product); + $error("TEST FAILED"); + end + else if (i % 1000 == 0) begin + $display("Test %d passed", i); + $displayh("A: %0d", a); + $displayh("B: %0d", b); + $displayh("C: %0d", c); + $displayh("EXPTECTED: %0d", product); + end + end + + $display("TEST PASSES"); + + $finish; +end + + + +endmodule |