aboutsummaryrefslogblamecommitdiff
path: root/multiplier/hvl/tb_multiplier.sv
blob: f9dcf2c14d4ded500a6c164523e7eea80554cc36 (plain) (tree)















































                                                             
`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