Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. entity SelectorWithHiZ_using_For_Loop is
  2.   generic (
  3.       candidates_num : integer := 8);
  4.   port (
  5.       candidates : in std_logic_vector(candidates_num - 1 downto 0);
  6.       selects : in std_logic_vector(candidates_num - 1 downto 0);
  7.       result : out std_logic);
  8. end SelectorWithHiZ_using_For_Loop;
  9.  
  10. architecture Behavioral of SelectorWithHiZ_using_For_Loop is
  11. begin
  12.  
  13.   process(selects)
  14.     variable tmp : std_logic;
  15.   begin
  16.     tmp := 'Z';
  17.     for i in selects'high downto selects'low loop
  18.       if selects(i) = '1' then
  19.         tmp := candidates(i);
  20.       end if;
  21.     end loop;
  22.     result <= tmp;
  23.   end process;
  24.  
  25. end Behavioral;