Array pipeline

H

hssig

Hi,

I want to declare an array "vecarr " which consists of
std_logic_vector, and a second
array "arr3d " to pipeline the first array.
When simuating the following test code Modelsim complains:
** Fatal: (vsim-3734) Index value 0 is out of range 4 downto 1.


------------------------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;

entity arr_pipe is
end entity;

architecture xy of arr_pipe is

type t_vecarr is array(natural range <>) of std_logic_vector(7 downto
0);
signal vecarr : t_vecarr(15 downto 0) := (others => (others => '1'));
type t_arr3d is array(natural range <>) of t_vecarr(15 downto 0);
signal arr3d : t_arr3d(4 downto 0);
signal clk : std_logic;

begin

process
begin
clk <= '1'; wait for 5 ns;
clk <= '0'; wait for 5 ns;
end process;

process(clk)
begin
if rising_edge(clk) then
for m in 0 to 15 loop
arr3d(arr3d'high)(m) <= vecarr(m);
arr3d(arr3d'high-1 downto 0)(m) <= arr3d(arr3d'high
downto 1)(m); --** ERROR
end loop;
end if;
end process;

end xy;
------------------------------------------------------------------------------------------------


Can someone explain to me what is wrong about that shift register ?

Cheers,
hssig
 
J

Jonathan Bromley

arr3d(arr3d'high-1 downto 0)(m)
<= arr3d(arr3d'high downto 1)(m);  --** ERROR

Huh? You're taking a slice of an array, and then
trying to subscript it? I didn't think that was
possible, but it seems that maybe it is (must go
check the LRM!) and the (m) is being used as a
subscript into the slice arr3d(arr3d'high-1 downto 0).

You need an inner for-loop to do that copy,
scanning over the first subscript of arr3d.

I don't see why you need the m-loop at all,
since you're just copying bits broadside.
What's wrong with this:

arr3d(arr3d'high) <= vecarr;
arr3d(arr3d'high-1 downto 0)
<= arr3d(arr3d'high downto 1);

Or something like this...

for i in arr3d'range loop
if i = arr3d'high then
arr3d(i) <= vecarr;
else
arr3d(i) <= arr3d(i+1);
end if;
end loop;

I don't see the need for a loop scanning over
the subcomponents of the t_vecarr objects.
 
H

hssig

Hi Jonathan,

thank you for your alternative description. I have just been curious
about the reason why my solution does
not work. Now it is clear.

Cheers,
hssig
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top