← ProblemsVerilog Language / Procedures
If statement
64%proceduresconditionalsmuxAn if statement inside a combinational always block is just another way to describe a multiplexer.
Build a 2-to-1 mux that outputs b when both sel_b1 and sel_b2 are 1, and outputs a otherwise. Implement it twice:
out_assign: using anassignwith the conditional (ternary) operatorout_always: using anif/elseinside analways @(*)block
Both outputs implement the exact same function.