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.

how the signals will be displayed for this rtl

Status
Not open for further replies.

sun_ray

Advanced Member level 3
Joined
Oct 3, 2011
Messages
772
Helped
5
Reputation
10
Reaction score
5
Trophy points
1,298
Activity points
6,828
How will the $display will display the values of the signals for the following code?

always @ (p,q,r,s)
p=q;
p<=r;
p=s;
 

are you posting these questions from your interview, while you are interviewing?

Run it in a simulator and see for yourself.

Or here look at the code closely, when formatted to show the LRM rules:

Code Verilog - [expand]
1
2
3
4
always @ (p,q,r,s) p=q; // p, r, and s cause the always block to be scheduled even when there is nothing to do.
 
p<=r;
p=s;



Of course you probably meant to write this, but how would I know as I can only go by what you wrote in the first place.

Code Verilog - [expand]
1
2
3
4
5
always @ (q,r,s) begin
  p = q;
  p <= r;
  p = s;
end


Non-blocking assignments get scheduled at the end of the block so the blocking assignments are scheduled in the order they appear and are then overwritten by the scheduled non-blocking assignment at the end of the always.

Note: the p has been removed from the always sensitivity list, I tried to verify my initial conclusion of which value would show up on p in a simulator and it had an iteration limit exceeded due to the p being in the sensitivity list. This is why you've been told previously to use @* (introduced in 2001 and supported by every tool I've used) instead of calling out all the variables read (i.e. not assigned outputs that are never read) individually in the sensitivity list.
 

Non-blocking assignments get scheduled at the end of the block so the blocking assignments are scheduled in the order they appear and are then overwritten by the scheduled non-blocking assignment at the end of the always.

Where in LRM it is stated that Non-blocking assignments get scheduled at the end of the block?

Do you want to mean that here although in the code p<=r precedes p=s; the last assignment out of the three will be p<=r?

Is it you want to mean that p will get the value of r only and not the values of q and s?
 

Where in LRM it is stated that Non-blocking assignments get scheduled at the end of the block?
In the event scheduling section referred to as NBA.

sun_ray said:
Do you want to mean that here although in the code p<=r precedes p=s; the last assignment out of the three will be p<=r?

Is it you want to mean that p will get the value of r only and not the values of q and s?
yes
 

Where is the $display?

The LRM is very clear about multiple NBA's to the same variable, the last one wins, but does not mention the interaction between an NBA followed by a blocking assignment. It suspect it is not syntehsizable.
 

Where is the $display?

The LRM is very clear about multiple NBA's to the same variable, the last one wins, but does not mention the interaction between an NBA followed by a blocking assignment. It suspect it is not syntehsizable.

Well of course it isn't probably not synthesizable...it looks like an interview question to see if the interviewee knows the difference between blocking and non-blocking behavior (this is a really bad question for checking that knowledge).

But reading the LRM indicates that blocking assignments are scheduled before NBAs, but it's not an easy to understand part of the LRM as it's has multiple NBA scheduling points that are related to weather or not you have # delays in the assignments. I've read that portion many times, but ended up finding a paper that explained Verilog's event scheduler in human understandable terms (if I recall correctly it was described in a flowchart).
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top