ROD firmware  1.0.5
ATLAS l1-calo - ROD_eFEX and ROD_jFEX firmware for the L1Calo ROD board

Back to ROD documentation
onehot_dec.vhd
1 ----------------------------------------------------------------------------------
2 -- Company:
3 -- Engineer:
4 --
5 -- Create Date: 13.02.2017 11:16:21
6 -- Design Name:
7 -- Module Name: onehot_dec
8 -- Project Name:
9 -- Target Devices:
10 -- Tool Versions:
11 -- Description:
12 --
13 -- Dependencies:
14 --
15 -- Revision:
16 -- Revision 0.01 - File Created
17 -- Additional Comments:
18 --
19 ----------------------------------------------------------------------------------
20 
21 
22 library IEEE;
23 use IEEE.STD_LOGIC_1164.ALL;
24 
25 -- Uncomment the following library declaration if using
26 -- arithmetic functions with Signed or Unsigned values
27 use IEEE.NUMERIC_STD.ALL;
28 
29 -- Uncomment the following library declaration if instantiating
30 -- any Xilinx leaf cells in this code.
31 --library UNISIM;
32 --use UNISIM.VComponents.all;
33 
34 -- n to m decoder
35 -- n is number of binary inputs
36 -- m is the number of one-hot outputs
37 
38 
39 
40 entity onehot_dec is
41 -- generic (n : integer := 4; m : integer := 16);
42  generic (n : integer := 5; m : integer := 32);
43  Port ( bin_in : in STD_LOGIC_VECTOR (n-1 downto 0);
44  oh_out : out STD_LOGIC_VECTOR (m-1 downto 0));
45 end onehot_dec;
46 
47 architecture RTL of onehot_dec is
48 
49 signal one : unsigned(m-1 downto 0);
50 signal shift : integer;
51 
52 begin
53 
54 one <= to_unsigned(1,m);
55 shift <= to_integer(unsigned(bin_in));
56 oh_out <= std_logic_vector(one sll shift);
57 
58 end RTL;