aboutsummaryrefslogtreecommitdiff
path: root/multiplier/hvl
diff options
context:
space:
mode:
Diffstat (limited to 'multiplier/hvl')
-rw-r--r--multiplier/hvl/tb_multiplier.sv48
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