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 a verilog code for a 4-bit multiplier by using 4 bit full adder
write a verilog code for a 4-bit multiplier by using 4 bit full adder
Using Behavioral model, write a Verilog description of parameterized Multiplier: 1.Make one stimulus for two different...
Using Behavioral model, write a Verilog description of parameterized Multiplier: 1.Make one stimulus for two different parameter values and show the wave forms results. 2. Analyse the circuits implementation of Structural Binary Multiplier and Behavioral-Level Multiplier, in terms of resource utilization and critical path delay (Input size should be same).
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...
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.
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
Write a VHDL code for a 8x8 bit multiplier. use structural approach. write the design code...
Write a VHDL code for a 8x8 bit multiplier. use structural approach. write the design code and testbench. Use for-generate if possible
Implement a 4x4 multiplier using gate level (verilog code and test bench)
Implement a 4x4 multiplier using gate level (verilog code and test bench)
please i need the code for an 8 bit by 8 bit multiplier in verilog ....
please i need the code for an 8 bit by 8 bit multiplier in verilog . ( pls the code should be clearly written and BOLD)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT