11.2.3.2.2 12:1 Multiplexor

The following examples infer a 12:1 multiplexor using a case statement.

VHDL
-- 12:1 mux
library ieee;
use ieee.std_logic_1164.all;
-- Entity declaration:
entity mux12_1 is
port
(
mux_sel: in std_logic_vector (3 downto 0);-- mux select
A: in std_logic;
B: in std_logic;
C: in std_logic;
D: in std_logic;
E: in std_logic;
F: in std_logic;
G: in std_logic;
H: in std_logic;
I: in std_logic;
J: in std_logic;
K: in std_logic;
M: in std_logic;
mux_out: out std_logic -- mux output
);
end mux12_1;
-- Architectural body:
architecture synth of mux12_1 is
begin
proc1: process (mux_sel, A, B, C, D, E, F, G, H, I, J, K, M)
begin
case mux_sel is
when "0000" => mux_out<= A;
when "0001" => mux_out <= B;
when "0010" => mux_out <= C;
when "0011” => mux_out <= D;
when "0100" => mux_out <= E;
when "0101" => mux_out <= F;
when "0110" => mux_out <= G;
when "0111" => mux_out <= H;
when "1000" => mux_out <= I;
when "1001" => mux_out <= J;
when "1010" => mux_out <= K;
when "1011" => mux_out <= M;
when others => mux_out<= '0';
end case;
end process proc1;
end synth;
Verilog
// 12:1 mux
module mux12_1(mux_out,
mux_sel,M,L,K,J,H,G,F,E,D,C,B,A
);
output mux_out;
input [3:0] mux_sel;
input M;
input L;
input K;
input J;
input H;
input G;
input F;
input E;
input D;
input C;
input B;
input A;
reg mux_out;
// create a 12:1 mux using a case statement
always @ ({mux_sel[3:0]} or M or L or K or J or H or G or F or E or D or C or B or A)
begin: mux_blk
case ({mux_sel[3:0]}) // synthesis full_case parallel_case
4'b0000 : mux_out = A;
4'b0001 : mux_out = B;
4'b0010 : mux_out = C;
4'b0011 : mux_out = D;
4'b0100 : mux_out = E;
4'b0101 : mux_out = F;
4'b0110 : mux_out = G;
4'b0111 : mux_out = H;
4'b1000 : mux_out = J;
4'b1001 : mux_out = K;
4'b1010 : mux_out = L;
4'b1011 : mux_out = M;
4'b1100 : mux_out = 1'b0;
4'b1101 : mux_out = 1'b0;
4'b1110 : mux_out = 1'b0;
4'b1111 : mux_out = 1'b0;
endcase
end
endmodule