eFEX firmware  1.7.3
ATLAS l1-calo - electron and tau feature extraction firmware for eFEX boards

Back to eFEX documentation
MultiMultiplier.vhd
1 library IEEE;
2 use IEEE.STD_LOGIC_1164.all;
3 use IEEE.NUMERIC_STD.all;
4 
5 library work;
6 use work.DataTypes.all;
7 
8 entity MultiMultiplier is
9  generic (parameters : integer := 3; FAST : boolean := false);
10 
11  port (
12  CLK : in std_logic;
13  IN_Word : in DataWord;
14  IN_parameters : in AlgoParameters(parameters-1 downto 0);
15  OUT_Overflow : out std_logic_vector(parameters-1 downto 0);
16  OUT_Words : out DataWords(parameters-1 downto 0)
17  );
18 
19 end MultiMultiplier;
20 
21 architecture Behavioral of MultiMultiplier is
22 
23  component Mult
24  port (
25  CLK : in std_logic;
26  A : in std_logic_vector(15 downto 0);
27  B : in std_logic_vector(7 downto 0);
28  P : out std_logic_vector(23 downto 0)
29  );
30  end component;
31 
32  component FastMult
33  port (
34  CLK : in std_logic;
35  A : in std_logic_vector(15 downto 0);
36  B : in std_logic_vector(7 downto 0);
37  P : out std_logic_vector(23 downto 0)
38  );
39  end component;
40 
41  type param_t is array(natural range <>) of std_logic_vector(MULTIPLIER_PAR_INPUT_WIDTH-1 downto 0);
42  type data_t is array(natural range <>) of std_logic_vector(MULTIPLIER_DATA_INPUT_WIDTH-1 downto 0);
43  type result_big_t is array(natural range <>) of std_logic_vector(MULTIPLIER_OUTPUT_WIDTH-1 downto 0);
44 
45 -- Multipliers input
46  signal Param : param_t(parameters-1 downto 0);
47  signal Data : data_t(parameters-1 downto 0);
48 
49 -- Multipliers output
50  signal Overflow : std_logic_vector(parameters-1 downto 0);
51  signal Result_big : result_big_t(parameters-1 downto 0);
52  signal Result : DataWords(parameters-1 downto 0);
53 
54  constant ZERO_Result : std_logic_vector(Result_big(0)'high downto Result(0)'high+1) := (others => '0');
55 
56 
57 begin
58  OUT_Words <= Result;
59  OUT_Overflow <= Overflow;
60 
61  MULT_FOR : for i in 0 to parameters-1 generate
62 
63  Param(i) <= (minimum(Param(i)'high, IN_parameters(i)'high) downto 0 => IN_parameters(i)(minimum(Param(i)'high, IN_parameters(i)'high) downto 0), others => '0');
64  Data(i) <= (minimum(Data(i)'high, IN_Word'high) downto 0 => IN_Word(minimum(Data(i)'high, IN_Word'high) downto 0), others => '0');
65  -- to make it REALLY multi input just change IN_word into IN_Word(i)
66  -- to do that change the input port from DataWord into DataWords(parameters-1
67  -- downto 0)
68 
69  SPEED : if FAST generate
70  FASTMULTIPLIER : FastMult --delay 2
71  port map (
72  CLK => CLK,
73  A => Data(i),
74  B => Param(i),
75  P => Result_big(i)
76  );
77  else generate
78  MULTIPLIER : Mult --delay 3
79  port map (
80  CLK => CLK,
81  A => Data(i),
82  B => Param(i),
83  P => Result_big(i)
84  );
85  end generate;
86 
87  Result(i) <= Result_big(i)(Result(i)'high downto 0);
88  Overflow(i) <= '1' when Result_big(i)(Result_big(i)'high downto Result(i)'high+1) /= ZERO_Result else '0';
89  end generate MULT_FOR;
90 
91 end Behavioral;