Multiplexer Modeling
멀티플렉서 모델링
* Multiplexer (URL)
Dataflow Modeling with \(\texttt{with-select-when}\) Statement
-- Entity Body
ENTITY MUX_2x1 IS
PORT ( w0, w1 : IN bit;
s : IN bit;
f : OUT bit );
END MUX_2x1;
-- Architecture Body
ARCHITECTURE Dataflow_with_select OF MUX_2x1 IS
BEGIN
WITH s SELECT
f <= w0 WHEN '0',
w1 WHEN OTHERS;
END Dataflow_with_else;
-- Entity Body
ENTITY mux_4x1 IS
PORT ( w, x, y, z : IN bit;
mux_sel : IN bit;
mux_out : OUT bit );
END mux_4x1;
-- Architecture Body
ARCHITECTURE with_select_when_mux4x1 OF mux_4x1 IS
BEGIN
WITH mux_sel SELECT mux_out <= w WHEN "00",
x WHEN "01",
y WHEN "10",
z WHEN OTHERS;
END with_select_when_mux4x1;
Dataflow Modeling with \(\texttt{when-else}\) Statement
-- Entity Body
ENTITY MUX_2x1 IS
PORT ( w0, w1 : IN bit;
s : IN bit;
f : OUT bit );
END MUX_2x1;
-- Architecture Body
ARCHITECTURE Dataflow_when_else OF MUX_2x1 IS
BEGIN
f <= w0 WHEN (s = '0') ELSE
w1;
END Dataflow_when_else;
-- Entity Body
ENTITY mux_4x1 IS
PORT ( w, x, y, z : IN bit;
mux_sel : IN bit;
mux_out : OUT bit );
END mux_4x1;
-- Architecture Body
ARCHITECTURE when_else_mux4x1 OF mux_4x1 IS
BEGIN
mux_out <= w WHEN (mux_sel = "00") ELSE
x WHEN (mux_sel = "01") ELSE
y WHEN (mux_sel = "10") ELSE
z;
END when_else_mux4x1;
Behavioral Modeling with \(\texttt{if-else}\) Statement
-- Entity Body
ENTITY MUX_2x1 IS
PORT ( w0, w1 : IN bit;
s : IN bit;
f : OUT bit );
END MUX_2x1;
-- Architecture Body
ARCHITECTURE Behavioral_if_else OF MUX_2x1 IS
BEGIN
PROCESS(w0, w1, s)
if (s = '0') then f <= w0;
else f <= w1;
end if;
END PROCESS
END Behavioral_if_else;
-- Entity Body
ENTITY mux_4x1 IS
PORT ( w, x, y, z : IN bit;
mux_sel : IN bit;
mux_out : OUT bit );
END mux_4x1;
-- Architecture Body
ARCHITECTURE if_else_mux4x1 OF mux_4x1 IS
PROCESS (mux_sel, w, x, y, z)
BEGIN
IF (mux_sel = "00") THEN mux_out <= w;
ELSIF (mux_sel = "01") THEN mux_out <= x;
ELSIF (mux_sel = "10") THEN mux_out <= y;
ELSE mux_out <= z;
END IF;
END PROCESS;
END if_else_mux4x1;
Behavioral Modeling with \(\texttt{case-when}\) Statement
-- Entity Body
ENTITY MUX_2x1 IS
PORT ( w0, w1 : IN bit;
s : IN bit;
f : OUT bit );
END MUX_2x1;
-- Architecture Body
ARCHITECTURE case_when_mux4x1 OF MUX_2x1 IS
BEGIN
PROCESS(w0, w1, s)
BEGIN
CASE s IS
WHEN '0' => f <= w0;
WHEN OTHERS => f <= w1;
END CASE;
END PROCESS
END case_when_mux4x1;
-- Entity Body
ENTITY mux_4x1 IS
PORT ( w, x, y, z : IN bit;
mux_sel : IN bit;
mux_out : OUT bit );
END mux_4x1;
-- Architecture Body
ARCHITECTURE case_when_mux4x1 OF mux_4x1 IS
PROCESS (mux_sel, w, x, y, z)
BEGIN
CASE mux_sel IS
WHEN "00" => mux_out <= w;
WHEN "01" => mux_out <= x;
WHEN "10" => mux_out <= y;
WHEN OTHERS => mux_out <= z;
END CASE;
END PROCESS;
END case_when_mux4x1;
Configuration
CONFIGURATION CONF_A OF mux4x1 IS
FOR with_select_when_mux4x1
END FOR
END CONF_A;
CONFIGURATION CONF_B OF mux4x1 IS
FOR when_else_mux4x1
END FOR
END CONF_B;
CONFIGURATION CONF_C OF mux4x1 IS
FOR if_else_mux4x1
END FOR
END CONF_C;
CONFIGURATION CONF_D OF mux4x1 IS
FOR case_when_mux4x1
END FOR
END CONF_D;