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.

plz anyone correct this coding

Status
Not open for further replies.

renoz

Member level 3
Joined
Aug 27, 2011
Messages
54
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,587
hi

anyone correct this below verilog coding,it is 4 bit carrt select adder which contains 3 module
ripple carry adder
binary excess one conveter
mux(6:3)
i had error in last part which calling the modules





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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
module fulladder(a, b, c_in, sum, c_out);
input a;
input b;
input c_in;
output sum;
output c_out;
wire x,y,z;
xor (x,a,b);
xor(sum,x,c_in);
and(y,a,b);
and (z,x,c_in);
or (c_out,z,y);
endmodule
 
 
module fourbitadder(a, b, c_in, sum, c1);
input [1:0] a;
input [1:0] b;
input c_in;
output [1:0] sum;
output c1;
wire c0;
fulladder fa0(a[0],b[0],c_in,sum[0],c0);
fulladder fa1(a[1],b[1],c0,sum[1],c1);
endmodule
 
 
 
// another    2 bit ripple carry adder
module fourbitadder1(a, b, c_in, sum, c3);
input [3:2] a;
input [3:2] b;
input c_in;
output [3:2] sum;
output c3;
wire c2;
assign c_in=0;
fulladder fa0(a[2],b[2],c_in,sum[2],c2);
fulladder fa1(a[3],b[3],c2,sum[3],c3);
endmodule
 
module BCD2Excess1 (X, B);
output [2:0] X; //declare output ports
input [2:0]B; //declare input ports
wire [2:0] X;
 //watch the changes of inputs
 //form the output signals in
//terms of input signals
assign X[0] = ~B[0];
assign X[1] = (B[0] & B[1]) ;
assign X[2]= (B[2] ^ (B[0] & B[1])) ;
endmodule
 
//
// 6:3 MUX
//
module mux(X,bin,out);
input X;
input bin;
output out;
wire [2:3]sum;
wire c3;
assign bin[0]=sum[2];
assign bin[1]=sum[3];
assign bin[2]=c3;
wire [2:0] X;   // input a
wire [2:0] bin;   // input b
wire [2:0] out; // output (obviously)
wire       c1; // selection thingy
assign out = c1 ? X : bin;
endmodule
 
module csa(A,B,cin,sumout,cout);
input [3:0]A;
input [3:0]B;
input cin;
output [3:0]sumout;
output cout;
wire [3:0]a;
wire [3:0]b;
wire c_in;
wire c_out;
wire [2:0]X;
wire [2:0]B;
wire bin;
wire out;
 
fulladder m1(a, b, c_in, sum, c_out);
fourbitadder m2(a, b, c_in, sum, c1);
fourbitadder1 m3(a, b, c_in, sum, c3);
BCD2Excess1 m4(X, B);
mux m5(X,bin,out);
 
assign sumout[2]=out[0];
assign sumout[3]=out[1];
assign cout=out[2];
endmodule

 
Last edited by a moderator:

Kind of easy. In the module csa, you have declared "out" as a single bit, but trying to access out[0], out[1] e.t.c. Kindly look into that! I suggest you run the code in modelsim or any other simulator for quicker debugs.

Sudhir
WorldServe Education
www.worldserve.in
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top