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.

Non-blocking assignment in always@(*) block

Status
Not open for further replies.

KQWD

Newbie level 2
Newbie level 2
Joined
Sep 10, 2013
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Visit site
Activity points
22
Hi,

I've always coded using blocking assignment in always@(*) to specify combo logic. However, I am going through a design where non-blocking assignment is always used in always@(*) blocks. Is there a reason to do this? Maybe to be more succinct in the code, and declare less intermediate signals?

Thanks :smile:
 


Thanks for the reply - I see why the example you gave is wrong. I guess I have a new question - the signals in the always@(*) block are declared as reg, and wires are assigned , for example;

input wire input_value;

reg example1_new;
reg example1_current;
reg example2_new;
reg example2_current;
wire example3;

always@(posedge clk) begin
example1_current <= example1_new;
example2_current <= example2_new;
end

assign example3 = input_value;

always@(*) begin
example1_new <= 0;
example2_new <= 0;
if (example3) begin
example1_new <= 1;
example2_new <= 1;
end
end

So are example1_new and example2_new combinatorial logic? It seems like no, since they are reg, but I am still confused by assigning it in a always@(*) block. It's like we are registering values and doing the combinatorial logic at the same time, since the last non-blocking statement is used (example1_new will be 1 if input_value is 1).

Thanks again!
 

reg in verilog always confuse to beginner, as reg implies to us as sequential element and wire implies for combinational element.

following points are needed to understand-
1. any output whether it is intermediate output or output must be declared as reg iff it is described inside always block
2. Always block can infer Combinational hardware, iff it is output completely defined within always, for example, incomplete if leads to a latch (which is sequential element and latches are level triggered)

3. Flipflop are always EDGE Triggered, thus signal attribute such as posedge or negedge leads to flipflop inference.
 

In the present example (in post #3), there's no effect of using non-blocking versus blocking assignments. Nevertheless you should follow the known coding rules (e.g. discussed in the Sunburst paper linked in post #2), because it might matter in other cases.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top