8-bit Ripple carry adder using 2 Four bit adder:
module
bit_8adder(
input [7:0] a,
input [7:0] b,
input cin,
output [8:0] sum);
wire tmp;
add8_use4
A1(a[0],a[1],a[2],a[3],b[0],b[1],b[2],b[3],cin,sum[0],sum[1],sum[2],sum[3],tmp);
add8_use4 A2(a[4],a[5],a[6],a[7],b[4],b[5],b[6],b[7],tmp,sum[4],sum[5],sum[6],sum[7],sum[8]);
endmodule
module add8_use4(
input a0, input a1, input
a2, input a3, input b0, input b1, input b2, input b3, input cin, output sum0,
output sum1,output sum2,output sum3, output carry);
wire c0,c1,c2;
fulladder
FA1(a0,b0,cin,sum0,c0);
fulladder
FA2(a1,b1,tmp[0],sum1,c1);
fulladder
FA3(a2,b2,tmp[1],sum2,c2);
fulladder
FA4(a3,b3,tmp[2],sum3,carry);
endmodule
No comments:
Post a Comment