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

Back to eFEX documentation
FastFifo.vhd
Go to the documentation of this file.
1 
7 
8 library ieee;
9 use ieee.std_logic_1164.all;
10 use ieee.numeric_std.all;
11 
12 library algolib;
13 use algolib.DataTypes.all;
14 use algolib.AlgoDataTypes.all;
15 
16 -------------------------------------------------------------------------------
18 entity FastFifo is
19 
20  generic (
21  FASTFIFO_DATA_DEPTH : integer := 8;
22  FASTFIFO_ADDRESS_DEPTH : integer := 3
23  );
24 
25  port (
26  clk : in std_logic;
27  IN_Reset : in std_logic;
28  IN_Data : in AlgoTriggerObject;
29  IN_Write : in std_logic;
30  IN_Ack : in std_logic;
31  OUT_Empty : out std_logic;
32  OUT_Data : out AlgoTriggerObject
33  );
34 
35 end entity FastFifo;
36 
37 -------------------------------------------------------------------------------
39 architecture str of FastFifo is
40 
41  -----------------------------------------------------------------------------
42  -- Internal signal declarations
43  -----------------------------------------------------------------------------
44  signal mem : AlgoTriggerObjects(FASTFIFO_DATA_DEPTH-1 downto 0) := (others => ZERO_ALGO_TRIGGER_OBJECT);
45  signal ReadAddress : std_logic_vector(FASTFIFO_ADDRESS_DEPTH-1 downto 0) := (others => '0');
46  signal WriteAddress : std_logic_vector(FASTFIFO_ADDRESS_DEPTH-1 downto 0) := (others => '0');
47  signal Address : std_logic_vector(FASTFIFO_ADDRESS_DEPTH-1 downto 0) := (others => '0');
48  signal Empty : std_logic;
49 
50 begin -- architecture str
51  Empty <= '0' when unsigned(WriteAddress) > unsigned(ReadAddress) else '1';
52 
53  OUT_Empty <= Empty;
54  OUT_data <= mem(to_integer(unsigned(ReadAddress))) when Empty = '0' else ZERO_ALGO_TRIGGER_OBJECT;
55 
56  reading : process (clk)
57  begin
58  if rising_edge(clk) then
59  if IN_Reset = '1' then
60  ReadAddress <= (others => '0');
61  elsif IN_Ack = '1' and unsigned(ReadAddress) < (FASTFIFO_DATA_DEPTH-1) then
62  ReadAddress <= std_logic_vector(unsigned(ReadAddress) + 1);
63  else
64  ReadAddress <= ReadAddress; --the FIFO will be stuck to this
65  --address until a reset is issued
66  end if;
67  end if;
68 
69  end process reading;
70 
71  writing : process (clk)
72  variable temp : std_logic_vector(1 downto 0);
73  begin
74  if rising_edge(clk) then
75  temp := IN_Reset&IN_Write;
76  case temp is
77  when "11" =>
78  WriteAddress <= (0 => '1', others => '0');
79  when "10" =>
80  WriteAddress <= (others => '0');
81  when "01" =>
82  if unsigned(WriteAddress) >= FASTFIFO_DATA_DEPTH then
83  report "Writing on full FIFO!" severity error;
84  end if;
85  WriteAddress <= std_logic_vector(unsigned(WriteAddress) + 1);
86  when others =>
87  WriteAddress <= WriteAddress;
88  end case;
89 
90  end if;
91 
92  end process writing;
93 
94  mem(mem'high) <= ZERO_ALGO_TRIGGER_OBJECT; --This word will be put as output when
95  --the FIFO is empty
96 
97  Address <= WriteAddress when IN_Reset = '0' else (others => '0');
98 
99  memory : process (clk)
100  begin
101  if rising_edge(clk) then
102  for i in 0 to mem'high-1 loop
103  if IN_Write = '1' and i = to_integer(unsigned(Address)) then
104  mem(i) <= IN_Data;
105  else
106  mem(i) <= mem(i);
107  end if;
108  end loop;
109 
110  end if;
111  end process memory;
112 
113 
114 end architecture str;
115 
116 -------------------------------------------------------------------------------
External data-types and functions.
array(natural range <> ) of AlgoTriggerObject AlgoTriggerObjects
Algorithm OUTPUT port.
std_logic_vector( OUT_TOB_WIDTH- 1 downto 0) AlgoTriggerObject
Algorithm Trigger Object TOB.
Fast FIFO, without control signal but with 1 clock tick i/0 delay.
Definition: FastFifo.vhd:39
Fast FIFO, without control signal but with 1 clock tick i/0 delay.
Definition: FastFifo.vhd:18