K
Ken Cecka
Hi All,
I was trying to get something similar to the following to compile today without success:
ENTITY ent IS
GENERIC
(
bits : INTEGER := 4;
val : STD_LOGIC_VECTOR((bits - 1) DOWNTO 0) := (OTHERS => '0')
);
PORT
(
reset : IN STD_LOGIC;
clk : IN STD_LOGIC;
din : IN STD_LOGIC_VECTOR((bits - 1) DOWNTO 0);
dout : OUT STD_LOGIC_VECTOR((bits - 1) DOWNTO 0)
);
END ent;
The compilers don't seem to like me using 'bits' in the type for val (probably because bits is not considered defined while inside the GENERIC block?).
I can remove the dimensions on val, but then I can't default it to all 0s with (OTHERS => '0').
Is there any way to achieve what I'm trying to do here? I want a component with a generic bus width that also takes a generic constant which is required to match that bus width and defaults to all 0s.
I've considered passing the constant in as an integer and then using CONV_STD_LOGIC_VECTOR internally, but as I understand it, integers have a fixed width of 32 in the compiler, so the entity would not scale to designs with (bits > 32).
Thanks,
Ken
I was trying to get something similar to the following to compile today without success:
ENTITY ent IS
GENERIC
(
bits : INTEGER := 4;
val : STD_LOGIC_VECTOR((bits - 1) DOWNTO 0) := (OTHERS => '0')
);
PORT
(
reset : IN STD_LOGIC;
clk : IN STD_LOGIC;
din : IN STD_LOGIC_VECTOR((bits - 1) DOWNTO 0);
dout : OUT STD_LOGIC_VECTOR((bits - 1) DOWNTO 0)
);
END ent;
The compilers don't seem to like me using 'bits' in the type for val (probably because bits is not considered defined while inside the GENERIC block?).
I can remove the dimensions on val, but then I can't default it to all 0s with (OTHERS => '0').
Is there any way to achieve what I'm trying to do here? I want a component with a generic bus width that also takes a generic constant which is required to match that bus width and defaults to all 0s.
I've considered passing the constant in as an integer and then using CONV_STD_LOGIC_VECTOR internally, but as I understand it, integers have a fixed width of 32 in the compiler, so the entity would not scale to designs with (bits > 32).
Thanks,
Ken