Example of if-else Statement (VHDL) - 2022.1 English

Vivado Design Suite User Guide: Synthesis (UG901)

Document ID
UG901
Release Date
2022-06-06
Version
2022.1 English

library IEEE;

use IEEE.std_logic_1164.all;

 

entity mux4 is port (

   a, b, c, d : in std_logic_vector (7 downto 0);

   sel1, sel2 : in std_logic;

   outmux : out std_logic_vector (7 downto 0));

end mux4;

 

architecture behavior of mux4 is begin

   process (a, b, c, d, sel1, sel2)

      begin

      if (sel1 = '1') then

      if (sel2 = '1') then

      outmux <= a;

 

   else outmux <= b;

      else

   end if;

      if (sel2 = '1') then outmux <= c;

         else

      outmux <= d;

   end if;

end if;

   end process;

end behavior;