1

I am trying to make an array of std_logic_vectors in VHDL. The array is used in a generate statement to make a barrel shifter. Each element of the array (array, vector) should be an individually addressable bit. Here's some of my code.

Signal declarations:

type stage_t is array( 4 downto 0 ) of std_logic_vector ( 15 downto 0);
signal stages: stage_t;

In the architecture:

test_stage: for st in 0 to 4 generate
        test_bit_assign: for st_bit in 0 to 15 generate 
            test_stagemux: entity work.mux2_1 port map (
                S => amt(st),
                M0 => stages(st,st_bit), M1 =>  stages(st,st_bit+log_w),
                O => stages(st+1,st_bit)
        );
end generate;

Entity of 2:1 mux:

entity mux2_1 is
   generic ( n : INTEGER := 8);
   port (
       S : in std_logic; -- select
       M0, M1   : in std_logic;
       O        : out std_logic
    );
end mux2_1;

The error that I am getting:

Indexed name prefix type stage_t expects 1 dimensions

This happens anywhere I'm reading or writing to the stages array. How do I address bits of one of the vectors?

woo2
  • 33
  • 1
  • 7
  • 1
    You could also declare type stage_t as `type stage_t is array( 4 downto 0, 15 downto 0) of std_logic;` and make it a two dimensional array retaining your associations in the port map. Without a [Minimal, Complete and Verifiable example](https://stackoverflow.com/help/mcve) it's hard to accurately predict the next problem you'll encounter. –  Apr 08 '17 at 06:13
  • 2
    Stages is a one dimensional type (stage_t). Try along the lines of `M0 => stages(st)(st_bit),` where st in the dimension index, stages(st) is an indexed name specifying which element of stage_t of stages and is a prefix tfor the indexed named using st_bit as an index into an element of the std_logic_vector. You're attempting to address stages as a multidimensional array and it is not. It's elements just happen to be an array type. –  Apr 08 '17 at 06:22
  • 1
    @J.H.Bonarius Yep, some users insist on answering questions in the comments :/ – scary_jeff Apr 10 '17 at 13:29

1 Answers1

1

I solved my problem by following @user1155120's second solution. stage_t is an array of vectors, and each dimension likes to be addressed on its own. stages(st) indexes the entire vector at st. stages(st)(st_bit) is the same as ( stages(st) )(st_bit).

woo2
  • 33
  • 1
  • 7