Example of if-else Statement - 2022.1 English

Vivado Design Suite User Guide: Synthesis (UG901)

Document ID
UG901
Release Date
2022-06-06
Version
2022.1 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;