Verilog Assignment with condition

Status
Not open for further replies.

beginner_EDA

Full Member level 4
Joined
Aug 14, 2013
Messages
191
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,296
Activity points
3,854

Code Verilog - [expand]
1
2
3
4
5
6
7
8
always @(posedge clk) begin
 
    x<=1'b1;     //  First Assignment
      if (y) begin    //some condition met
        x <= 1'b1;  // Second Assignment
      end
 
end



I would like to know in above code when also condition met which assignment will be executed although both assignments are same? First Assignment or Second Assignment?
 

It doesn't matter that both assigments are identical. Only the second assignment is used if the condition "y" is true.
 

If there is clear execution ordering of a set of nonblocking assignments, the order of the resulting updates to the LHS are preserved. So the second assignment overrides the first.

In synthesis, the conditional statement would be optimized away as it has no impact on the result.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…