blocking assignment in always_comb

Status
Not open for further replies.

stanford

Full Member level 2
Joined
Feb 16, 2014
Messages
132
Helped
4
Reputation
8
Reaction score
6
Trophy points
1,298
Activity points
2,223
1. Are these two code functionally equivalent?

2. Will they synthesize into the same hardware?

Code:
always_comb
  out = 0;
  out = (sel[0]) ? in[0] : out;
  out = (sel[1]) ? in[1] : out;

Code:
assign out = sel[1] ? in[1] : sel[0] ? in[0] : 0;
 

What do you expect?


Most likely, if 1 is true.

Code 1 involves a syntax error.

Are you referring to missing begin/end? I was wondering if they are actually functionally equivalent. I wasn't sure.
 

Assuming the missing begin/end was a typo, they are functionally equivalent and should synthesize to the same hardware. The only difference is in simulation debugging, you'll be able to see the intermediate assignments if you step through the code.
 

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