Convert a combinational always block into assignments.
Basic examples of what we're trying to do here:
always @(*) ----> assign lhs = condition1 ? {expr1} if (condition1) : condition2 ? {expr2} lhs = expr1; : {expr3} else if (condition2) lhs = expr2; else lhs = expr3; always @(*) ----> assign lhs = condition ? {expr2} : {expr1} lhs = expr1; if (condition) lhs = expr2;
Note that this conversion isn't quite right if the widths of the
To avoid this, we locally use the stmttemps transform before trying
to carry out this expression building. This should ensure that all lhses/rhses
are well-typed and have compatible widths. The excessive use of concatenations
above ensures that everything is unsigned, to avoid creating badly typed
Slight twist. If we know that this is supposed to be a combinational always
block because it's written with
To drive the variable to Xes, a simple thing to do is, e.g.,
always_comb ---> always_comb if (condition) lhs = XXXX lhs = expr; if (condition) if (condition2) lhs = expr; lhs = expr2; if (condition2) lhs = expr2;
This is safe even if all the branches are covered (in which case we're simply setting the variable to X and then to its real value).