Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module halfadder (a, b, sum, cout);
- input a, b;
- output sum, cout;
- and carry(cout, a, b);
- xor (sum, a, b);
- endmodule
- module fulladder (a, b, cin, sum, cout);
- input a, b, cin;
- output sum, cout;
- wire carry1, carry2, sum1;
- halfadder h1 (a, b, sum1, carry1);
- halfadder h2 (cin, sum1, sum, carry2);
- or (cout, carry1, carry2);
- endmodule
- module SubtractorCircuit (a1, b1, a2, b2, a3, b3, a4, b4, cin, coutinv,sum11, sum22, sum33, sum44);
- input a1, b1, a2, b2, a3, b3, a4, b4, cin;
- output sum11, sum22, sum33, sum44,coutinv;
- wire carry1, carry2, carry3;
- wire b11,b22,b33,b44, cout;
- wire sum1, sum2, sum3, sum4;
- not(b11,b1);
- not(b22,b2);
- not(b33,b3);
- not(b44,b4);
- not(coutinv,cout);
- not(sum11,sum1);
- not(sum22,sum2);
- not(sum33,sum3);
- not(sum44,sum4);
- fulladder f1(a1, b11, cin, sum1, carry1);
- fulladder f2(a2, b22, carry1, sum2, carry2);
- fulladder f3(a3, b33, carry2, sum3, carry3);
- fulladder f4(a4, b44, carry3, sum4, cout);
- endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement