Belle II KLM Scint Firmware
1
tx_ll_control.vhd
1
-- (c) Copyright 2008 Xilinx, Inc. All rights reserved.
2
--
3
-- This file contains confidential and proprietary information
4
-- of Xilinx, Inc. and is protected under U.S. and
5
-- international copyright and other intellectual property
6
-- laws.
7
--
8
-- DISCLAIMER
9
-- This disclaimer is not a license and does not grant any
10
-- rights to the materials distributed herewith. Except as
11
-- otherwise provided in a valid license issued to you by
12
-- Xilinx, and to the maximum extent permitted by applicable
13
-- law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND
14
-- WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES
15
-- AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING
16
-- BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-
17
-- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and
18
-- (2) Xilinx shall not be liable (whether in contract or tort,
19
-- including negligence, or under any other theory of
20
-- liability) for any loss or damage of any kind or nature
21
-- related to, arising under or in connection with these
22
-- materials, including for any direct, or any indirect,
23
-- special, incidental, or consequential loss or damage
24
-- (including loss of data, profits, goodwill, or any type of
25
-- loss or damage suffered as a result of any action brought
26
-- by a third party) even if such damage or loss was
27
-- reasonably foreseeable or Xilinx had been advised of the
28
-- possibility of the same.
29
--
30
-- CRITICAL APPLICATIONS
31
-- Xilinx products are not designed or intended to be fail-
32
-- safe, or for use in any application requiring fail-safe
33
-- performance, such as life-support or safety devices or
34
-- systems, Class III medical devices, nuclear facilities,
35
-- applications related to the deployment of airbags, or any
36
-- other applications that could lead to death, personal
37
-- injury, or severe property or environmental damage
38
-- (individually and collectively, "Critical
39
-- Applications"). Customer assumes the sole risk and
40
-- liability of any use of Xilinx products in Critical
41
-- Applications, subject only to applicable laws and
42
-- regulations governing limitations on product liability.
43
--
44
-- THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS
45
-- PART OF THIS FILE AT ALL TIMES.
46
--
47
--
48
49
--
50
-- TX_LL_CONTROL
51
--
52
--
53
--
54
-- Description: This module provides the transmitter state machine
55
-- control logic to connect the LocalLink interface to
56
-- the Aurora Channel.
57
--
58
-- This module supports 1 2-byte lane designs
59
--
60
61
library
IEEE
;
62
use
IEEE.STD_LOGIC_1164.
all
;
63
use
WORK.
AURORA_PKG
.
all
;
64
65
-- synthesis translate_off
66
library
UNISIM
;
67
use
UNISIM.all
;
68
-- synthesis translate_on
69
70
entity
TX_LL_CONTROL
is
71
port
(
72
-- LocalLink PDU Interface
73
TX_SRC_RDY_N
:
in
std_logic
;
74
TX_SOF_N
:
in
std_logic
;
75
TX_EOF_N
:
in
std_logic
;
76
TX_DST_RDY_N
:
out
std_logic
;
77
-- Clock Compensation Interface
78
DO_CC
:
in
std_logic
;
79
-- Global Logic Interface
80
CHANNEL_UP
:
in
std_logic
;
81
-- TX_LL Control Module Interface
82
HALT_C
:
out
std_logic
;
83
-- Aurora Lane Interface
84
GEN_SCP
:
out
std_logic
;
85
GEN_ECP
:
out
std_logic
;
86
GEN_CC
:
out
std_logic
;
87
-- System Interface
88
USER_CLK
:
in
std_logic
)
;
89
end
TX_LL_CONTROL
;
90
91
architecture
RTL
of
TX_LL_CONTROL
is
92
93
-- Parameter Declarations --
94
95
constant
DLY
:
time
:=
1
ns
;
96
97
-- External Register Declarations --
98
99
signal
TX_DST_RDY_N_Buffer
:
std_logic
;
100
signal
HALT_C_Buffer
:
std_logic
;
101
signal
GEN_SCP_Buffer
:
std_logic
;
102
signal
GEN_ECP_Buffer
:
std_logic
;
103
signal
GEN_CC_Buffer
:
std_logic
;
104
105
-- Internal Register Declarations --
106
107
signal
do_cc_r
:
std_logic
;
108
109
signal
idle_r
:
std_logic
;
110
signal
sof_r
:
std_logic
;
111
signal
sof_data_eof_1_r
:
std_logic
;
112
signal
sof_data_eof_2_r
:
std_logic
;
113
signal
sof_data_eof_3_r
:
std_logic
;
114
signal
data_r
:
std_logic
;
115
signal
data_eof_1_r
:
std_logic
;
116
signal
data_eof_2_r
:
std_logic
;
117
signal
data_eof_3_r
:
std_logic
;
118
119
-- Wire Declarations --
120
121
122
signal
next_idle_c
:
std_logic
;
123
signal
next_sof_c
:
std_logic
;
124
signal
next_sof_data_eof_1_c
:
std_logic
;
125
signal
next_sof_data_eof_2_c
:
std_logic
;
126
signal
next_sof_data_eof_3_c
:
std_logic
;
127
signal
next_data_c
:
std_logic
;
128
signal
next_data_eof_1_c
:
std_logic
;
129
signal
next_data_eof_2_c
:
std_logic
;
130
signal
next_data_eof_3_c
:
std_logic
;
131
132
signal
tx_dst_rdy_n_c
:
std_logic
;
133
signal
do_sof_c
:
std_logic
;
134
signal
do_eof_c
:
std_logic
;
135
signal
pdu_ok_c
:
std_logic
;
136
137
-- Declarations to handle VHDL limitations
138
signal
reset_i
:
std_logic
;
139
140
-- Component Declarations --
141
142
component
FDR
143
144
generic
(INIT :
bit
:= '
0
');
145
146
port
(
147
148
Q :
out
std_ulogic
;
149
C :
in
std_ulogic
;
150
D :
in
std_ulogic
;
151
R :
in
std_ulogic
152
153
);
154
155
end
component
;
156
157
begin
158
159
TX_DST_RDY_N
<=
TX_DST_RDY_N_Buffer
;
160
HALT_C
<=
HALT_C_Buffer
;
161
GEN_SCP
<=
GEN_SCP_Buffer
;
162
GEN_ECP
<=
GEN_ECP_Buffer
;
163
GEN_CC
<=
GEN_CC_Buffer
;
164
165
-- Main Body of Code --
166
167
168
169
reset_i
<=
not
CHANNEL_UP
;
170
171
172
-- Clock Compensation --
173
174
-- Register the DO_CC and WARN_CC signals for internal use. Note that the raw DO_CC
175
-- signal is used for some logic so the DO_CC signal should be driven directly
176
-- from a register whenever possible.
177
178
process
(USER_CLK)
179
180
begin
181
182
if
(
USER_CLK
'
event
and
USER_CLK
=
'
1
'
)
then
183
do_cc_r
<=
DO_CC
after
DLY
;
184
end
if
;
185
186
end
process
;
187
188
189
190
-- PDU State Machine --
191
192
-- The PDU state machine handles the encapsulation and transmission of user
193
-- PDUs. It can use the channel when there is no CC, NFC message, UFC header,
194
-- UFC message or remote NFC request.
195
196
-- State Registers
197
198
process
(USER_CLK)
199
200
begin
201
202
if
(
USER_CLK
'
event
and
USER_CLK
=
'
1
'
)
then
203
204
if
(
CHANNEL_UP
=
'
0
'
)
then
205
206
idle_r
<=
'
1
'
after
DLY
;
207
sof_r
<=
'
0
'
after
DLY
;
208
sof_data_eof_1_r
<=
'
0
'
after
DLY
;
209
sof_data_eof_2_r
<=
'
0
'
after
DLY
;
210
sof_data_eof_3_r
<=
'
0
'
after
DLY
;
211
data_r
<=
'
0
'
after
DLY
;
212
data_eof_1_r
<=
'
0
'
after
DLY
;
213
data_eof_2_r
<=
'
0
'
after
DLY
;
214
data_eof_3_r
<=
'
0
'
after
DLY
;
215
216
else
217
218
if
(
pdu_ok_c
=
'
1
'
)
then
219
220
idle_r
<=
next_idle_c
after
DLY
;
221
sof_r
<=
next_sof_c
after
DLY
;
222
sof_data_eof_1_r
<=
next_sof_data_eof_1_c
after
DLY
;
223
sof_data_eof_2_r
<=
next_sof_data_eof_2_c
after
DLY
;
224
sof_data_eof_3_r
<=
next_sof_data_eof_3_c
after
DLY
;
225
data_r
<=
next_data_c
after
DLY
;
226
data_eof_1_r
<=
next_data_eof_1_c
after
DLY
;
227
data_eof_2_r
<=
next_data_eof_2_c
after
DLY
;
228
data_eof_3_r
<=
next_data_eof_3_c
after
DLY
;
229
230
end
if
;
231
232
end
if
;
233
234
end
if
;
235
236
end
process
;
237
238
239
-- Next State Logic
240
241
next_idle_c
<=
(
idle_r
and
not
do_sof_c
)
or
242
(
sof_data_eof_3_r
and
not
do_sof_c
)
or
243
(
data_eof_3_r
and
not
do_sof_c
)
;
244
245
246
247
next_sof_c
<=
(
(
idle_r
and
do_sof_c
)
and
not
do_eof_c
)
or
248
(
(
sof_data_eof_3_r
and
do_sof_c
)
and
not
do_eof_c
)
or
249
(
(
data_eof_3_r
and
do_sof_c
)
and
not
do_eof_c
)
;
250
251
252
253
next_data_c
<=
(
sof_r
and
not
do_eof_c
)
or
254
(
data_r
and
not
do_eof_c
)
;
255
256
257
next_data_eof_1_c
<=
(
sof_r
and
do_eof_c
)
or
258
(
data_r
and
do_eof_c
)
;
259
260
261
next_data_eof_2_c
<=
data_eof_1_r
;
262
263
264
next_data_eof_3_c
<=
data_eof_2_r
;
265
266
267
next_sof_data_eof_1_c
<=
(
(
idle_r
and
do_sof_c
)
and
do_eof_c
)
or
268
(
(
sof_data_eof_3_r
and
do_sof_c
)
and
do_eof_c
)
or
269
(
(
data_eof_3_r
and
do_sof_c
)
and
do_eof_c
)
;
270
271
272
next_sof_data_eof_2_c
<=
sof_data_eof_1_r
;
273
274
275
next_sof_data_eof_3_c
<=
sof_data_eof_2_r
;
276
277
278
-- Generate an SCP character when the PDU state machine is active and in an SOF state.
279
280
process
(USER_CLK)
281
282
begin
283
284
if
(
USER_CLK
'
event
and
USER_CLK
=
'
1
'
)
then
285
286
if
(
CHANNEL_UP
=
'
0
'
)
then
287
288
GEN_SCP_Buffer
<=
'
0
'
after
DLY
;
289
290
else
291
292
GEN_SCP_Buffer
<=
(
(
sof_r
or
sof_data_eof_1_r
)
and
pdu_ok_c
)
after
DLY
;
293
294
end
if
;
295
296
end
if
;
297
298
end
process
;
299
300
301
-- Generate an ECP character when the PDU state machine is active and in and EOF state.
302
303
process
(USER_CLK)
304
305
begin
306
307
if
(
USER_CLK
'
event
and
USER_CLK
=
'
1
'
)
then
308
309
if
(
CHANNEL_UP
=
'
0
'
)
then
310
311
GEN_ECP_Buffer
<=
'
0
'
after
DLY
;
312
313
else
314
315
GEN_ECP_Buffer
<=
(
data_eof_3_r
or
sof_data_eof_3_r
)
and
pdu_ok_c
after
DLY
;
316
317
end
if
;
318
319
end
if
;
320
321
end
process
;
322
323
324
tx_dst_rdy_n_c
<=
(
next_sof_data_eof_1_c
and
pdu_ok_c
)
or
325
sof_data_eof_1_r
or
326
(
next_data_eof_1_c
and
pdu_ok_c
)
or
327
DO_CC
or
328
data_eof_1_r
or
329
(
data_eof_2_r
and
not
pdu_ok_c
)
or
330
(
sof_data_eof_2_r
and
not
pdu_ok_c
)
;
331
332
333
-- The flops for the GEN_CC signal are replicated for timing and instantiated to allow us
334
-- to set their value reliably on powerup.
335
336
gen_cc_flop_0_i : FDR
337
338
port
map
(
339
340
D => do_cc_r,
341
C => USER_CLK,
342
R => reset_i,
343
Q => GEN_CC_Buffer
344
345
)
;
346
347
348
-- The TX_DST_RDY_N signal is registered.
349
350
process
(USER_CLK)
351
352
begin
353
354
if
(
USER_CLK
'
event
and
USER_CLK
=
'
1
'
)
then
355
356
if
(
CHANNEL_UP
=
'
0
'
)
then
357
358
TX_DST_RDY_N_Buffer
<=
'
1
'
after
DLY
;
359
360
else
361
362
TX_DST_RDY_N_Buffer
<=
tx_dst_rdy_n_c
after
DLY
;
363
364
end
if
;
365
366
end
if
;
367
368
end
process
;
369
370
371
-- Helper Logic
372
373
-- SOF requests are valid when TX_SRC_RDY_N. TX_DST_RDY_N and TX_SOF_N are asserted
374
375
do_sof_c
<=
not
TX_SRC_RDY_N
and
376
not
TX_DST_RDY_N_Buffer
and
377
not
TX_SOF_N
;
378
379
380
-- EOF requests are valid when TX_SRC_RDY_N, TX_DST_RDY_N and TX_EOF_N are asserted
381
382
do_eof_c
<=
not
TX_SRC_RDY_N
and
383
not
TX_DST_RDY_N_Buffer
and
384
not
TX_EOF_N
;
385
386
387
388
389
-- Freeze the PDU state machine when CCs must be handled.
390
391
pdu_ok_c
<=
not
do_cc_r
;
392
393
394
-- Halt the flow of data through the datastream when the PDU state machine is frozen.
395
396
HALT_C_Buffer
<=
not
pdu_ok_c
;
397
398
399
-- The aurora channel is 'full' if there is more than enough data to fit into
400
-- a channel that is already carrying an SCP and an ECP character.
401
402
end
RTL
;
AURORA_PKG
Definition:
aurora_pkg.vhd:60
TX_LL_CONTROL
Definition:
tx_ll_control.vhd:70
klm_aurora
source
tx_ll_control.vhd
Generated by
1.8.13