AND all elements of an n-bit array in VHDL

前端 未结 3 1475
Happy的楠姐
Happy的楠姐 2020-12-19 13:47

lets say I have an n-bit array. I want to AND all elements in the array. Similar to wiring each element to an n-bit AND gate.

How do I achieve this in VHDL?

<
3条回答
  •  北荒
    北荒 (楼主)
    2020-12-19 14:06

    My favorite, non-VHDL-2008 solution is:

    use ieee.std_logic_unsigned.all ;  -- assuming not VHDL-2008
    . . . 
    result <= '1' when not MyArray = 0 else '0' ; 
    

    With VHDL-2008, I recommend that you use the "and" reduction built-in (see Pedroni's post) and use the IEEE standard package "ieee.numeric_std_unsigned.all" instead of the shareware package "std_logic_unsigned".

提交回复
热议问题