2014年6月7日 星期六

4 x 4 bit-array multiplier for unsigned numbers

源自於 http://blog.csdn.net/chevroletss/article/details/6292330



`timescale 1ns / 1ps
module Multiplier(
    Data1_in,
     Data2_in,
     Product_out
     );
   
    input [3:0] Data1_in;
    input [3:0] Data2_in;
    output [7:0] Product_out;
assign Product_out[0] = Data1_in[0] & Data2_in[0];
HalfAdder u0 (Data1_in[0]&Data2_in[1], Data1_in[1]&Data2_in[0], Product_out[1], Cout_u0);
FullAdder u1 (Data1_in[1]&Data2_in[1], Data1_in[2]&Data2_in[0], Cout_u0, sum_u1, Cout_u1);
FullAdder u2 (Data1_in[2]&Data2_in[1], Data1_in[3]&Data2_in[0], Cout_u1, sum_u2, Cout_u2);
HalfAdder u3 (Data1_in[3]&Data2_in[1], Cout_u2, sum_u3, Cout_u3);
HalfAdder u4 (Data1_in[0]&Data2_in[2], sum_u1, Product_out[2], Cout_u4);
FullAdder u5 (Data1_in[1]&Data2_in[2], sum_u2, Cout_u4, sum_u5, Cout_u5);
FullAdder u6 (Data1_in[2]&Data2_in[2], sum_u3, Cout_u5, sum_u6, Cout_u6);
FullAdder u7 (Data1_in[3]&Data2_in[2], Cout_u3, Cout_u6, sum_u7, Cout_u7);
HalfAdder u8 (Data1_in[0]&Data2_in[3], sum_u5, Product_out[3], Cout_u8);
FullAdder u9 (Data1_in[1]&Data2_in[3], sum_u6, Cout_u8, Product_out[4], Cout_u9);
FullAdder u10 (Data1_in[2]&Data2_in[3], sum_u7, Cout_u9, Product_out[5], Cout_u10);
FullAdder u11 (Data1_in[3]&Data2_in[3], Cout_u7, Cout_u10, Product_out[6], Product_out[7]);
endmodule 



沒有留言:

張貼留言