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

Back to eFEX documentation
efex_packet_merger.vhd
Go to the documentation of this file.
1 
18 
19 library ieee;
20 use ieee.std_logic_1164.all;
21 use ieee.numeric_std.all;
22 
23 LIBRARY infrastructure_lib;
24 use infrastructure_lib.packet_mux_type.all;
25 
28  generic(NSRC: positive := 4);
29  port (
30  clk : in std_logic;
31  rst_clk : in std_logic;
32  packet_merger_start : in std_logic := '0';
33  packet_merger_enabled : IN std_logic_vector(NSRC-1 downto 0);
34  packet_merger_source : OUT std_logic_vector(2 downto 0);
36  packet_merger_data : IN packet_data_array(NSRC-1 downto 0);
37  packet_merger_valid : IN std_logic_vector(NSRC-1 downto 0);
38  packet_merger_last : IN std_logic_vector(NSRC-1 downto 0);
39  packet_merger_ready : OUT std_logic_vector(NSRC-1 downto 0);
41  packet_data : OUT std_logic_vector (63 DOWNTO 0) ;
42  packet_valid : OUT std_logic;
43  packet_last : OUT std_logic;
44  packet_sub_last : OUT std_logic;
45  packet_ready : IN std_logic
46  );
48 
50 architecture rtl of efex_packet_merger is
51 
52  TYPE STATE_TYPE IS (
53  idle,
54  searching,
55  pause,
56  active
57  );
58  type packet_source_array is array(natural range <>) of unsigned(2 downto 0);
59 
60  signal src, next_src: unsigned(2 downto 0) := (Others => '0'); -- Up to 8 sources...
61  signal sel, next_sel: integer range 0 to NSRC - 1 := 0;
62  signal source_array: packet_source_array(NSRC-1 downto 0);
63  signal state: STATE_TYPE;
64 
65 begin
66 
67  sel <= to_integer(src);
68  next_sel <= to_integer(next_src);
69  packet_merger_source <= std_logic_vector(src);
70 
71 select_block: process(clk)
72  begin
73  if rising_edge(clk) then
74  if (rst_clk = '1') then
75  state <= idle;
76  src <= "000";
77  next_src <= to_unsigned(NSRC-1, 3);
78  source_array <= (Others => (Others => '0'));
79  else
80  case state is
81  when searching =>
82 -- first load LIFO with enabled sources in reverse order
83  if (packet_merger_enabled(next_sel) = '1') then
84  source_array <= source_array(NSRC-2 downto 0) & next_src;
85  end if;
86  if next_src /= "000" then
87  next_src <= next_src - 1;
88  else
89  state <= pause;
90  end if;
91  when pause =>
92 -- start with first enabled source
93  src <= source_array(0);
94  source_array <= "000" & source_array(NSRC-1 downto 1);
95  state <= active;
96  when active =>
97 -- then switch to next source on each input last signal
98  if (packet_merger_last(sel) = '1') and (packet_ready = '1') then -- End of data on this input...
99  if (sel = NSRC-1) then -- and it was the last input
100  src <= "000";
101  state <= idle;
102  else
103  src <= source_array(0);
104  source_array <= "000" & source_array(NSRC-1 downto 1);
105  end if;
106  end if;
107  when Others =>
108  if (packet_merger_start = '1') then
109  src <= "000";
110  next_src <= to_unsigned(NSRC-1, 3);
111  state <= searching;
112  end if;
113  end case;
114  end if;
115  end if;
116  end process select_block;
117 
118 -- mask signal when hunting for data...
119  packet_valid <= packet_merger_valid(sel) when (state = active) else '0';
121 -- report suppressed last embedded within the packet
122  packet_sub_last <= packet_merger_last(sel);
123 -- only enable output last when on last input...
124  packet_last <= packet_merger_last(NSRC-1) when (sel = NSRC-1) else '0';
125 
126  ackgen: for i in NSRC - 1 downto 0 generate
127  begin
128  packet_merger_ready(i) <= packet_ready when (sel = i) and (state = active) else '0';
129  end generate;
130 
131 end rtl;
132 
MUX to concatenate AXI-stream fragments into single packet...
MUX to concatenate AXI-stream fragments into single packet...
in packet_merger_data packet_data_array( NSRC- 1 downto 0)
Input signals.
out packet_data std_logic_vector( 63 DOWNTO 0)
FIFO signals.