1-to-4 Demultiplexer (Using with-select-when Statement)
The demultiplexer is a combinational logic circuit designed to switch one input line to one of several separate output lines. It is exactly opposite of Multiplexer. In 1-to-4 Demux the input line is connected to one of the 4 output lines depending on the select line input. The below VHDL code is written using with-select-when  statement. VHDL Code: library IEEE; use IEEE.STD_LOGIC_1164.ALL; entity demux is     Port ( Din : in  STD_LOGIC;            Dout : out  STD_LOGIC_VECTOR (3 downto 0);            Sel : in  STD_LOGIC_VECTOR (1 downto 0)); end demux; architecture Behavioral of demux is begin 	 with sel select 	 Dout 	 <= "000"&Din when "00", 				 "00"&Din&'0' when "01", 				 '0'&Din&"00" when "10", 				 Din&"000" when "11", 				 "XXXX" when others; end Behavioral; Testbench: LIBRARY ieee; USE ieee.std_logic_1164.ALL;   ENTITY Demux_tb IS END Demux_tb; ...