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

Back to eFEX documentation
ipbus_sorting_outputRAM_wrapper.vhd
1 -- generalised from: ipbus_dpram
2 -- F. Gonnella, October 2017
3 --
4 
5 library IEEE;
6 use IEEE.STD_LOGIC_1164.all;
7 use ieee.numeric_std.all;
8 library ipbus_lib;
9 
10 use ipbus_lib.ipbus.all;
11 use work.DataTypes.all;
12 use work.AlgoDataTypes.all;
13 
15  port(
16  clk_ipb : in std_logic;
17  rst : in std_logic;
18  ipb_in : in ipb_wbus;
19  ipb_out : out ipb_rbus;
20  SortedIn : in AlgoTriggerObject;
21  BCNIn : in std_logic_vector(11 downto 0) := (others => '0');
22  SpyBCNIn : in std_logic := '0';
23 
24  rclk : in std_logic; --280
25  Sync : in std_logic;
26  we : in std_logic := '0';
27  SortedOut : out AlgoTriggerObject
28  );
29 
31 
33 
34 COMPONENT SortingOutputRAM
35  PORT (
36  clka : IN STD_LOGIC;
37  ena : IN STD_LOGIC;
38  wea : IN STD_LOGIC_VECTOR(0 DOWNTO 0);
39  addra : IN STD_LOGIC_VECTOR(6 DOWNTO 0);
40  dina : IN STD_LOGIC_VECTOR(31 DOWNTO 0);
41  douta : OUT STD_LOGIC_VECTOR(31 DOWNTO 0);
42  clkb : IN STD_LOGIC;
43  enb : IN STD_LOGIC;
44  web : IN STD_LOGIC_VECTOR(0 DOWNTO 0);
45  addrb : IN STD_LOGIC_VECTOR(6 DOWNTO 0);
46  dinb : IN STD_LOGIC_VECTOR(31 DOWNTO 0);
47  doutb : OUT STD_LOGIC_VECTOR(31 DOWNTO 0)
48  );
49 END COMPONENT;
50 
51  -- algorithm signals
52  signal din : std_logic_vector(31 downto 0);
53  signal q : std_logic_vector(31 downto 0);
54  signal counter : std_logic_vector(6 downto 0) := "0000000"; --16 BCs*7TOBs
55  signal BC_counter : std_logic_vector(3 downto 0) := "0000"; --16 BCs
56  signal dSync : std_logic_vector(4 downto 0); -- input shift
57  signal dOutput : AlgoTriggerObjects(2 downto 0); -- output shift register
58 
59 
60 
61  --ipbus signals
62  signal ack : std_logic;
63  signal ack2 : std_logic;
64  signal ipbus_write : std_logic_vector(0 downto 0);
65  signal write_enable : std_logic_vector(0 downto 0);
66 
67 begin
68  IPBUS_RAM : process(clk_ipb)
69  begin
70  if rising_edge(clk_ipb) then
71  if ipb_in.ipb_strobe = '1' and ipb_in.ipb_write = '1' then
72  ipbus_write(0) <= '1';
73  else
74  ipbus_write(0) <= '0';
75  end if;
76  ack2 <= ipb_in.ipb_strobe and (not ack2) and (not ack);
77  ack <= ack2;
78 
79  end if;
80  end process;
81 
82  ipb_out.ipb_ack <= ack;
83  ipb_out.ipb_err <= '0';
84 
85  write_enable(0) <= we;
86 
87  COUNTER_PROC : process(rclk)
88  begin
89  if rising_edge(rclk) then
90  dSync(0) <= Sync;
91  dSync(dSync'high downto 1) <= dSync(dSync'high-1 downto 0);
92 
93  if dSync(4) = '1' then
94  BC_counter <= std_logic_vector(unsigned(BC_counter) + 1);
95  end if;
96 
97  if BC_Counter = "0000" and dSync(4) = '1' then
98  counter <= (others => '0');
99  else
100  counter <= std_logic_vector(unsigned(counter) + 1);
101  end if;
102 
103  -- Output is sync'ed with next BC
104  dOutput(0) <= to_AlgoTriggerObject(q);
105  dOutput(dOutput'high downto 1) <= dOutput(dOutput'high-1 downto 0);
106  end if;
107  end process;
108 
109  ALGO_OUTPUT_RAM : SortingOutputRAM
110  port map (
111  clka => clk_ipb,
112  ena => ipb_in.ipb_strobe,
113  wea => ipbus_write,
114  addra => ipb_in.ipb_addr(6 downto 0),
115  dina => ipb_in.ipb_wdata,
116  douta => ipb_out.ipb_rdata,
117  clkb => rclk,
118  enb => '1',
119  web => write_enable,
120  addrb => counter,
121  dinb => din,
122  doutb => q
123  );
124 
125  SortedOut <= dOutput(2);
126  din <= to_LogicVector(SortedIn) when spyBCNIn = '0' else x"f" & BCNIn & x"0fff";
127 
128 end rtl;
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.