Question

In: Computer Science

verilog code of a 64 x64 array with 128 parameters please include test bench

verilog code of a 64 x64 array with 128 parameters

please include test bench

Solutions

Expert Solution


module array_multiplier_tb;

reg [31:0] a, b;
wire [31:0] y;

array_multiplier #(
        .width(32)
) uut (
        .a(a),
        .b(b),
        .y(y)
); 

reg [31:0] xrnd = 1;
task xorshift32;
begin
        xrnd = xrnd ^ (xrnd << 13);
        xrnd = xrnd ^ (xrnd >> 17);
        xrnd = xrnd ^ (xrnd <<  5);
end endtask

integer i;
initial begin
        // $dumpfile("array_multiplier_tb.vcd");
        // $dumpvars(0, array_multiplier_tb);

        for (i = 0; i < 100; i = i+1)
        begin
                #10;

                xorshift32;
                a <= xrnd;
                xorshift32;
                b <= xrnd;

                #10;

                $display("%d * %d = %d (%d)", a, b, y, a*b);
                if (y != a*b) begin
                        $display("ERROR!");
                        $finish;
                end
        end
        $display("PASSED.");
end

endmodule

The above is your test branch

module array_multiplier_pipeline(clk, a, b, y);

parameter width = 8;

input clk;
input [width-1:0] a, b;
output [width-1:0] y;

reg [width-1:0] a_pipeline [0:width-2];
reg [width-1:0] b_pipeline [0:width-2];
reg [width-1:0] partials [0:width-1];
integer i;

always @(posedge clk) begin
    a_pipeline[0] <= a;
    b_pipeline[0] <= b;
    for (i = 1; i < width-1; i = i+1) begin
        a_pipeline[i] <= a_pipeline[i-1];
        b_pipeline[i] <= b_pipeline[i-1];
    end

    partials[0] <= a[0] ? b : 0;
    for (i = 1; i < width; i = i+1)
        partials[i] <= (a_pipeline[i-1][i] ? b_pipeline[i-1] << i : 0) +
                partials[i-1];
end

assign y = partials[width-1];

endmodule

Related Solutions

Implement a 4x4 multiplier using gate level (verilog code and test bench)
Implement a 4x4 multiplier using gate level (verilog code and test bench)
Write the VERILOG code for an arithmetic/logic unit (ALU) with a test bench that does the...
Write the VERILOG code for an arithmetic/logic unit (ALU) with a test bench that does the following with 4 bit inputs , and can be tested in on nexys 4 board This is to be implement on : ISE Design Suite - Xilinx /* ALU Arithmetic and Logic Operations ---------------------------------------------------------------------- |ALU_Sel| ALU Operation ---------------------------------------------------------------------- | 0000 | ALU_Out = A + B; ---------------------------------------------------------------------- | 0001 | ALU_Out = A - B; ---------------------------------------------------------------------- | 0010 | ALU_Out = A * B;...
Can anyone write a Verilog code and a test bench for a universal shift register with...
Can anyone write a Verilog code and a test bench for a universal shift register with 4 bits using D flip flop? Thanks
Write the Verilog code and test bench for the following circuits: - Mealy State machine design...
Write the Verilog code and test bench for the following circuits: - Mealy State machine design for a Serial Adder Circuit - Moore State Machine design for a Serial Adder Circuit
Type up Verilog Verilog program , test bench and screenshot of the wavefore using verilog xilinx....
Type up Verilog Verilog program , test bench and screenshot of the wavefore using verilog xilinx. (PLEASE ONLY ANSWER IF YOU UNDERSTAND HOW TO USE XILINX. ******************no need to show me the state diagram or state table just the verilog code , test bench and the screenshot of the waveforem **************** Implement the function given below using each of the following methods. As few 16-1 multiplexers as possible. Behavioral Verilog. F( w , x, y , z) = ?(2 ,...
code an 8 bit LFSR random number generator in system verilog. Write a test bench, load...
code an 8 bit LFSR random number generator in system verilog. Write a test bench, load the seed 11111111, and generate the first 10 random numbers.
Using the conditional assignment statements, write the verilog code for 16:1 Mux. Write the test bench...
Using the conditional assignment statements, write the verilog code for 16:1 Mux. Write the test bench for this module.
1. Write Verilog code and test bench for Moore FSM having a single input line ‘X’...
1. Write Verilog code and test bench for Moore FSM having a single input line ‘X’ and a single output-line ’Z’. An output of 1 is to be produced coincident with the pattern 1101 and an output of ‘ 0’ is to be produced for all the other sequences and simulate it.
Implement 4-bit binary adder/subtractor using gate level. ( verilog code and test bench)
Implement 4-bit binary adder/subtractor using gate level. ( verilog code and test bench)
Implement a JK Flip flop using behavioral modeling in verilog, also write its test bench code.
Implement a JK Flip flop using behavioral modeling in verilog, also write its test bench code.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT