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.

A basic question on Verilog simulation

Status
Not open for further replies.

eruisi

Member level 4
Joined
Jan 3, 2006
Messages
71
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
CA
Activity points
1,817
In IEEE standard 1364, it says the following code
Code:
module test;
wire p;
reg q;
 
assign p = q;
initial begin
        q = 1;
        #1 q = 0;
        $display("At time: %t, the value is %f\n", $realtime, p);
end
endmodule

could either display p as a "1" or "0". I can't understand why.
#1 q = 0 is a blocking assignment, the display should be executed after #1 q=0 is finished at time 1, right? I run the simulation in vcs and got 0 but in ncverilog got 1.

Could you tell me how this happens.

Thanks a lot!
 

semiconductorman

Full Member level 3
Joined
Dec 18, 2004
Messages
156
Helped
23
Reputation
46
Reaction score
4
Trophy points
1,298
Activity points
1,769
yes , " #1 q = 0; " is a blocking statement. But the value being printed out is p not q so here is the deal , when you do "assign p=q" it spons out as a spearate thread, or in verilog terms it is equivalent to writing always@ (q) p=q; Right ? When you do this , the print statement may be executed delta cycle before q is assigned to p or after q is assinged to p. That's why it is not predictable but if you do put a delay before print than this will work fine and always print the value of p after q is assigned to it. other way around if you put a delay in assigning q to p , print will always print value of p before q is assigned to it.
 

    eruisi

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top