Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)

Generic Array

Altera_Forum
Honored Contributor II
1,235 Views

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!
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
412 Views

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';
0 Kudos
Altera_Forum
Honored Contributor II
412 Views

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;
0 Kudos
Altera_Forum
Honored Contributor II
412 Views

Thank you so much!

0 Kudos
Reply