繁体   English   中英

来自 4 位进位超前 (CLA) 的 16 位加法器 - 来自块生成和传播的 Cout

[英]16-bit adder from 4-bit Carry Look Ahead (CLA) - Cout from Block Generate and Propagate

我是 Verilog 的新手。 这是我到目前为止所做的并且 4 位 CLA 工作。 但是,16 位(使用 4 位 CLA 的实例)没有。 问题肯定在于设置来自块传播( BP )和块生成( BG )的Cout_itermed (中间进位)值。 我创建了一个模块carries处理这一点。

在 Xilinx ISE 中,输出波形如下所示(未显示波形):

赛灵思ISE

module CLA_4bit(
        output [3:0] S,
        output Cout, PG, GG,
        input [3:0] A, B,
        input Cin
        );

        wire [3:0] G,P,C;

        assign G = A & B; //Generate
        assign P = A ^ B; //Propagate

        assign C[0] = Cin;
        assign C[1] = G[0] | (P[0] & C[0]);
        assign C[2] = G[1] | (P[1] & G[0]) | (P[1] & P[0] & C[0]);
        assign C[3] = G[2] | (P[2] & G[1]) | (P[2] & P[1] & G[0]) | (P[2] & P[1] & P[0] & C[0]);

        assign Cout = G[3] | (P[3] & G[2]) | (P[3] & P[2] & G[1]) | (P[3] & P[2] & P[1] & G[0]) |(P[3] & P[2] & P[1] & P[0] & C[0]);
        assign S = P ^ C;

        assign PG = P[3] & P[2] & P[1] & P[0]; // block generate
        assign GG = G[3] | (P[3] & G[2]) | (P[3] & P[2] & G[1]) | (P[3] & P[2] & P[1] & G[0]); // block propagate
endmodule

module CLA_16bit(
        output reg [15:0] S,
        output reg Cout,
        input [15:0] A, B,
        input Cin
        );

        reg [3:0] BP, BG;

        reg [3:0] Cout_itermed;

        carries my_carries(BP, GP, Cin, Cout_itermed, Cout);

        CLA_4bit cla0(S[3:0], Cout_itermed[0], BP[0], BG[0], A[3:0], B[3:0], Cin);

        CLA_4bit cla1(S[7:4], Cout_itermed[1], BP[1], BG[1], A[7:4], B[7:4], Cout_itermed[0]);

        CLA_4bit cla2(S[11:8], Cout_itermed[2], BP[2], BG[2], A[11:8], B[11:8], Cout_itermed[1]);

        CLA_4bit cla3(S[15:12], Cout_itermed[3], BP[3], BG[3], A[15:12], B[15:12], Cout_itermed[2]);

        Cout = Cout_itermed[3];
endmodule

module carries (
        input [3:0] BP,
        input [3:0] BG,
        input Cin,
        output reg [3:0] Cout_itermed,
        output reg Cout
        );

        assign Cout_itermed[0] = BG[0] |  (BP[0] & Cin);
        assign Cout_itermed[1] = BG[1] |  (BP[1] & Cout_itermed[0]);
        assign Cout_itermed[2] = BG[2] |  (BP[2] & Cout_itermed[1]);

        assign Cout = Cout_itermed[3]; 

endmodule

当我运行 4 位 CLA 的测试台时,波形确实显示(并且正确)。 任何人都可以解释问题出在carries还是CLA_16bit模块中?

Cout_itermed有两个驱动程序——第一个是CLA_4bitCout输出,第二个是carries模块的Cout_itermed输出。

这同样适用于CoutCLA_16bit (虽然它的两个驱动器最终被相同的信号, Cout_itermed[3]CLA_16bitcarries )。

请记住,在 Verilog 中,您是在描述物理电路,并且永远不应将两个源(驱动器)连接到同一根电线上——这就是我们短路的原因!

以下内容基于https://en.wikipedia.org/wiki/Lookahead_carry_unit#16-bit_adder 您需要做的是定义从CLA_16bit s 的Cout端口中删除Cout_itermed[x] (您可以让端口悬空)。 您应该将确定Cout_itermed[3] (即BG[3] | (BP[3]&Cout_itermed[2]) ) 的逻辑移动到carries模块。

暂无
暂无

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

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