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.

Need full verilog code for 16-bit adder with carry save

Status
Not open for further replies.

rsharitwal

Newbie level 2
Newbie level 2
Joined
Mar 22, 2009
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,294
verilog carry

please send me full verilog code for 16-bit adder with carry save.please send it as fast as you can.I need it very urgently.
 

verilog assign [3:0]

In fact, I have the code write 5,6 years ago by myself, I don't advocate one to get code from this way, if you understand the method of carry save, it's very simple. but I still offer to you this time


Code Verilog - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
module RCA4(A,B,Ci,So,Co);
input [3:0] A,B;
input Ci;
output [3:0] So;
output Co;
wire c1,c2,c3,c4;
wire g0,g1,g2,g3;
wire p0,p1,p2,p3;
 
 assign g0=A[0]&B[0];
 assign g1=A[1]&B[1];
 assign g2=A[2]&B[2];
 assign g3=A[3]&B[3];
 
 assign p0=A[0]|B[0];
 assign p1=A[1]|B[1];
 assign p2=A[2]|B[2];
 assign p3=A[3]|B[3];
 
 assign c1=g0|(p0&Ci);
 assign c2=g1|(p1&g0)|(p1&p0&Ci);
 assign c3=g2|(p2&g1)|(p2&p1&g0)|(p2&p1&p0&Ci);
 assign c4=g3|(p3&g2)|(p3&p2&g1)|(p3&p2&p1&g0)|(p3&p2&p1&p0&Ci);
 assign Co=c4;
       
 assign So[0]=g0^p0^Ci;
 assign So[1]=g1^p1^c1;
 assign So[2]=g2^p2^c2;
 assign So[3]=g3^p3^c3;
endmodule
 
 
module CSA8(A,B,Ci,So,Co);
input [7:0] A,B;
input Ci;
output [7:0] So;
output Co;
 
wire [3:0] stemp1,stemp0;
wire c4;
wire c80,c81;
 
