2.3.4位加法器级联
module adder11(A,B,S,Cout);
// Port in declarations
input [10:0]A;
input [10:0]B;
// Port out declarations
output [10:0]S;
output Cout;
//Local signal declarations
wire [10:0]g,p;
wire [10:0]c;
wire [2:0]g_stage1;
wire [2:0]p_stage1;
wire [2:0]c_stage2;
//Preprocessing
assign g = A&B;
assign p = A^B;
//Processing
clb clb_1(.gin(g[3:0]),
.pin(p[3:0]),
.cin(c_stage2[0]),
.gout(g_stage1[0]),
.pout(p_stage1[0]),
.cout(c[3:0]));
clb clb_2(.gin(g[7:4]),
.pin(p[7:4]),
.cin(c_stage2[1]),
.gout(g_stage1[1]),
.pout(p_stage1[1]),
.cout(c[7:4]));
clb3 clb3(.gin(g[10:8]),
.pin(p[10:8]),
.cin(c_stage2[2]),
.gout(g_stage1[2]),
.pout(p_stage1[2]),
.cout(c[10:8]));
clb3 clb3_1(.gin(g_stage1),
.pin(p_stage1),
.cin(1'b0),
.gout(Cout),
.pout(),
.cout(c_stage2));
//Postprocessing
assign S = p^c;
endmodule