mbm_8x8.v (과제에서 주어진 모듈명 mba8x8 과 다르게 지정하였습니다.)
module mbm_8x8(x, y, S, cin, cout );
input [7:0] x, y;
input cin;
output [15:0] S;
output cout;
wire X_sel_0, X2_sel_0, X_sel_1, X2_sel_1, X_sel_2, X2_sel_2, X_sel_3, X2_sel_3;
wire NEG0, NEG1, NEG2, NEG3;
wire [8:0] pp1, pp2, pp3, pp4;
wire [8:0] cout0, cout1, cout2;
wire [8:0] sum0, sum1, sum2;
mux_sel M1(x,X_sel_0, X2_sel_0, NEG0, pp1);
mux_sel M2(x,X_sel_1, X2_sel_1, NEG1, pp2);
mux_sel M3(x,X_sel_2, X2_sel_2, NEG2, pp3);
mux_sel M4(x,X_sel_3, X2_sel_3, NEG3, pp4);
cod_cir C1(1`b0,y[0],y[1],X_sel_0,X2_sel_0,NEG0);
cod_cir C2(y[1],y[2],y[3],X_sel_1,X2_sel_1,NEG1);
cod_cir C3(y[3],y[4],y[5],X_sel_2,X2_sel_2,NEG2);
cod_cir C4(y[5],y[6],y[7],X_sel_3,X2_sel_3,NEG3);
pfa9 F1(pp2, {{3{pp1[8]}},pp1[7:2]}, 9`b0, sum0, cout0); // half adder
pfa9 F2(pp3,{{2{sum0[8]}},sum0[8:2]},{{2{cout0[8]}},cout0[7:1]}, sum1, cout1);
pfa9 F3(pp4,{{2{sum1[8]}},sum1[8:2]},{{2{cout1[8]}},cout1[7:1]}, sum2, cout2);
fin_add_csa U0
({sum2[8],sum2[8:0],sum1[1:0],sum0[1:0],pp1[1:0]},{cout2[8:0],NEG3,cout1[0],NEG2,cout0[0],NEG1,1`b0,NEG0},S,cin,cout);
endmodule