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.

[SOLVED] adder output is always at high impedance state

Status
Not open for further replies.

rakeshk.r

Member level 2
Joined
Nov 12, 2013
Messages
47
Helped
1
Reputation
2
Reaction score
1
Trophy points
8
Activity points
421
I have written a gate level code for adder in verilog. The output the adder is shown below. As you can see the sum and cout are always in z. I don't know why. Could you check what am i missing ? Thanks for your time.
# a = x, b = x, cin = x, summ = z, cout = z at time = 0
# a = 0, b = 0, cin = 0, summ = z, cout = z at time = 10
# a = 0, b = 1, cin = 0, summ = z, cout = z at time = 20
# a = 1, b = 0, cin = 0, summ = z, cout = z at time = 30
# a = 1, b = 1, cin = 0, summ = z, cout = z at time = 40
# a = 0, b = 0, cin = 1, summ = z, cout = z at time = 50
# a = 0, b = 1, cin = 1, summ = z, cout = z at time = 60
# a = 1, b = 0, cin = 1, summ = z, cout = z at time = 70
# a = 1, b = 1, cin = 1, summ = z, cout = z at time = 80
Code:
module tb();  

reg a, b, cin; 
wire cout, summ;

FA_gatelevel gatelevel(.a(a), .b(b), .cin(cin), .summ(summ), .cout(cout)); 

initial begin  

	#10 a = 0; b = 0; cin = 0; 
	#10 a = 0; b = 1; cin = 0;
	#10 a = 1; b = 0; cin = 0;
	#10 a = 1; b = 1; cin = 0;
	#10 a = 0; b = 0; cin = 1;
	#10 a = 0; b = 1; cin = 1;
	#10 a = 1; b = 0; cin = 1;
	#10 a = 1; b = 1; cin = 1;

end

initial begin

	$monitor("a = %0h, b = %0h, cin = %0h, summ = %0h, cout = %0h at time = %0t",a,b,cin,summ,cout,$time);	// gate level

			
	#200 $finish;
end 


endmodule

Code:
module FA_gatelevel(a, b, cin, summ, cout);


input a,b,cin;
output summ,cout;

FA_co ins_co(.a(a), .b(b), .cin(cin), .cout(cout));
FA_sum ins_sum(.a(a), .b(b), .cin(cin), .summ(summ));

endmodule

Code:
module FA_co (a, b, cin, cout);

input a, b, cin;
output cout;
wire ab, bc, ca;

and g0 (a,b,ab);
and g1 (b,c,bc);
and g2 (c,a,ca);
or  g3 (ab,bc,ca,cout);

// equation: cout = (a.b) + (b.c) + (c.a)

endmodule

Code:
module FA_sum(a, b, cin, summ);

input a, b, cin;
output  summ;

xor g0 (a,b,cin,summ);
	

endmodule
 

Hi
your have mistake in using primitives such as and , xor , ...

for example you have written
Code:
xor g0 (a,b,cin,summ);
its not correct, this is the correct
Code:
xor g0 (summ,a,b,cin);

output node comes first in primitives !
 
output node comes first in primitives
Even if this is the case for certain libraries, you shouldn't rely on it. There's no general language rule suggesting a specific order.

I think, if you use lazy ordered parameter assignment instead of unequivocal named assignment, you deserve the trouble.
 

I think, if you use lazy ordered parameter assignment instead of unequivocal named assignment, you deserve the trouble.
what does unequivocal named assignment mean? can you give an example.
 

Even if this is the case for certain libraries, you shouldn't rely on it. There's no general language rule suggesting a specific order.

I think, if you use lazy ordered parameter assignment instead of unequivocal named assignment, you deserve the trouble.

this is not a library, this is a primitive. as far as I know, you can't do name assigned instantiation.
 

this is not a library, this is a primitive. as far as I know, you can't do name assigned instantiation.

This is correct, Verilog gate primitives have no port names and the output is always the first connection.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top