]> rtime.felk.cvut.cz Git - fpga/pwm.git/blob - priority_encoder.vhd
Wave_table initialization data format modified.
[fpga/pwm.git] / priority_encoder.vhd
1 library ieee;
2 use ieee.std_logic_1164.all;
3 use ieee.std_logic_arith.all;
4 use ieee.std_logic_unsigned.all;
5
6 library std;
7 use std.textio.all;
8
9 --------------------------------------------------------------------------------
10
11 entity priority_encoder is
12   generic (
13     SEL_W  : integer := 16;
14     CODE_W : integer := 4);
15   port (
16     sel  : in  std_logic_vector (SEL_W-1 downto 0);
17     code : out std_logic_vector (CODE_W-1 downto 0));
18 end entity priority_encoder;
19
20 --------------------------------------------------------------------------------
21
22 architecture behavioral of priority_encoder is
23
24 --------------------------------------------------------------------------------
25
26 begin
27
28   process (sel) is
29   begin
30     code <= (others => '-');
31     
32     for i in 0 to SEL_W-1 loop
33       if sel(i) = '1' then
34         code <= conv_std_logic_vector(i, CODE_W);
35       end if;
36     end loop;
37   end process;
38   
39 end architecture behavioral;
40