Question

In: Computer Science

Design a Verilog code for 64x64 array multiplier. Use behavioral Verilog description with full adders and/or...

Design a Verilog code for 64x64 array multiplier. Use behavioral Verilog description with full adders and/or half adders. Please include testbench

Solutions

Expert Solution

module array_multiplier(a, b, y);

parameter width = 8;
input [width-1:0] a, b;
output [width-1:0] y;

wire [width*width-1:0] partials;

genvar i;
assign partials[width-1 : 0] = a[0] ? b : 0;
generate for (i = 1; i < width; i = i+1) begin:gen
    assign partials[width*(i+1)-1 : width*i] = (a[i] ? b << i : 0) +
                                   partials[width*i-1 : width*(i-1)];
end endgenerate

assign y = partials[width*width-1 : width*(width-1)];

endmodule

Test bench for above program


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

Related Solutions

Design a 4-bit multiplier by using 4 bit full adder and write a verilog code.
Design a 4-bit multiplier by using 4 bit full adder and write a verilog code.
Write in verilog, code to implement a 6 bit multiplier. Cascade a 1 bit multiplier to...
Write in verilog, code to implement a 6 bit multiplier. Cascade a 1 bit multiplier to implement this.
using verilog to design a 8x8 unsigned multiplier(with testbench) utilizing a 2x8 multiplier as a building...
using verilog to design a 8x8 unsigned multiplier(with testbench) utilizing a 2x8 multiplier as a building block here is the testbench and code for 2x8: module cpp_mult(mplr,mcand, prod); input [1:0] mplr; input [7:0] mcand; output [9:0] prod; wire [9:0] mcand1; wire [9:0] mcand2; wire [9:0] mcand3; assign mcand0 = 10'b00000000; assign prod = (mplr==2'b00)?mcand0 :        ((mplr==2'b01)?{2'b00,mcand[7:0]}:        ((mplr==2'b10)?{1'b0,mcand[7:0],1'b0}:        ((mplr==2'b11)?{2'b00,mcand[7:0]}+{1'b0,mcand[7:0],1'b0}:8'hxx))); endmodule ____________________________________________________________________ module cpp_mult_tb(); reg [1:0] mplr; reg [7:0] mcand; wire [9:0] prod; // Instantiate the...
Design a circuit and write a verilog code description of the 16-bit right rotator using barrel...
Design a circuit and write a verilog code description of the 16-bit right rotator using barrel shift method
Write a verilog code for 5 to 8 multiplier using fourbit adder
Write a verilog code for 5 to 8 multiplier using fourbit adder
Implement a 4x4 multiplier using gate level (verilog code and test bench)
Implement a 4x4 multiplier using gate level (verilog code and test bench)
Design an 8-bit adder. Show Verilog code and testbench.
Design an 8-bit adder. Show Verilog code and testbench.
First, draw the state machine for the following program. Then write the corresponding Verilog behavioral code....
First, draw the state machine for the following program. Then write the corresponding Verilog behavioral code. Input: X - 1 bit number Output: Z - 1 bit number Clock: clk (State will change at positive edge of the clock) Output will be equal to one if Xn-2 Xn-1 Xn = 011 or Xn-2 Xn-1 Xn = 101
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
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