Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
13 years ago

Generic Array

What's the best way to achieve the following statement, when the user_address size depends on a generic value?

generic

(

addr_length: integer;

)

signal addr_enable: std_logic;

signal user_address: std_logic_vector((addr_length - 1) downto 0);

addr_enable <= '0' when (user_address=(others=>'1')) else '1';

Thanks!

3 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    best way to read it would be create a constant:

    
    constant ALL_ONES : std_logic_vector((addr_length - 1) downto 0) := (others => '1');
    addr_enable <= '0' when (user_address=ALL_ONES) else '1';
    
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    or you could use the AND_REDUCE function of the std_logic_misc array:

    addr_enable <= '0' when and_reduce(user_address) = '1' else '1';

    or the fact that the specified function is just reduced very simply:

    addr_enable <= nand_reduce(user_address);

    or even simpler in VHDL 2008:

    addr_enable <= nand user_address;