diff options
author | Michael Abed <michaelabed@gmail.com> | 2012-12-02 12:11:54 -0500 |
---|---|---|
committer | Michael Abed <michaelabed@gmail.com> | 2012-12-02 12:11:54 -0500 |
commit | a93f8d8f6331f28b8862258db95cea3ac14f7787 (patch) | |
tree | f624b9f481b06157c7d1041300703130546ea8cb /full_adder.v | |
download | ec413-lab3-master.tar.gz ec413-lab3-master.tar.bz2 ec413-lab3-master.zip |
Diffstat (limited to 'full_adder.v')
-rwxr-xr-x | full_adder.v | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/full_adder.v b/full_adder.v new file mode 100755 index 0000000..85ec9db --- /dev/null +++ b/full_adder.v @@ -0,0 +1,96 @@ +`timescale 1ns / 1ps +////////////////////////////////////////////////////////////////////////////////// +// Company: +// Engineer: +// +// Create Date: 14:19:23 09/26/2012 +// Design Name: +// Module Name: full_adder +// Project Name: +// Target Devices: +// Tool versions: +// Description: +// +// Dependencies: +// +// Revision: +// Revision 0.01 - File Created +// Additional Comments: +// +///////////////////////////////////////////////////////////////////////////////// + + + +module fa( + input A, + input B, + input Carry_In, + output Sum, + output Carry_Out + ); +`define timed +`ifdef timed + +wire s1, s2, s3, s4; // sum wires +wire c1, c2, c3; // carry wires +wire ia, ib, ic; // inverted wires + +// invert wires ad needed for the sum +not n1(ia, A); +not n2(ib, B); +not n3(ic, Carry_In); + +// SUM CALCULATION + +// compute relevant minterms +and #1 a1(s1, ia, ib, Carry_In); +and #1 a2(s2, ia, B, ic); +and #1 a3(s3, A, ib, ic); +and #1 a4(s4, A, B, Carry_In); + +// or minterm results +or #1 sum(Sum, s1, s2, s3, s4); + +// CARRY CALCULATION + +// compute minterms +and #1 ca1(c1, A, B); +and #1 ca2(c2, A, Carry_In); +and #1 ca3(c3, B, Carry_In); + +// or results +or #1 cout(Carry_Out, c1, c2, c3); + + +`else +wire s1, s2, s3, s4; // sum wires +wire c1, c2, c3; // carry wires +wire ia, ib, ic; // inverted wires + +// invert wires ad needed for the sum +not n1(ia, A); +not n2(ib, B); +not n3(ic, Carry_In); + +// SUM CALCULATION + +// compute relevant minterms +and a1(s1, ia, ib, Carry_In); +and a2(s2, ia, B, ic); +and a3(s3, A, ib, ic); +and a4(s4, A, B, Carry_In); + +// or minterm results +or sum(Sum, s1, s2, s3, s4); + +// CARRY CALCULATION + +// compute minterms +and ca1(c1, A, B); +and ca2(c2, A, Carry_In); +and ca3(c3, B, Carry_In); + +// or results +or cout(Carry_Out, c1, c2, c3); +`endif +endmodule |