Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

8-bit adder help with my current code.

Status
Not open for further replies.

nfavenom

Newbie level 1
Joined
Nov 28, 2010
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,294
i am designing an 8 bit full adder and this is what i have so far but im not getting the correct output i would appreciate if anyone could help me out.


// 1-bit full_adder
module fulladd(sum, c_out, a, b, c_in);

// I/O port declarations
output sum, c_out;
input a, b, c_in;

// Internal nets
wire s1, c1, c2;

// Instantiate logic gate primatives
xor (s1, a, b);
and (c1, a, b);

xor (sum, s1, c_in);
and (c2, s1, c_in);

or (c_out, c2, c_in);

endmodule

// Define a 8-bit binary adder
module fulladd8(sum, c_out, a, b, c_in);

// I/O port declarations
output [7:0] sum;
output c_out;
input [7:0] a, b;
input c_in;

// Internal nets
wire c1, c2, c3,c4,c5,c6,c7;

// Instantiate four 1-bit full adders
fulladd fa0(sum[0], c1, a[0], b[0], c_in);
fulladd fa1(sum[1], c2, a[1], b[1], c1);
fulladd fa2(sum[2], c3, a[2], b[2], c2);
fulladd fa3(sum[3], c4, a[3], b[3], c3);
fulladd fa4(sum[4], c5, a[4], b[4], c4);
fulladd fa5(sum[5], c6, a[5], b[5], c5);
fulladd fa6(sum[6], c7, a[6], b[6], c6);
fulladd fa7(sum[7], c_out, a[7], b[7], c7);
endmodule
 

i think code of "c_out" can write ao follow:
and(t1 , a , b);
and(t2 , a , c_in);
and(t3 , b , c_in);
or(c_out , t1, t2, t3);
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top