////////////////////////////////////////////////////////////////////////////////// // qmults_stim.sv // SystemVerilog version of test.v from Basel Halak // ////////////////////////////////////////////////////////////////////////////////// module qmults_stim; timeunit 1ns; timeprecision 1ps; // Inputs logic [31:0] multiplicand; logic [31:0] multiplier; logic start; logic Clock; logic nReset; // Outputs wire [31:0] result; wire complete; wire overflow; // Instantiate the Unit Under Test (UUT) qmults uut ( .multiplicand, .multiplier, .start, .Clock, .nReset, .result, .complete, .overflow ); logic [10:0] count; initial begin // Initialize Inputs multiplicand = 3; multiplier = 0; start = 0; Clock = 0; nReset=1; count = 0; // Wait 100 ns for global reset to finish #100; nReset =0; #100; nReset =1; #10000; $finish; end //clock generator always #1.5 Clock = ~Clock; always @(posedge Clock) begin if (count == 47) begin count <= 0; start <= 1'b1; end else begin count <= count + 1; start <= 1'b0; end end always @(count) begin if (count == 47) begin if ( multiplier > 32'h1FFFFFFF ) begin multiplier <= 1; multiplicand = (multiplicand << 1) + 3; end else multiplier = (multiplier << 1) + 1; end end logic was_going; always @(posedge Clock) begin if ( was_going && complete ) $display ("%d,%d,%d,%b", multiplicand, multiplier, result, overflow); // Monitor the stuff we care about was_going = ( complete === 0 ); end endmodule