Example of if-else Statement - Example of if-else Statement - 2022.2 English - UG901

Vivado Design Suite User Guide: Synthesis (UG901)

Document ID
UG901
Release Date
2022-11-16
Version
2022.2 English

This coding example uses an if-else statement to describe a Multiplexer.

module mux4 (sel, a, b, c, d, outmux);

input [1:0] sel;

input [1:0] a, b, c, d;

output [1:0] outmux;

reg [1:0] outmux;

always @(sel or a or b or c or d)

begin

if (sel[1])

if (sel[0])

outmux = d;

else

else

outmux = c;

if (sel[0])

outmux = b;

end endmodule

else

outmux = a;