muxing¶
Dependencies¶
common_2008 (for muxing_2008)
Description¶
A set of routines for creating parameterized multiplexers, decoders,
and demultiplexers. The VHDL-2008 version has an additional mux()
function that can select from multi-bit inputs implemented in
VHDL-2008 syntax.
Example usage¶
signal sel : unsigned(3 downto 0);
signal d, data : std_ulogic_vector(0 to 2**sel'length-1);
signal d2 : std_ulogic_vector(0 to 10);
signal m : std_ulogic;
...
d <= decode(sel); -- Full binary decode
d2 <= decode(sel, d2'length); -- Partial decode
m <= mux(data, sel); -- Mux with internal decoder
m <= mux(data, d); -- Mux with external decoder
d2 <= demux(m, sel, d2'length);
Muxing vectors with VHDL-2008:
library extras_2008;
use extras_2008.muxing.all;
use extras_2008.common.sulv_array;
signal sel : unsigned(3 downto 0);
signal m : std_ulogic_vector(7 downto 0);
signal data : sulv_array(0 to 2**sel'length-1)(m'range);
...
m <= mux(data, sel);
Subprograms¶
-
muxing.
decode
(Sel : unsigned) → std_ulogic_vector¶ - Decoder with variable sized output (power of 2).
Parameters: - Sel (unsigned) – Numeric value to decode (range 0 to 2**Sel’length-1)
Returns: Decoded (one-hot) representation of Sel.
-
muxing.
decode
(Sel : unsigned; Size : positive) → std_ulogic_vector¶ - Decoder with variable sized output (user specified).
Parameters: - Sel (unsigned) – Numeric value to decode (range 0 to Size-1)
- Size (positive) – Number of bits in result (leftmost bits)
Returns: Decoded (one-hot) representation of Sel.
-
muxing.
mux
(Inputs : std_ulogic_vector; Sel : unsigned) → std_ulogic¶ - Multiplexer with variable sized inputs.
Parameters: - Inputs (std_ulogic_vector) – Inputs to select from
- Sel (unsigned) – Input to select
Returns: Selected input.
-
muxing.
mux
(Inputs : std_ulogic_vector; One_hot_sel : std_ulogic_vector) → std_ulogic¶ - Multiplexer with variable sized inputs using external decoder.
Parameters: - Inputs (std_ulogic_vector) – Inputs to select from
- One_hot_sel (std_ulogic_vector) – Input to select (generated by decode())
Returns: Selected input.
-
muxing.
demux
(Input : std_ulogic; Sel : unsigned; Size : positive) → std_ulogic_vector¶ - Demultiplexer with variable sized inputs.
Parameters: - Input (std_ulogic) – Bit to demultiplex
- Sel (unsigned) – Position of Bit in result
- Size (positive) – Length of the result
Returns: Vector with selected bit connected to the Input.
VHDL-2008 variant¶
Subprograms¶
-
muxing.
decode
(Sel : unsigned) → std_ulogic_vector¶ - Decoder with variable sized output (power of 2).
Parameters: - Sel (unsigned) – Numeric value to decode (range 0 to 2**Sel’length-1)
Returns: Decoded (one-hot) representation of Sel.
-
muxing.
decode
(Sel : unsigned; Size : positive) → std_ulogic_vector¶ - Decoder with variable sized output (user specified).
Parameters: - Sel (unsigned) – Numeric value to decode (range 0 to Size-1)
- Size (positive) – Number of bits in result (leftmost bits)
Returns: Decoded (one-hot) representation of Sel.
-
muxing.
mux
(Inputs : std_ulogic_vector; Sel : unsigned) → std_ulogic¶ - Multiplexer with variable sized inputs.
Parameters: - Inputs (std_ulogic_vector) – Inputs to select from
- Sel (unsigned) – Input to select
Returns: Selected input.
-
muxing.
mux
(Inputs : std_ulogic_vector; One_hot_sel : std_ulogic_vector) → std_ulogic¶ - Multiplexer with variable sized inputs using external decoder.
Parameters: - Inputs (std_ulogic_vector) – Inputs to select from
- One_hot_sel (std_ulogic_vector) – Input to select (generated by decode())
Returns: Selected input.
-
muxing.
demux
(Input : std_ulogic; Sel : unsigned; Size : positive) → std_ulogic_vector¶ - Demultiplexer with variable sized inputs.
Parameters: - Input (std_ulogic) – Bit to demultiplex
- Sel (unsigned) – Position of Bit in result
- Size (positive) – Length of the result
Returns: Vector with selected bit connected to the Input.
-
muxing.
mux
(Inputs : sulv_array; Sel : unsigned) → std_ulogic_vector¶ - Multiplexer with variable sized, multi-bit inputs.
Parameters: - Inputs (sulv_array) – Inputs to select from
- Sel (unsigned) – Input to select
Returns: Selected input.