繁体   English   中英

这个16位进位超前加法器在结构性Verilog中看起来正确吗?

[英]does this 16 bit carry look ahead adder looks correct in structual verilog?

我完成了这个16位进位超前加法器,并问教授这是否正确。 他告诉我错了。 我寻求帮助,以获取有关如何使用结构性Verilog构建构架的想法。 有人可以帮我验证我的代码有什么问题吗?

            `timescale 1ns/1ns
             module fulladder(a, b, c, s, cout); //one bit fulladder

                    //the wires
                wire w1, w2, w3, w4, s, cout;

                input a, b, c;
                output s, cout;
                reg [0 : 0] s,cout; //register with one bit

                //exclusive or gate with 1 ns delay
                  xor   #1
                  g1(w1, a, b),
                  g2(s, w1, c);
                //and gate with 1 ns delay
                  and   #1
                  g3(w2, c, b),
                  g4(w3, c, a),
                  g5(w4, a, b);
                  //or gate with 1 ns delay
                  or    #1
                  g6(cout, w2, w3, w4);

               endmodule

          //16bit carry look ahead
          module sixteen_bit_carry_lookahead(a, b, c, s, cout);
                input  [15:0] a,
                input  [15:0] b,
                input        c,    //Carry in
                output [15:0] s,    //Sum
                output       cout  //Carry

            //wires
            wire [3:1] carry, [3:0] p, [3:0] g, [3:1] carry;  
            fulladder f0(.a(a[0]), .b(b[0]), .c(c),.s(s[0]),.cout(),.g(g[0]),.p([0]));
            fulladder f1(.a(a[1]),.b(b[1]),.c(carry[1]),.s(s[1]),.cout(),.g(g[1]),.p([1]));
            fulladder f2(.a(a[2]), .b(b[2]), .c(carry[2]), .s(s[2]), .cout(), .g(g[2]),.p([2]));
            fulladder f3(.a(a[3]), .b(b[3]), .c(carry[3]), .s(s[3]), .cout(), .g(g[3]), .p([3]));
            fulladder f4(.a(a[4]), .b(b[4]), .c(carry[4]), .s(s[4]), .cout(), .g(g[4]), .p([4]));
            fulladder f5(.a(a[5]), .b(b[5]), .c(carry[5]), .s(s[5]), .cout(), .g(g[5]), .p([5]));
            fulladder f6(.a(a[6]), .b(b[6]), .c(carry[6]), .s(s[6]), .cout(), .g(g[6]), .p([6]));
            fulladder f7(.a(a[7]), .b(b[7]), .c(carry[7]), .s(s[7]), .cout(), .g(g[7]), .p([7]));
            fulladder f8(.a(a[8]), .b(b[8]), .c(carry[8]), .s(s[8]), .cout(), .g(g[8]), .p([8]) );
            fulladder f9(.a(a[9]), .b(b[9]), .c(carry[9]), .s(s[9]), .cout(), .g(g[9]), .p([9]) );
                .  
                .   //goes all the way to 16 bit
                .
            fulladder f15(.a(a[15]),.b(b[15]),.c(carry[15]),.s(s[15]),.cout(),.g(g[15),.p([15]));

            endmodule

            //the carry look ahead adder with inputs and outputs
            module carry_lookahead(.p, .g, .c, .cout);
              input .p(p); //input  [15:0] 
              input .g(g); //input  [15:0]
              output .c(carry); //output [15:1]
              output .cout (cout);  //output

            endmodule

您包含的fulladder没有传播p并生成了您在实例化中关联的g输出。 我将使用这些输出来创建一个名为broadcast_adder的新模块,并删除生成cout的逻辑。

该模块sixteen_bit_carry_lookahead缺少的一个实例carry_lookahead ,这需要为运送路径。

在fulladder的声明中,您具有reg [0:0]这与编写reg相同。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM