ERROR: Selector is an unconstrained array

Discussion in 'VHDL' started by Mad I.D., Mar 8, 2009.

  1. Mad I.D.

    Mad I.D. Guest

    ERROR MESSAGE :
    "Selector (Signal 'addr' of type std_logic_vector) is an unconstrained
    array."

    Architecture body, declarative part (before begin) can use entity
    generics but statement part can't ?

    I'm I right? Little explanation on this please.



    entity rom1 is
    generic (
    ADDR_WIDTH : integer :=4;
    DATA_WIDTH : integer :=8
    );
    port (
    addr : in std_logic_vector (ADDR_WIDTH-1 downto 0);
    dout : out std_logic_vector (DATA_WIDTH-1 downto 0)
    );
    end rom1;

    architecture beh of rom1 is
    begin
    with addr select
    dout <= "11001101" when "0000",
    "01011100" when "0001",
    "01010101" when "0010",
    "00000000" when "0011",
    ...............
    ...............
     
    Mad I.D., Mar 8, 2009
    #1
    1. Advertisements

  2. Mad I.D. wrote:
    > ERROR MESSAGE :
    > "Selector (Signal 'addr' of type std_logic_vector) is an unconstrained
    > array."
    >
    > Architecture body, declarative part (before begin) can use entity
    > generics but statement part can't ?



    I would code a constant array as Jonathan did.
    http://mysite.verizon.net/miketreseler/sync_rom.vhd
    Generic dimensions are ok for arrays, but not for case selections.
    The only way to make an asynchronous one-liner,
    is to use fixed widths as shown below.

    -- Mike Treseler
    __________________
    library ieee;
    use ieee.std_logic_1164.all;
    entity rom1 is
    port (
    dout : out std_logic_vector(7 downto 0);
    addr : in std_logic_vector(3 downto 0));
    end entity case_vs_if;

    architecture sim of rom1 is
    begin
    with addr select
    dout <=
    "11001101" when "0000",
    "01011100" when "0001",
    "01010101" when "0010",
    "00000000" when "0011",
    "00000000" when others;
    end architecture sim;
     
    Mike Treseler, Mar 8, 2009
    #2
    1. Advertisements

  3. Mad I.D.

    Mad I.D. Guest

    Thanks all !
     
    Mad I.D., Mar 9, 2009
    #3
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alex Rast
    Replies:
    3
    Views:
    6,375
    Jim Lewis
    Oct 6, 2003
  2. Victor Hannak
    Replies:
    1
    Views:
    692
    Mike Treseler
    Nov 25, 2003
  3. Replies:
    5
    Views:
    1,275
    Ralf Hildebrandt
    May 27, 2005
  4. Amal
    Replies:
    5
    Views:
    9,632
    Brandon
    Mar 8, 2006
  5. Nicolas Matringe

    Unconstrained array and range direction

    Nicolas Matringe, Oct 2, 2006, in forum: VHDL
    Replies:
    12
    Views:
    1,464
  6. andrea2
    Replies:
    0
    Views:
    758
    andrea2
    Oct 19, 2006
  7. jens
    Replies:
    3
    Views:
    1,257
  8. Replies:
    2
    Views:
    1,727
    JimLewis
    Mar 18, 2009
Loading...