RCA4 RCA4in(A[3:0],B[3:0],Ci,So[3:0],c4);
RCA4 RCA41 (A[7:4],B[7:4],1'b1,stemp1,c81);
RCA4 RCA40 (A[7:4],B[7:4],1'b0,stemp0,c80);
 
assign So[7:4] = c4?stemp1:stemp0;
assign Co=       c4?c81:c80;
 
endmodule
 
module CSA16(A,B,Ci,So,Co);
input [15:0] A,B;
input Ci;
output [15:0] So;
output Co;
 
wire [7:0] stemp1,stemp0;
wire c8;
wire c160,c161;
 
CSA8 CSA8in(A[7:0],B[7:0],Ci,So[7:0],c8 );
CSA8 CSA81 (A[15:8],B[15:8],1'b1,stemp1,c161);
CSA8 CSA80 (A[15:8],B[15:8],1'b0,stemp0,c160);
 
assign So[15:8] = c8?stemp1:stemp0;
assign Co=        c8?c161:c160;
 
endmodule

 
Last edited by a moderator:
Re: verilog code very urgent

thank you very much sir.actually I understood the logic behind it.I am doing a project that uses it. because i have very less time to submit it.i made my own code but I am getting a probelm with it.that's i was asking for helping.thank you again.
 

Re: verilog assign [3:0]

Hi I need some description about this code
Can u narrate this code Please

I have this assignment of full adder and to submit very shortly hardly in three days

I cannot be able to write the correct code for it
I have found ur code and i think if u give some description it would be easy to understand some key features

Thank you
And take care

In fact, I have the code write 5,6 years ago by myself, I don't advocate one to get code from this way, if you understand the method of carry save, it's very simple. but I still offer to you this time

module RCA4(A,B,Ci,So,Co);
input [3:0] A,B;
input Ci;
output [3:0] So;
output Co;
wire c1,c2,c3,c4;
wire g0,g1,g2,g3;
wire p0,p1,p2,p3;

assign g0=A[0]&B[0];
assign g1=A[1]&B[1];
assign g2=A[2]&B[2];
assign g3=A[3]&B[3];

assign p0=A[0]|B[0];
assign p1=A[1]|B[1];
assign p2=A[2]|B[2];
assign p3=A[3]|B[3];

assign c1=g0|(p0&Ci);
assign c2=g1|(p1&g0)|(p1&p0&Ci);
assign c3=g2|(p2&g1)|(p2&p1&g0)|(p2&p1&p0&Ci);
assign c4=g3|(p3&g2)|(p3&p2&g1)|(p3&p2&p1&g0)|(p3&p2&p1&p0&Ci);
assign Co=c4;

assign So[0]=g0^p0^Ci;
assign So[1]=g1^p1^c1;
assign So[2]=g2^p2^c2;
assign So[3]=g3^p3^c3;
endmodule


module CSA8(A,B,Ci,So,Co);
input [7:0] A,B;
input Ci;
output [7:0] So;
output Co;

wire [3:0] stemp1,stemp0;
wire c4;
wire c80,c81;

RCA4 RCA4in(A[3:0],B[3:0],Ci,So[3:0],c4);
RCA4 RCA41 (A[7:4],B[7:4],1'b1,stemp1,c81);
RCA4 RCA40 (A[7:4],B[7:4],1'b0,stemp0,c80);

assign So[7:4] = c4?stemp1:stemp0;
assign Co= c4?c81:c80;

endmodule

module CSA16(A,B,Ci,So,Co);
input [15:0] A,B;
input Ci;
output [15:0] So;
output Co;

wire [7:0] stemp1,stemp0;
wire c8;
wire c160,c161;

CSA8 CSA8in(A[7:0],B[7:0],Ci,So[7:0],c8 );
CSA8 CSA81 (A[15:8],B[15:8],1'b1,stemp1,c161);
CSA8 CSA80 (A[15:8],B[15:8],1'b0,stemp0,c160);

assign So[15:8] = c8?stemp1:stemp0;
assign Co= c8?c161:c160;

endmodule
 

Re: verilog carry

please send me full verilog code for 16-bit adder with carry save.please send it as fast as you can.I need it very urgently.
this is the code for the .. 16 bit carry propagate adder circuit.



Code Verilog - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
module cla(sum,c0,a,b,ci);
input [7:0]a,b;
input ci;
output[7:0]sum;
output c0;
wire p0,p1,p2,p3,p4,p5,p6,p7,g0,g1,g2,g3,g4,g5,g6,g7;
wire c1,c2,c3,c4,c5,c6,c7,c8;
assign 
p0=a[0]^b[0],
p1=a[1]^b[1],
p2=a[2]^b[2],
p3=a[3]^b[3],
p4=a[4]^b[4],
p5=a[5]^b[5],
p6=a[6]^b[6],
p7=a[7]^b[7],
g0=a[0]&b[0],
g1=a[1]&b[1],
g2=a[2]&b[2],
g3=a[3]&b[3],
g4=a[4]&b[4],
g5=a[5]&b[5],
g6=a[6]&b[6],
g7=a[7]&b[7];
assign
c1=g0|(p0&ci),
c2=g1|(p1&g0)|(p1&p0&ci),
c3=g2|(p2&g1)|(p2&p1&g0)|(p2&p1&p0&ci),
c4=g3|(p3&g2)|(p3&p2&g1)|(p3&p2&p1&g0)|(p3&p2&p1&p0&ci),
c5=g4|(p4&g3)|(p4&p3&g2)|(p4&p3&p2&g1)|(p4&p3&p2&p1&g0)|(p4&p3&p2&p1&p0&ci),
c6=g5|(p5&g4)|(p5&p4&g3)|(p5&p4&p3&g2)|(p5&p4&p3&p2&g1)|(p5&p4&p3&p2&p1&g0)|(p5&p4&p3&p2&p1&p0&ci) ,
c7=g6|(p6&g5)|(p6&p5&g4)|(p6&p5&p4&g3)|(p6&p5&p4&p3&g2)|(p6&p5&p4&p3&p2&g1)|(p6&p5&p4&p3&p2&p1&g0)|( p6&p5&p4&p3&p2&p1&p0&ci),
c8=g7|(p7&g6)|(p7&p6&g5)|(p7&p6&p5&g4)|(p7&p6&p5&p4&g3)|(p7&p6&p5&p4&p3&g2)|(p7&p6&p5&p4&p3&p2&g1)|( p7&p6&p5&p4&p3&p2&p1&g0)|(p7&p6&p5&p4&p3&p2&p1&p0& ci);
assign
sum[0]=p0^ci,
sum[1]=p1^c1,
sum[2]=p2^c2,
sum[3]=p3^c3,
sum[4]=p4^c4,
sum[5]=p5^c5,
sum[6]=p6^c6,
sum[7]=p7^c7,
c0=c8;
endmodule
 
 
// FOR THE TEST BENCH
 
module testbench();
  
  wire [7:0]sum;
  wire c0;
  reg ci;
  reg [7:0]a,b;
  cla g1 (sum,c0,a,b,ci);
  initial
  begin
  ci = 1'b0;
  a = 8'b10101011;
  b = 8'b11010101;
end
endmodule

 
Last edited by a moderator:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top