I am a newbie with Verilog. While doing a lab assignment (yes, I’ve read the homework policy here), I came across a conditional statement (ternary operator).
assign w1 = load ? in : out;
I understand that assign updates whenever anything on the right changes. In this case, does assign update w1 whenever load
, in
, or out
change? Or does assign update only when load
changes?
The lab assignment is for implementing a register. This question doesn’t directly relate to register implementation so I feel safe to ask for clarification here. All the documentation I’ve found on assign
suggests that it updates whenever any operand on the right hand side changes. How does this apply with ternary operator?
Logically, the statement is equivalent to two “or-ed” “and” gates, correct ((load and in) or (~load and out))?
Thanks.
I expect assign will update only when load
changes. The situation in which I’m using the statement is kinda confusing to isolate which behavior is used so I’m curious to learn from someone who knows more.
I’m also interested in understanding the logic equivalent.