wturri
Newbie level 4
Hello,
We have a 2D window filter implemented that we'd like to make more reusable. Presently we use a 7x7 kernel, and we assign the coefficient values to individually-named constants, which are then assigned to a 2D array of signals in the body of the design (this can then be operated on using for-loop constructs). For example we assign the first row of coefficient values as:
We have six more blocks. Now, because these are individually named, we have to assign them to the signal array explicitly as:
What we would like to do is something more like:
Where "kernelconst" would be assigned more like this:
So my question is, (1) can I declare a 2D array of constants, and (2) if so, how? I suspect I would have to use "deferred constants" to declare the array type in a package, but I cannot find any coding examples.
Help is appreciated, thank you!
We have a 2D window filter implemented that we'd like to make more reusable. Presently we use a 7x7 kernel, and we assign the coefficient values to individually-named constants, which are then assigned to a 2D array of signals in the body of the design (this can then be operated on using for-loop constructs). For example we assign the first row of coefficient values as:
--Kernel constant definition
constant kernel00 : std_logic_vector(10 downto 0) := b"00000000011"; --x"0003";
constant kernel01 : std_logic_vector(10 downto 0) := b"00000001000"; --x"0008";
constant kernel02 : std_logic_vector(10 downto 0) := b"00000010000"; --x"0010";
constant kernel03 : std_logic_vector(10 downto 0) := b"00000010100"; --x"0014";
constant kernel04 : std_logic_vector(10 downto 0) := b"00000010000"; --x"0010";
constant kernel05 : std_logic_vector(10 downto 0) := b"00000001000"; --x"0008";
constant kernel06 : std_logic_vector(10 downto 0) := b"00000000011"; --x"0003";
We have six more blocks. Now, because these are individually named, we have to assign them to the signal array explicitly as:
kernel(0)(0) <= kernel00;
kernel(0)(1) <= kernel01;
kernel(0)(2) <= kernel02;
kernel(0)(3) <= kernel03;
kernel(0)(4) <= kernel04;
kernel(0)(5) <= kernel05;
kernel(0)(6) <= kernel06;
What we would like to do is something more like:
for i in 0 to KERNEL_HEIGHT loop
for j in 0 to KERNEL_WIDTH loop
kernel(i)(j) <= kernelconst(i)(j);
end loop;
end loop;
Where "kernelconst" would be assigned more like this:
constant kernelconst(0)(0) : std_logic_vector(10 downto 0) := b"00000000011"; --x"0003";
constant kernelconst(0)(1) : std_logic_vector(10 downto 0) := b"00000001000"; --x"0008";
constant kernelconst(0)(2) : std_logic_vector(10 downto 0) := b"00000010000"; --x"0010";
constant kernelconst(0)(3) : std_logic_vector(10 downto 0) := b"00000010100"; --x"0014";
constant kernelconst(0)(4) : std_logic_vector(10 downto 0) := b"00000010000"; --x"0010";
constant kernelconst(0)(5) : std_logic_vector(10 downto 0) := b"00000001000"; --x"0008";
constant kernelconst(0)(6) : std_logic_vector(10 downto 0) := b"00000000011"; --x"0003";
So my question is, (1) can I declare a 2D array of constants, and (2) if so, how? I suspect I would have to use "deferred constants" to declare the array type in a package, but I cannot find any coding examples.
Help is appreciated, thank you!