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

Back to ROD documentation
aurora_reset.vhd
1 ----------------------------------------------------------------------------------
2 -- Company: University of Cambridge
3 -- Engineer: Ed Flaherty
4 --
5 -- Create Date: 24.08.2016 13:48:32
6 -- Design Name:
7 -- Module Name: reset_3 - rtl
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 use IEEE.STD_LOGIC_UNSIGNED.ALL;
25 
26 -- Uncomment the following library declaration if using
27 -- arithmetic functions with Signed or Unsigned values
28 --use IEEE.NUMERIC_STD.ALL;
29 
30 -- Uncomment the following library declaration if instantiating
31 -- any Xilinx leaf cells in this code.
32 --library UNISIM;
33 --use UNISIM.VComponents.all;
34 
35 entity aurora_reset is
36 -- Port ( );
37  Port ( init_clk : in STD_LOGIC;
38  BTN0 : in STD_LOGIC;
39  rst_sw : in STD_LOGIC;
40  tx_reset : out STD_LOGIC;
41  tx_GTReset : out STD_LOGIC := '0';
42  rx_reset : out STD_LOGIC;
43  rx_GTReset : out STD_LOGIC := '0');
44 end aurora_reset;
45 
46 architecture rtl of aurora_reset is
47 signal samp1 : std_logic := '0';
48 signal samp2 : std_logic := '0';
49 signal btn_samp1 : std_logic := '0';
50 signal start_seq : std_logic := '0';
51 signal count : std_logic_vector(15 downto 0) := X"0000";
52 signal pwrcount : std_logic_vector(15 downto 0) := X"0000";
53 signal tx_btn_reset : std_logic := '0';
54 signal rx_btn_reset : std_logic := '0';
55 signal tx_pwr_reset : std_logic := '0';
56 signal rx_pwr_reset : std_logic := '0';
57 signal rx_pwr_GTReset : std_logic := '0';
58 signal tx_pwr_GTReset : std_logic := '0';
59 signal rx_btn_GTReset : std_logic := '0';
60 signal tx_btn_GTReset : std_logic := '0';
61 
62 signal pwr_on : std_logic;
63 begin
64 --power-on
65 --use a switch to hold system in power-up until both boards can be configured. Then release switch to start the sequence of
66 -- both resets and GTresets
67 
68 --normal reset
69 --use BTN0 to start sequence. No GTreset should be issued
70 
71 
72 --Power_on_reset
73 --Simplex power-on sequence:
74 --1. Deassert TX-side gt_reset (A)
75 --2. Deassert RX-side gt_reset (C)
76 --3. Deassert RX-side reset synchronous to user_clk (D)
77 --4. Deassert TX-side reset synchronous to user_clk (B)
78 --Note: Care must be taken to ensure that the (D) to (B) time difference is as minimal as possible.
79 
80 
81 
82  process (init_clk) begin
83  if rising_edge (init_clk) then
84  samp1 <= rst_sw;
85  samp2 <= samp1;
86  end if;
87 
88  end process;
89 
90 --changing timer trigger from reset falling (trailing) edge to rising (leading) edge.
91 -- pwr_on <= samp2 and not samp1;
92  pwr_on <= samp1 and not samp2;
93 
94 
95 
96  process (init_clk) begin
97  if rising_edge (init_clk) then
98  if pwr_on = '1' then
99  pwrcount <= X"FFFF";
100  elsif pwrcount /= X"0000" then
101  pwrcount <= (pwrcount - '1');
102  end if;
103  end if;
104  end process;
105 
106  process (init_clk) begin
107  if rising_edge(init_clk) then
108  if (pwrcount = X"0000" and samp2 = '0') then
109  tx_pwr_reset <= '0';
110  rx_pwr_reset <= '0';
111  tx_pwr_GTReset <= '0';
112  rx_pwr_GTREset <= '0';
113 
114  elsif (samp2 = '1') then
115  tx_pwr_reset <= '1';
116  rx_pwr_reset <= '1';
117  tx_pwr_GTReset <= '1';
118  rx_pwr_GTREset <= '1';
119  end if;
120 
121 --1. Deassert TX-side gt_reset (A)
122  if (pwrcount = X"8000") then
123  tx_pwr_GTReset <='0';
124 
125 --2. Deassert RX-side gt_reset (C)
126  elsif (pwrcount = X"7000") then
127  tx_pwr_GTReset <='0';
128  rx_pwr_GTReset <='0';
129 
130 --3. Deassert RX-side reset synchronous to user_clk (D)
131 
132  elsif (pwrcount = X"0020") then
133  rx_pwr_reset <='0';
134 
135 --4. Deassert TX-side reset synchronous to user_clk (B)
136 --Note: Care must be taken to ensure that the (D) to (B) time difference is as minimal as possible.
137 
138  elsif (pwrcount = X"001D") then
139  tx_pwr_reset <='0';
140 
141  end if;
142  end if;
143  end process;
144 
145 
146 --Button_0_reset
147 --1. tx_system_reset and rx_system_reset are asserted for at least six clock
148 -- user_clk time periods.
149 --2. tx_channel_up and rx_channel_up are deasserted after three user_clk cycles.
150 --3. rx_system_reset is deasserted (or) released after tx_system_reset is deasserted.
151 -- This ensures that the transceiver in the simplex-TX core starts transmitting initialization
152 -- data much earlier and it enhances the likelihood of the simplex-RX core aligning to the
153 -- correct data sequence.
154 --4. rx_channel_up is asserted before tx_channel_up assertion. This condition must be
155 -- satisfied by the simplex-RX core and simplex timer parameters (C_ALIGNED_TIMER,
156 -- C_BONDED_TIMER and C_VERIFY_TIMER) in the simplex-TX core need to be adjusted to
157 -- meet this criteria.
158 --5. tx_channel_up is asserted when the simplex-TX core completes the Aurora 8B/10B
159 -- protocol channel initialization sequence transmission for the configured time. Assertion
160 -- of tx_channel_up last ensures that the simplex-TX core transmits the Aurora
161 -- initialization sequence when the simplex-RX core is ready.
162 
163  process (init_clk) begin
164  if rising_edge(init_clk) then
165  if ((BTN0 = '1') and (btn_samp1 = '0')) then btn_samp1 <= '1';
166  elsif ((BTN0 = '0') and (btn_samp1 = '1')) then start_seq <= '1';
167  end if;
168 
169  if (start_seq ='1') then
170  btn_samp1 <= '0';
171  start_seq <= '0';
172  end if;
173  end if;
174  end process;
175 
176 
177  process (init_clk) begin
178  if rising_edge(init_clk) then
179  if (start_seq = '1') then count <= X"FFFF";
180  elsif (start_seq = '0' and count = X"0000") then count <= X"0000";
181  else count <= (count - '1');
182  end if;
183  end if;
184  end process;
185 
186  process (init_clk) begin
187  if rising_edge(init_clk) then
188  if (start_seq = '1') then
189  rx_btn_reset <= '1';
190  tx_btn_reset <= '1';
191 
192  elsif (count = X"FEFF") then
193  tx_btn_reset <='1';
194 
195  elsif (count = X"FDFF") then
196  tx_btn_GTReset <='1';
197 
198  elsif (count = X"FDF0") then
199  tx_btn_GTReset <='0';
200 
201  elsif (count = X"FDE0") then
202  rx_btn_GTReset <='1';
203 
204  elsif (count = X"FDD0") then
205  rx_btn_GTReset <='0';
206 
207  elsif (count = X"0040") then
208  tx_btn_reset <='0';
209 
210 --3. rx_system_reset is deasserted (or) released after tx_system_reset is deasserted.
211 
212  elsif (count = X"0020") then
213 
214  rx_btn_reset <='0';
215  end if;
216  end if;
217  end process;
218 
219 
220  tx_reset <= tx_pwr_reset or tx_btn_reset;
221  rx_reset <= rx_pwr_reset or rx_btn_reset;
222  tx_GTReset <= tx_pwr_GTReset or tx_btn_GTReset;
223  rx_GTReset <= rx_pwr_GTReset or rx_btn_GTReset;
224 
225 
226 end rtl;
227