4-bits ripple_carry_adder
unknown
plain_text
4 years ago
1.1 kB
5
Indexable
module ripple_carry_adder (in0, in1, out, cout,s_overflow,u_overflow);
// declare input signals
input [3:0] in0;
input [3:0] in1;
// declare output signals
output [3:0] out;
output cout;
output s_overflow;
output u_overflow;
// here is your design
wire [3:0] in0;
wire [3:0] in1;
wire c1, c2, c3, w1, w2, w3, w4, w5, w6, w7, w8, w9;
wire [3:0] out;
wire cout, s_overflow, u_overflow;
xor xor1(out[0], in0[0], in1[0]);
and and1(c1, in0[0], in1[0]);
xor xor2(w1, in0[1], in1[1]);
and and2(w2, w1, c1);
and and3(w3, in0[1], in1[1]);
xor xor3(out[1], w1, c1);
or or1(c2, w2, w3);
xor xor4(w4, in0[2], in1[2]);
and and4(w5, w4, c2);
and and5(w6, in0[2], in1[2]);
xor xor5(out[2], w4, c2);
or or2(c3, w5, w6);
xor xor6(w7, in0[3], in1[3]);
and and6(w8, w7, c3);
and and7(w9, in0[3], in1[3]);
xor xor7(out[3], w7, c3);
or or3(cout, w8, w9);
xor (s_overflow, cout, c3);
or or4(u_overflow, w8, w9);
endmodule
Editor is loading...