¿Qué función quieres darle a la señal Sel
?
Si este es un módulo de nivel superior, puede usar el paquete y calcular sus constantes de la siguiente manera:
library ieee;
use ieee.std_logic_1164.all;
use ieee.math_real.all;
package dmux_const_pkg is
constant IWIDTH : integer:= 3; -- for example
constant SWIDTH ; integer:= 0;
constant OWIDTH : integer:= 2**IWIDTH; -- 2^3
end package_name;
e inclúyalo a su módulo superior como: use work.dmux_const_pkg.all;
y en la declaración del módulo puede usar las constantes:
entity DEMUX is
-- Map input, output, selection and enable signal ports
port(
Inp : in std_logic_vector(IWIDTH-1 downto 0); -- Input pin
Ena : in std_logic; -- Enable pin
Sel : in std_logic_vector(SWIDTH-1 dwonto 0);--How to set select lines?
Oup : out std_logic_vector(OWIDTH-1 downto 0)--How to set outputs?
);
end MUX;
Si este no es un módulo superior, puede declarar todos los anchos en genérico y calcularlo en este módulo:
entity DEMUX is
-- Get the size of an integer
generic(
IWIDTH : integer;
SWIDTH : integer;
OWIDTH : integer
);
-- Map input, output, selection and enable signal ports
port(
Inp : in std_logic_vector(IWIDTH-1 downto 0); -- Input pin
Ena : in std_logic; -- Enable pin
Sel : in std_logic_vector(SWIDTH-1 dwonto 0);--How to set select lines?
Oup : out std_logic_vector(OWIDTH-1 downto 0)--How to set outputs?
);
end MUX;
Módulo de nivel superior:
entity top_level_module(
...);
end top_level_module;
architecture arch of top_level_module is
constant DMUX_IWIDTH : integer := 1;
constant DMUX_SWIDTH : integer := 0;
constant DMUX_OWIDTH : integer := 2**DMUX_IWIDTH;
component DEMUX is
generic(
IWIDTH : integer;
SWIDTH : integer;
OWIDTH : integer
);
-- Map input, output, selection and enable signal ports
port(
Inp : in std_logic_vector(IWIDTH-1 downto 0); -- Input pin
Ena : in std_logic; -- Enable pin
Sel : in std_logic_vector(SWIDTH-1 dwonto 0);--How to set select lines?
Oup : out std_logic_vector(OWIDTH-1 downto 0)--How to set outputs?
);
end component DEMUX;
begin
DMUX: DEMUX
generic map(
IWIDTH => DMUX_IWIDTH,
SWIDTH => DMUX_SWIDTH,
OWIDTH => DMUX_OWIDTH
) port map (
...
);
...
end arch;