喜欢1次
                                团队编号:CICC1230
团队名称:少吃米饭多吃肉
一般的4:2压缩器是由两级3:2压缩器串接起来的,而3:2压缩器的实质就是全加器,其结构如下:
表达式如下:
代码实现:
module full_adder(
    input a,
    input b,
    input cin,
    output cout,
    output s
);
assign s = a ^ b ^ cin;
assign cout = a & b | (cin & (a | b));
endmodule
其中输出cout的权重要大于S一位才能继续送入下一个模块压缩
而对于直接串联的4:2压缩器如下:
逻辑表达式如下:
优化后:

可以看到原本的3:2压缩器两级串联会有4个XOR的延迟,而改进之后只有三个XOR的延迟
具体代码实现如下:
module single42 (
    input op1,
    input op2,
    input op3,
    input op4,
    input Cin,
    output Cout,
    output Carry,
    output Sum
);
wire o1,o2,o3,o4;
    xor xor2(o2,op3,op4);
    xor xor1(o1,op1,op2);
    xor xor3(o3,o1,o2);
    xor xor4(o4,o3,Cin);
    assign Sum = o4;
    assign Cout = (o1 == 1'b1) ? op1 : op3;
    assign Carry = (o3 == 1'b1) ? op4 : Cin;
endmodule
