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.

Pre and Post Increment in System Verilog

Status
Not open for further replies.

sunidrak

Full Member level 1
Full Member level 1
Joined
Apr 12, 2012
Messages
97
Helped
2
Reputation
4
Reaction score
2
Trophy points
1,288
Location
Bengaluru, India
Visit site
Activity points
1,738
hi

Can any body please explain
Pre and post Incrment in system verilog and reason for this output



module increment;
integer i=3,z;
initial
begin
z=i++/i;
$display("i=%d,z=%d "i,z);
end
endmodule

Output
# i=4
# z=0


Regards
SUNIL
 

The numerator of your expression i++/i is definitely 3, but the denominator could be 3 or 4. And 3/4 as an integer is 0.

The LRM explains this quite well. See section 11.4.2 Increment and decrement operators.

Don't have a copy of the LRM?, get a free copy.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top