From dec5747241d15fca0b94117205a139b4ba692a9d Mon Sep 17 00:00:00 2001 From: functionpointersuss Date: Sat, 23 Dec 2023 13:36:04 +0800 Subject: updated gitignore, updated testbench, added beginnings of synthesis testing --- multiplier/hvl/tb_multiplier.sv | 48 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 multiplier/hvl/tb_multiplier.sv (limited to 'multiplier/hvl') 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 -- cgit v1.2.3