otsdaq_prepmodernization
v2_05_02_indev
Return to top level
Main Page
Classes
Files
File List
decipherer.vhd
1
-------------------------------------------------------------------------------
2
--
3
-- Title : Decipherer
4
-- Design : ethernet_controller
5
-- Author : Ryan Rivera
6
-- Company : FNAL
7
--
8
-------------------------------------------------------------------------------
9
--
10
-- File : d:\Projects\otsdaq\OtS Ethernet MAC firmware\ActiveHDL_proj\ethernet_controller\compile\decipherer.vhd
11
-- Generated : 05/18/16 11:48:04
12
-- From : d:/Projects/otsdaq/OtS Ethernet MAC firmware/ActiveHDL_proj/ethernet_controller/src/decipherer.asf
13
-- By : FSM2VHDL ver. 5.0.7.2
14
--
15
-------------------------------------------------------------------------------
16
--
17
-- Description :
18
--
19
-------------------------------------------------------------------------------
20
21
library
IEEE
;
22
use
IEEE.std_logic_1164.
all
;
23
use
IEEE.std_logic_arith.
all
;
24
use
IEEE.std_logic_unsigned.
all
;
25
26
entity
decipherer
is
27
port
(
28
clk
:
in
STD_LOGIC
;
29
data_in
:
in
STD_LOGIC_VECTOR
(
7
downto
0
)
;
30
dv
:
in
STD_LOGIC
;
31
er
:
in
STD_LOGIC
;
32
reset
:
in
STD_LOGIC
;
33
self_addrs
:
in
STD_LOGIC_VECTOR
(
31
downto
0
)
;
34
arp_req_ip
:
out
STD_LOGIC_VECTOR
(
31
downto
0
)
;
35
arp_req_mac
:
out
STD_LOGIC_VECTOR
(
47
downto
0
)
;
36
arp_search_ip
:
out
STD_LOGIC_VECTOR
(
31
downto
0
)
;
37
capture_source_addrs
:
out
STD_LOGIC
;
38
clken_out
:
out
STD_LOGIC
;
39
crc_chk_en
:
out
STD_LOGIC
;
40
crc_chk_init
:
out
STD_LOGIC
;
41
crc_chk_rd
:
out
STD_LOGIC
;
42
data_out
:
out
STD_LOGIC_VECTOR
(
7
downto
0
)
;
43
dest_mac
:
out
STD_LOGIC_VECTOR
(
47
downto
0
)
;
44
four_bit_mode_out
:
out
STD_LOGIC
;
45
icmp_checksum
:
out
STD_LOGIC_VECTOR
(
15
downto
0
)
;
46
ip_data_count
:
out
STD_LOGIC_VECTOR
(
10
downto
0
)
;
47
is_arp
:
out
STD_LOGIC
;
48
is_icmp_ping
:
out
STD_LOGIC
;
49
is_idle
:
out
STD_LOGIC
;
50
is_ip
:
out
STD_LOGIC
;
51
is_udp
:
out
STD_LOGIC
;
52
src_mac
:
out
STD_LOGIC_VECTOR
(
47
downto
0
)
;
53
udp_data_count
:
out
STD_LOGIC_VECTOR
(
10
downto
0
)
;
54
udp_data_valid
:
out
STD_LOGIC
;
55
udp_dest_port_out
:
out
STD_LOGIC_VECTOR
(
15
downto
0
)
;
56
udp_src_ip
:
out
STD_LOGIC_VECTOR
(
31
downto
0
)
;
57
udp_src_port
:
out
STD_LOGIC_VECTOR
(
15
downto
0
)
)
;
58
end
decipherer
;
59
60
architecture
decipherer_arch
of
decipherer
is
61
62
-- diagram signals declarations
63
signal
addrs_match_sig
:
STD_LOGIC
;
64
signal
capture_source_addrs_sig
:
STD_LOGIC
;
65
signal
clken
:
STD_LOGIC
;
66
signal
crc_chk_en_masked
:
STD_LOGIC
;
67
signal
crc_chk_en_unmasked
:
STD_LOGIC
;
68
signal
data
:
STD_LOGIC_VECTOR
(
7
downto
0
)
;
69
signal
dv_old
:
STD_LOGIC
;
70
signal
first_bytes_count
:
STD_LOGIC_VECTOR
(
2
downto
0
)
;
71
signal
four_bit_count
:
STD_LOGIC_VECTOR
(
4
downto
0
)
;
72
signal
four_bit_data
:
STD_LOGIC_VECTOR
(
7
downto
0
)
;
73
signal
four_bit_mode
:
STD_LOGIC
;
74
signal
icmp_trigger_sig
:
STD_LOGIC
;
75
signal
is_arp_sig
:
STD_LOGIC
;
76
signal
is_icmp_ping_sig
:
STD_LOGIC
;
77
signal
is_ip_sig
:
STD_LOGIC
;
78
signal
is_udp_sig
:
STD_LOGIC
;
79
signal
udp_countdown
:
STD_LOGIC_VECTOR
(
15
downto
0
)
;
80
signal
udp_data_valid_sig
:
STD_LOGIC
;
81
signal
udp_dest_ip
:
STD_LOGIC_VECTOR
(
31
downto
0
)
;
82
signal
udp_dest_ip_reg
:
STD_LOGIC_VECTOR
(
31
downto
0
)
;
83
signal
udp_dest_port
:
STD_LOGIC_VECTOR
(
15
downto
0
)
;
84
signal
udp_zeros
:
STD_LOGIC_VECTOR
(
10
downto
0
)
;
85
86
-- SYMBOLIC ENCODED state machine: Sreg0
87
type
Sreg0_type
is
(
88
Idle
,
RecvPacket_IP_Payload_UDP_RecvDataLoop
,
RecvPacket_Type_S29
,
RecvPacket_IP_Payload_IP_TotLength2
,
RecvPacket_IP_Payload_UDP_SourcePort1
,
89
RecvPacket_IP_Payload_IP_VersionAndHeader
,
RecvPacket_Dest_S22
,
RecvPacket_IP_Payload_IP_TotLength1
,
RecvPacket_IP_Payload_IP_ToS
,
90
RecvPacket_Dest_S11
,
RecvPacket_IP_Payload_UDP_DestPort1
,
RecvPacket_IP_Payload_IP_TTL
,
RecvPacket_IP_Payload_IP_FragmentOffset
,
91
RecvPacket_IP_Payload_IP_FlagsAndFrag
,
RecvPacket_IP_Payload_IP_ID2
,
RecvPacket_IP_Payload_IP_ID1
,
RecvPacket_Dest_S12
,
RecvPacket_Dest_S13
,
92
RecvPacket_Dest_S14
,
RecvPacket_Dest_S15
,
RecvPacket_IP_Payload_IP_SourceAddr1
,
RecvPacket_IP_Payload_IP_Checksum2
,
RecvPacket_IP_Payload_IP_Checksum1
,
93
RecvPacket_IP_Payload_IP_Protocol
,
RecvPacket_IP_Payload_IP_SourceAddr3
,
RecvPacket_IP_Payload_IP_SourceAddr2
,
RecvPacket_IP_Payload_IP_DestAddr2
,
94
RecvPacket_IP_Payload_IP_DestAddr1
,
RecvPacket_IP_Payload_IP_SourceAddr4
,
RecvPacket_IP_Payload_IP_DestAddr4
,
RecvPacket_IP_Payload_IP_DestAddr3
,
95
RecvPacket_Type_S26
,
RecvPacket_IP_Payload_UDP_DestPort2
,
RecvPacket_IP_Payload_UDP_Length1
,
RecvPacket_IP_Payload_UDP_Checksum2
,
96
RecvPacket_IP_Payload_UDP_Checksum1
,
RecvPacket_IP_Payload_UDP_Length2
,
RecvPacket_IP_Payload_UDP_SourcePort2
,
RecvPacket_Src_S42
,
97
RecvPacket_Src_S44
,
RecvPacket_Src_S45
,
RecvPacket_Src_S46
,
RecvPacket_Src_S47
,
RecvPacket_Src_S43
,
RecvPacket_Type_S1
,
RecvPacket_Type_S48
,
98
RecvPacket_Type_S49
,
RecvPacket_ARP_Payload_HType2
,
RecvPacket_ARP_Payload_HType1
,
RecvPacket_ARP_Payload_PType1
,
RecvPacket_ARP_Payload_PType2
,
99
RecvPacket_ARP_Payload_HLen
,
RecvPacket_ARP_Payload_PLen
,
RecvPacket_ARP_Payload_Op1
,
RecvPacket_ARP_Payload_SMac1
,
RecvPacket_ARP_Payload_SMac2
,
100
RecvPacket_ARP_Payload_SMac3
,
RecvPacket_ARP_Payload_SMac4
,
RecvPacket_ARP_Payload_SMac5
,
RecvPacket_ARP_Payload_SMac6
,
RecvPacket_ARP_Payload_Sip1
,
101
RecvPacket_ARP_Payload_Sip2
,
RecvPacket_ARP_Payload_Sip3
,
RecvPacket_ARP_Payload_Sip4
,
RecvPacket_ARP_Payload_TMac1
,
RecvPacket_ARP_Payload_TMac2
,
102
RecvPacket_ARP_Payload_TMac3
,
RecvPacket_ARP_Payload_TMac4
,
RecvPacket_ARP_Payload_TMac5
,
RecvPacket_ARP_Payload_TMac6
,
RecvPacket_ARP_Payload_Tip1
,
103
RecvPacket_ARP_Payload_Tip2
,
RecvPacket_ARP_Payload_Tip3
,
RecvPacket_ARP_Payload_Tip4
,
RecvPacket_IP_Payload_ICMP_ID1
,
RecvPacket_ARP_Payload_Op2
,
104
RecvPacket_IP_Payload_ICMP_ID2
,
RecvPacket_Preamble_S50
,
RecvPacket_CRC_ARP_S52
,
RecvPacket_IP_Payload_ICMP_SeqNum1
,
RecvPacket_CRC_ARP_S53
,
105
RecvPacket_CRC_ARP_crc1
,
RecvPacket_IP_Payload_ICMP_SeqNum2
,
RecvPacket_CRC_ARP_crc2
,
RecvPacket_CRC_ARP_crc3
,
RecvPacket_CRC_ARP_crc4
,
106
RecvPacket_IP_Payload_ICMP_DataLoop
,
RecvPacket_Preamble_S54
,
RecvPacket_CRC_IP_S55
,
RecvPacket_CRC_IP_crc6
,
RecvPacket_CRC_IP_crc7
,
107
RecvPacket_CRC_IP_crc8
,
RecvPacket_CRC_IP_crc9
,
RecvPacket_CRC_IP_S56
,
RecvPacket_Preamble_S57
,
Ready
,
RecvPacket_IP_Payload_ICMP_Type
,
108
RecvPacket_IP_Payload_ICMP_Code
,
RecvPacket_IP_Payload_ICMP_Checksum1
,
RecvPacket_IP_Payload_ICMP_Checksum2
109
)
;
110
-- attribute ENUM_ENCODING of Sreg0_type: type is ... -- enum_encoding attribute is not supported for symbolic encoding
111
112
signal
Sreg0
:
Sreg0_type
;
113
114
begin
115
116
-- concurrent signals assignments
117
118
-- Diagram ACTION
119
is_arp
<=
is_arp_sig
;
120
is_ip
<=
is_ip_sig
;
121
is_udp
<=
is_udp_sig
;
122
is_icmp_ping
<=
icmp_trigger_sig
and
addrs_match_sig
;
123
-- FIXED to consider icmp type and dest address.. old: is_icmp_ping_sig;
124
capture_source_addrs
<=
capture_source_addrs_sig
and
addrs_match_sig
;
125
clken_out
<=
clken
;
126
data_out
<=
data
;
127
data
<=
data_in
when
(
four_bit_mode
=
'
0
'
)
else
four_bit_data
;
128
crc_chk_en_masked
<=
crc_chk_en_unmasked
and
clken
and
dv_old
;
129
crc_chk_en
<=
(
crc_chk_en_unmasked
and
dv
)
when
four_bit_mode
=
'
0
'
else
crc_chk_en_masked
;
130
udp_data_valid
<=
udp_data_valid_sig
and
addrs_match_sig
;
131
-- detect 4 bit interface (100 Mbps)
132
-- using first few bytes
133
four_bit_proc :
process
(clk)
134
begin
135
if
rising_edge
(
clk
)
then
136
dv_old
<=
dv
;
137
if
(
Sreg0
=
Ready
)
then
138
four_bit_count
<=
(
others
=
>
'
0
'
)
;
139
first_bytes_count
<=
(
others
=
>
'
0
'
)
;
140
four_bit_mode
<=
'
0
'
;
141
clken
<=
'
1
'
;
142
elsif
(
four_bit_mode
=
'
0
'
and
first_bytes_count
<
5
)
then
143
clken
<=
'
1
'
;
144
first_bytes_count
<=
first_bytes_count
+
1
;
145
--count total bytes
146
if
(
data_in
(
7
downto
4
)
=
0
)
then
--count 4 bit bytes
147
four_bit_count
<=
four_bit_count
+
1
;
148
end
if
;
149
if
(
four_bit_count
>
3
)
then
-- 4 bit mode detected!
150
four_bit_mode
<=
'
1
'
;
151
four_bit_count
<=
(
others
=
>
'
0
'
)
;
152
end
if
;
153
elsif
(
four_bit_mode
=
'
1
'
)
then
154
if
(
four_bit_count
<
9
)
then
-- let data catch up to state machine by withholding clken
155
four_bit_count
<=
four_bit_count
+
1
;
156
clken
<=
'
0
'
;
157
else
158
clken
<=
not
clken
;
159
end
if
;
160
if
(
clken
=
'
1
'
)
then
161
four_bit_data
(
3
downto
0
)
<=
data_in
(
3
downto
0
)
;
162
else
163
four_bit_data
(
7
downto
4
)
<=
data_in
(
3
downto
0
)
;
164
end
if
;
165
else
-- 8bit data mode
166
clken
<=
'
1
'
;
167
end
if
;
168
end
if
;
169
end
process
;
170
-- get received data size and calc number of 0 bytess to fill
171
udp_dc :
process
(clk)
172
begin
173
if
rising_edge
(
clk
)
then
174
if
reset
=
'
1
'
then
175
udp_data_count
<=
(
others
=
>
'
0
'
)
;
176
udp_zeros
<=
(
others
=
>
'
0
'
)
;
177
elsif
Sreg0
=
recvpacket_ip_payload_ip_checksum1
then
-- ip length for icmp
178
ip_data_count
<=
udp_countdown
(
10
downto
0
)
-
(
"000"
&
x
"08"
)
;
179
elsif
Sreg0
=
recvpacket_ip_payload_udp_length2
then
-- udp length for rx output
180
udp_data_count
<=
udp_countdown
(
10
downto
0
)
-
(
"000"
&
x
"08"
)
;
181
-- if number of bytes < 18 then need to add 0's (header is 8)
182
if
udp_countdown
(
10
downto
0
)
<
(
"000"
&
x
"1A"
)
then
183
udp_zeros
<=
(
"000"
&
x
"1A"
)
-
udp_countdown
(
10
downto
0
)
;
184
else
185
udp_zeros
<=
(
others
=
>
'
0
'
)
;
186
end
if
;
187
end
if
;
188
end
if
;
189
end
process
;
190
udp_dest_port_out
<=
udp_dest_port
;
191
-- Change Feb 2016 (no longer assume first 3 bytes of IP)
192
-- NOTE: Only IP is matched. Any mac and port are accepted
193
match_proc :
process
(clk)
194
begin
195
if
rising_edge
(
clk
)
then
196
addrs_match_sig
<=
'
0
'
;
197
--udp_dest_ip_reg <= udp_dest_ip; --add register to help meet timing --FIXME .. adding this extra reg breaks icmp reply timing
198
if
(
udp_dest_ip
=
self_addrs
)
then
-- and
199
--(self_port = 0 or udp_dest_port = self_port)) then
200
-- Note: rejecting the port presented a problem for ICMP matching logic
201
--(x"C0A885" & addrs) then --this UDP packet was intended for this firmware.
202
-- Removed feature: -- or udp_dest_ip = x"C0A885FE" then --0xFE is CAPTAN broadcast
203
-- Note: this is not considering the mac address (shouldn't matter if ARP works?)
204
addrs_match_sig
<=
'
1
'
;
205
end
if
;
206
end
if
;
207
end
process
;
208
209
----------------------------------------------------------------------
210
-- Machine: Sreg0
211
----------------------------------------------------------------------
212
Sreg0_machine:
process
(clk)
213
begin
214
if
clk
'
event
and
clk
=
'
1
'
then
215
if
reset
=
'
1
'
then
216
Sreg0
<=
Idle
;
217
-- Set default values for outputs, signals and variables
218
-- ...
219
-- **** only clear these on reset ****
220
--from ethernet frame
221
dest_mac
<=
(
others
=
>
'
0
'
)
;
222
src_mac
<=
(
others
=
>
'
0
'
)
;
223
--from arp payload
224
arp_req_mac
<=
(
others
=
>
'
0
'
)
;
225
arp_req_ip
<=
(
others
=
>
'
0
'
)
;
226
arp_search_ip
<=
(
others
=
>
'
0
'
)
;
227
--from ipv4 payload
228
udp_src_ip
<=
(
others
=
>
'
0
'
)
;
229
udp_src_port
<=
(
others
=
>
'
0
'
)
;
230
udp_dest_ip
<=
(
others
=
>
'
0
'
)
;
231
four_bit_mode_out
<=
'
0
'
;
232
is_ip_sig
<=
'
0
'
;
233
is_arp_sig
<=
'
0
'
;
234
is_idle
<=
'
1
'
;
235
is_udp_sig
<=
'
0
'
;
236
is_icmp_ping_sig
<=
'
0
'
;
237
icmp_trigger_sig
<=
'
0
'
;
238
--from ipv4 payload
239
udp_data_valid_sig
<=
'
0
'
;
240
--indicates packet data on data lines
241
udp_countdown
<=
(
others
=
>
'
0
'
)
;
242
-- used to determine when udp packet data ends
243
--also used for various delay counts throughout reception
244
crc_chk_init
<=
'
0
'
;
245
crc_chk_en_unmasked
<=
'
0
'
;
246
crc_chk_rd
<=
'
0
'
;
247
capture_source_addrs_sig
<=
'
0
'
;
248
else
249
if
clken
=
'
1
'
then
250
-- Set default values for outputs, signals and variables
251
-- ...
252
case
Sreg0
is
253
when
Idle
=
>
254
is_ip_sig
<=
'
0
'
;
255
is_arp_sig
<=
'
0
'
;
256
is_idle
<=
'
1
'
;
257
is_udp_sig
<=
'
0
'
;
258
is_icmp_ping_sig
<=
'
0
'
;
259
icmp_trigger_sig
<=
'
0
'
;
260
--from ipv4 payload
261
udp_data_valid_sig
<=
'
0
'
;
262
--indicates packet data on data lines
263
udp_countdown
<=
(
others
=
>
'
0
'
)
;
264
-- used to determine when udp packet data ends
265
--also used for various delay counts throughout reception
266
crc_chk_init
<=
'
0
'
;
267
crc_chk_en_unmasked
<=
'
0
'
;
268
crc_chk_rd
<=
'
0
'
;
269
capture_source_addrs_sig
<=
'
0
'
;
270
if
dv
=
'
0
'
and
er
=
'
0
'
then
271
Sreg0
<=
Ready
;
272
udp_dest_ip
<=
(
others
=
>
'
0
'
)
;
273
-- reset for checking destination
274
end
if
;
275
when
Ready
=
>
276
if
dv
=
'
1
'
and
er
=
'
0
'
then
277
Sreg0
<=
RecvPacket_Preamble_S50
;
278
is_idle
<=
'
0
'
;
279
crc_chk_init
<=
'
1
'
;
280
-- reset crc calculation
281
end
if
;
282
when
RecvPacket_IP_Payload_UDP_RecvDataLoop
=
>
283
udp_countdown
<=
udp_countdown
-
1
;
284
if
udp_countdown
=
x
"0009"
then
285
Sreg0
<=
RecvPacket_CRC_IP_S55
;
286
udp_data_valid_sig
<=
'
0
'
;
287
end
if
;
288
when
RecvPacket_IP_Payload_UDP_SourcePort1
=
>
289
Sreg0
<=
RecvPacket_IP_Payload_UDP_SourcePort2
;
290
udp_src_port
(
7
downto
0
)
<=
data
;
291
-- acquire src port to be used as destination port from CAPTAN
292
when
RecvPacket_IP_Payload_UDP_DestPort1
=
>
293
Sreg0
<=
RecvPacket_IP_Payload_UDP_DestPort2
;
294
udp_dest_port
(
7
downto
0
)
<=
data
;
295
--acquire dest port for possible forwarding
296
when
RecvPacket_IP_Payload_UDP_DestPort2
=
>
297
Sreg0
<=
RecvPacket_IP_Payload_UDP_Length1
;
298
udp_countdown
(
15
downto
8
)
<=
data
;
299
when
RecvPacket_IP_Payload_UDP_Length1
=
>
300
Sreg0
<=
RecvPacket_IP_Payload_UDP_Length2
;
301
udp_countdown
(
7
downto
0
)
<=
data
;
302
when
RecvPacket_IP_Payload_UDP_Checksum2
=
>
303
if
udp_countdown
<=
x
"0009"
then
-- for the 1 byte case (or illegal case)
304
Sreg0
<=
RecvPacket_CRC_IP_S55
;
305
udp_data_valid_sig
<=
'
0
'
;
306
else
307
Sreg0
<=
RecvPacket_IP_Payload_UDP_RecvDataLoop
;
308
udp_countdown
<=
udp_countdown
-
1
;
309
end
if
;
310
when
RecvPacket_IP_Payload_UDP_Checksum1
=
>
311
Sreg0
<=
RecvPacket_IP_Payload_UDP_Checksum2
;
312
if
udp_countdown
>
9
then
313
udp_data_valid_sig
<=
'
1
'
;
314
elsif
udp_countdown
=
9
then
-- is 1 byte packet (set IP address)
315
capture_source_addrs_sig
<=
'
1
'
;
316
end
if
;
317
when
RecvPacket_IP_Payload_UDP_Length2
=
>
318
Sreg0
<=
RecvPacket_IP_Payload_UDP_Checksum1
;
319
when
RecvPacket_IP_Payload_UDP_SourcePort2
=
>
320
Sreg0
<=
RecvPacket_IP_Payload_UDP_DestPort1
;
321
udp_dest_port
(
15
downto
8
)
<=
data
;
322
--acquire dest port for possible forwarding
323
when
RecvPacket_IP_Payload_IP_TotLength2
=
>
324
Sreg0
<=
RecvPacket_IP_Payload_IP_ID1
;
325
when
RecvPacket_IP_Payload_IP_VersionAndHeader
=
>
326
Sreg0
<=
RecvPacket_IP_Payload_IP_ToS
;
327
when
RecvPacket_IP_Payload_IP_TotLength1
=
>
328
Sreg0
<=
RecvPacket_IP_Payload_IP_TotLength2
;
329
udp_countdown
(
7
downto
0
)
<=
data
;
330
when
RecvPacket_IP_Payload_IP_ToS
=
>
331
Sreg0
<=
RecvPacket_IP_Payload_IP_TotLength1
;
332
udp_countdown
(
15
downto
8
)
<=
data
;
333
when
RecvPacket_IP_Payload_IP_TTL
=
>
334
if
data
=
x
"11"
then
335
Sreg0
<=
RecvPacket_IP_Payload_IP_Protocol
;
336
is_udp_sig
<=
'
1
'
;
337
elsif
data
=
x
"01"
then
338
Sreg0
<=
RecvPacket_IP_Payload_IP_Protocol
;
339
is_icmp_ping_sig
<=
'
1
'
;
340
else
341
Sreg0
<=
Idle
;
342
end
if
;
343
when
RecvPacket_IP_Payload_IP_FragmentOffset
=
>
344
Sreg0
<=
RecvPacket_IP_Payload_IP_TTL
;
345
when
RecvPacket_IP_Payload_IP_FlagsAndFrag
=
>
346
Sreg0
<=
RecvPacket_IP_Payload_IP_FragmentOffset
;
347
when
RecvPacket_IP_Payload_IP_ID2
=
>
348
Sreg0
<=
RecvPacket_IP_Payload_IP_FlagsAndFrag
;
349
when
RecvPacket_IP_Payload_IP_ID1
=
>
350
Sreg0
<=
RecvPacket_IP_Payload_IP_ID2
;
351
when
RecvPacket_IP_Payload_IP_SourceAddr1
=
>
352
Sreg0
<=
RecvPacket_IP_Payload_IP_SourceAddr2
;
353
udp_src_ip
(
23
downto
16
)
<=
data
;
354
when
RecvPacket_IP_Payload_IP_Checksum2
=
>
355
Sreg0
<=
RecvPacket_IP_Payload_IP_SourceAddr1
;
356
udp_src_ip
(
31
downto
24
)
<=
data
;
357
when
RecvPacket_IP_Payload_IP_Checksum1
=
>
358
Sreg0
<=
RecvPacket_IP_Payload_IP_Checksum2
;
359
when
RecvPacket_IP_Payload_IP_Protocol
=
>
360
Sreg0
<=
RecvPacket_IP_Payload_IP_Checksum1
;
361
when
RecvPacket_IP_Payload_IP_SourceAddr3
=
>
362
Sreg0
<=
RecvPacket_IP_Payload_IP_SourceAddr4
;
363
udp_src_ip
(
7
downto
0
)
<=
data
;
364
when
RecvPacket_IP_Payload_IP_SourceAddr2
=
>
365
Sreg0
<=
RecvPacket_IP_Payload_IP_SourceAddr3
;
366
udp_src_ip
(
15
downto
8
)
<=
data
;
367
when
RecvPacket_IP_Payload_IP_DestAddr2
=
>
368
Sreg0
<=
RecvPacket_IP_Payload_IP_DestAddr3
;
369
udp_dest_ip
(
15
downto
8
)
<=
data
;
370
when
RecvPacket_IP_Payload_IP_DestAddr1
=
>
371
Sreg0
<=
RecvPacket_IP_Payload_IP_DestAddr2
;
372
udp_dest_ip
(
23
downto
16
)
<=
data
;
373
when
RecvPacket_IP_Payload_IP_SourceAddr4
=
>
374
Sreg0
<=
RecvPacket_IP_Payload_IP_DestAddr1
;
375
udp_dest_ip
(
31
downto
24
)
<=
data
;
376
when
RecvPacket_IP_Payload_IP_DestAddr4
=
>
377
if
(
is_icmp_ping_sig
=
'
1
'
)
and
(
data
=
x
"08"
)
then
-- ping echo request
378
Sreg0
<=
RecvPacket_IP_Payload_ICMP_Type
;
379
udp_countdown
<=
udp_countdown
-
28
;
380
-- get ping payload data length
381
icmp_trigger_sig
<=
'
1
'
;
382
-- trigger packet create
383
elsif
is_icmp_ping_sig
=
'
1
'
then
384
Sreg0
<=
Idle
;
385
elsif
is_udp_sig
=
'
1
'
then
386
Sreg0
<=
RecvPacket_IP_Payload_UDP_SourcePort1
;
387
udp_src_port
(
15
downto
8
)
<=
data
;
388
-- acquire src port to be used as destination port from CAPTAN
389
end
if
;
390
when
RecvPacket_IP_Payload_IP_DestAddr3
=
>
391
Sreg0
<=
RecvPacket_IP_Payload_IP_DestAddr4
;
392
udp_dest_ip
(
7
downto
0
)
<=
data
;
393
when
RecvPacket_IP_Payload_ICMP_ID1
=
>
394
Sreg0
<=
RecvPacket_IP_Payload_ICMP_ID2
;
395
when
RecvPacket_IP_Payload_ICMP_ID2
=
>
396
Sreg0
<=
RecvPacket_IP_Payload_ICMP_SeqNum1
;
397
when
RecvPacket_IP_Payload_ICMP_SeqNum1
=
>
398
Sreg0
<=
RecvPacket_IP_Payload_ICMP_SeqNum2
;
399
when
RecvPacket_IP_Payload_ICMP_SeqNum2
=
>
400
Sreg0
<=
RecvPacket_IP_Payload_ICMP_DataLoop
;
401
when
RecvPacket_IP_Payload_ICMP_DataLoop
=
>
402
udp_countdown
<=
udp_countdown
-
1
;
403
if
udp_countdown
=
1
then
404
Sreg0
<=
RecvPacket_CRC_IP_S55
;
405
end
if
;
406
when
RecvPacket_IP_Payload_ICMP_Type
=
>
407
Sreg0
<=
RecvPacket_IP_Payload_ICMP_Code
;
408
when
RecvPacket_IP_Payload_ICMP_Code
=
>
409
Sreg0
<=
RecvPacket_IP_Payload_ICMP_Checksum1
;
410
icmp_checksum
(
15
downto
8
)
<=
data
;
411
when
RecvPacket_IP_Payload_ICMP_Checksum1
=
>
412
Sreg0
<=
RecvPacket_IP_Payload_ICMP_Checksum2
;
413
icmp_checksum
(
7
downto
0
)
<=
data
;
414
when
RecvPacket_IP_Payload_ICMP_Checksum2
=
>
415
Sreg0
<=
RecvPacket_IP_Payload_ICMP_ID1
;
416
when
RecvPacket_ARP_Payload_HType2
=
>
417
Sreg0
<=
RecvPacket_ARP_Payload_PType1
;
418
when
RecvPacket_ARP_Payload_HType1
=
>
419
Sreg0
<=
RecvPacket_ARP_Payload_HType2
;
420
when
RecvPacket_ARP_Payload_PType1
=
>
421
Sreg0
<=
RecvPacket_ARP_Payload_PType2
;
422
when
RecvPacket_ARP_Payload_PType2
=
>
423
Sreg0
<=
RecvPacket_ARP_Payload_HLen
;
424
when
RecvPacket_ARP_Payload_HLen
=
>
425
Sreg0
<=
RecvPacket_ARP_Payload_PLen
;
426
when
RecvPacket_ARP_Payload_PLen
=
>
427
Sreg0
<=
RecvPacket_ARP_Payload_Op1
;
428
when
RecvPacket_ARP_Payload_Op1
=
>
429
Sreg0
<=
RecvPacket_ARP_Payload_Op2
;
430
when
RecvPacket_ARP_Payload_SMac1
=
>
431
Sreg0
<=
RecvPacket_ARP_Payload_SMac2
;
432
arp_req_mac
(
39
downto
32
)
<=
data
;
433
when
RecvPacket_ARP_Payload_SMac2
=
>
434
Sreg0
<=
RecvPacket_ARP_Payload_SMac3
;
435
arp_req_mac
(
31
downto
24
)
<=
data
;
436
when
RecvPacket_ARP_Payload_SMac3
=
>
437
Sreg0
<=
RecvPacket_ARP_Payload_SMac4
;
438
arp_req_mac
(
23
downto
16
)
<=
data
;
439
when
RecvPacket_ARP_Payload_SMac4
=
>
440
Sreg0
<=
RecvPacket_ARP_Payload_SMac5
;
441
arp_req_mac
(
15
downto
8
)
<=
data
;
442
when
RecvPacket_ARP_Payload_SMac5
=
>
443
Sreg0
<=
RecvPacket_ARP_Payload_SMac6
;
444
arp_req_mac
(
7
downto
0
)
<=
data
;
445
when
RecvPacket_ARP_Payload_SMac6
=
>
446
Sreg0
<=
RecvPacket_ARP_Payload_Sip1
;
447
arp_req_ip
(
31
downto
24
)
<=
data
;
448
when
RecvPacket_ARP_Payload_Sip1
=
>
449
Sreg0
<=
RecvPacket_ARP_Payload_Sip2
;
450
arp_req_ip
(
23
downto
16
)
<=
data
;
451
when
RecvPacket_ARP_Payload_Sip2
=
>
452
Sreg0
<=
RecvPacket_ARP_Payload_Sip3
;
453
arp_req_ip
(
15
downto
8
)
<=
data
;
454
when
RecvPacket_ARP_Payload_Sip3
=
>
455
Sreg0
<=
RecvPacket_ARP_Payload_Sip4
;
456
arp_req_ip
(
7
downto
0
)
<=
data
;
457
when
RecvPacket_ARP_Payload_Sip4
=
>
458
Sreg0
<=
RecvPacket_ARP_Payload_TMac1
;
459
when
RecvPacket_ARP_Payload_TMac1
=
>
460
Sreg0
<=
RecvPacket_ARP_Payload_TMac2
;
461
when
RecvPacket_ARP_Payload_TMac2
=
>
462
Sreg0
<=
RecvPacket_ARP_Payload_TMac3
;
463
when
RecvPacket_ARP_Payload_TMac3
=
>
464
Sreg0
<=
RecvPacket_ARP_Payload_TMac4
;
465
when
RecvPacket_ARP_Payload_TMac4
=
>
466
Sreg0
<=
RecvPacket_ARP_Payload_TMac5
;
467
when
RecvPacket_ARP_Payload_TMac5
=
>
468
Sreg0
<=
RecvPacket_ARP_Payload_TMac6
;
469
when
RecvPacket_ARP_Payload_TMac6
=
>
470
Sreg0
<=
RecvPacket_ARP_Payload_Tip1
;
471
arp_search_ip
(
31
downto
24
)
<=
data
;
472
when
RecvPacket_ARP_Payload_Tip1
=
>
473
Sreg0
<=
RecvPacket_ARP_Payload_Tip2
;
474
arp_search_ip
(
23
downto
16
)
<=
data
;
475
when
RecvPacket_ARP_Payload_Tip2
=
>
476
Sreg0
<=
RecvPacket_ARP_Payload_Tip3
;
477
arp_search_ip
(
15
downto
8
)
<=
data
;
478
when
RecvPacket_ARP_Payload_Tip3
=
>
479
Sreg0
<=
RecvPacket_ARP_Payload_Tip4
;
480
arp_search_ip
(
7
downto
0
)
<=
data
;
481
when
RecvPacket_ARP_Payload_Tip4
=
>
482
Sreg0
<=
RecvPacket_CRC_ARP_S52
;
483
when
RecvPacket_ARP_Payload_Op2
=
>
484
Sreg0
<=
RecvPacket_ARP_Payload_SMac1
;
485
arp_req_mac
(
47
downto
40
)
<=
data
;
486
when
RecvPacket_Dest_S22
=
>
487
Sreg0
<=
RecvPacket_Dest_S11
;
488
dest_mac
(
39
downto
32
)
<=
data
;
489
when
RecvPacket_Dest_S11
=
>
490
Sreg0
<=
RecvPacket_Dest_S12
;
491
dest_mac
(
31
downto
24
)
<=
data
;
492
when
RecvPacket_Dest_S12
=
>
493
Sreg0
<=
RecvPacket_Dest_S13
;
494
dest_mac
(
23
downto
16
)
<=
data
;
495
when
RecvPacket_Dest_S13
=
>
496
Sreg0
<=
RecvPacket_Dest_S14
;
497
dest_mac
(
15
downto
8
)
<=
data
;
498
when
RecvPacket_Dest_S14
=
>
499
Sreg0
<=
RecvPacket_Dest_S15
;
500
dest_mac
(
7
downto
0
)
<=
data
;
501
when
RecvPacket_Dest_S15
=
>
502
Sreg0
<=
RecvPacket_Src_S42
;
503
src_mac
(
47
downto
40
)
<=
data
;
504
when
RecvPacket_Src_S42
=
>
505
Sreg0
<=
RecvPacket_Src_S44
;
506
src_mac
(
39
downto
32
)
<=
data
;
507
when
RecvPacket_Src_S44
=
>
508
Sreg0
<=
RecvPacket_Src_S43
;
509
src_mac
(
31
downto
24
)
<=
data
;
510
when
RecvPacket_Src_S45
=
>
511
if
data
=
x
"08"
then
512
Sreg0
<=
RecvPacket_Type_S26
;
513
else
514
Sreg0
<=
RecvPacket_Type_S48
;
515
end
if
;
516
when
RecvPacket_Src_S46
=
>
517
Sreg0
<=
RecvPacket_Src_S45
;
518
src_mac
(
7
downto
0
)
<=
data
;
519
when
RecvPacket_Src_S47
=
>
520
Sreg0
<=
RecvPacket_Src_S46
;
521
src_mac
(
15
downto
8
)
<=
data
;
522
when
RecvPacket_Src_S43
=
>
523
Sreg0
<=
RecvPacket_Src_S47
;
524
src_mac
(
23
downto
16
)
<=
data
;
525
when
RecvPacket_Type_S29
=
>
526
if
is_arp_sig
=
'
1
'
then
527
Sreg0
<=
RecvPacket_ARP_Payload_HType1
;
528
elsif
is_ip_sig
=
'
1
'
then
529
Sreg0
<=
RecvPacket_IP_Payload_IP_VersionAndHeader
;
530
else
531
Sreg0
<=
Idle
;
532
crc_chk_rd
<=
'
1
'
;
533
-- this allows crc_chk to output error status
534
end
if
;
535
when
RecvPacket_Type_S26
=
>
536
if
data
=
x
"00"
then
537
Sreg0
<=
RecvPacket_Type_S29
;
538
is_ip_sig
<=
'
1
'
;
539
elsif
data
=
x
"06"
then
540
Sreg0
<=
RecvPacket_Type_S49
;
541
is_arp_sig
<=
'
1
'
;
542
else
543
Sreg0
<=
RecvPacket_Type_S1
;
544
end
if
;
545
when
RecvPacket_Type_S1
=
>
546
if
is_arp_sig
=
'
1
'
then
547
Sreg0
<=
RecvPacket_ARP_Payload_HType1
;
548
elsif
is_ip_sig
=
'
1
'
then
549
Sreg0
<=
RecvPacket_IP_Payload_IP_VersionAndHeader
;
550
else
551
Sreg0
<=
Idle
;
552
crc_chk_rd
<=
'
1
'
;
553
-- this allows crc_chk to output error status
554
end
if
;
555
when
RecvPacket_Type_S48
=
>
556
Sreg0
<=
RecvPacket_Type_S1
;
557
when
RecvPacket_Type_S49
=
>
558
if
is_arp_sig
=
'
1
'
then
559
Sreg0
<=
RecvPacket_ARP_Payload_HType1
;
560
elsif
is_ip_sig
=
'
1
'
then
561
Sreg0
<=
RecvPacket_IP_Payload_IP_VersionAndHeader
;
562
else
563
Sreg0
<=
Idle
;
564
crc_chk_rd
<=
'
1
'
;
565
-- this allows crc_chk to output error status
566
end
if
;
567
when
RecvPacket_Preamble_S50
=
>
568
udp_countdown
<=
x
"0007"
;
569
-- idle during preamble reception
570
crc_chk_init
<=
'
0
'
;
571
Sreg0
<=
RecvPacket_Preamble_S57
;
572
when
RecvPacket_Preamble_S54
=
>
573
Sreg0
<=
RecvPacket_Dest_S22
;
574
four_bit_mode_out
<=
four_bit_mode
;
575
-- "permanently" latch four bit mode for outside world
576
-- can indicate if 100Mbps vs 1Gbps
577
-- but RGMII is handled upstream DIG_GEC.. so appears to be 8_bit mode (after first packet glitch)
578
dest_mac
(
47
downto
40
)
<=
data
;
579
when
RecvPacket_Preamble_S57
=
>
580
udp_countdown
<=
udp_countdown
-
1
;
581
if
udp_countdown
=
2
or
data
=
x
"D5"
then
582
Sreg0
<=
RecvPacket_Preamble_S54
;
583
crc_chk_en_unmasked
<=
'
1
'
;
584
end
if
;
585
when
RecvPacket_CRC_ARP_S52
=
>
586
udp_countdown
<=
x
"0011"
;
587
Sreg0
<=
RecvPacket_CRC_ARP_S53
;
588
when
RecvPacket_CRC_ARP_S53
=
>
589
udp_countdown
<=
udp_countdown
-
1
;
590
if
udp_countdown
=
x
"0001"
then
591
Sreg0
<=
RecvPacket_CRC_ARP_crc1
;
592
end
if
;
593
when
RecvPacket_CRC_ARP_crc1
=
>
594
Sreg0
<=
RecvPacket_CRC_ARP_crc2
;
595
when
RecvPacket_CRC_ARP_crc2
=
>
596
Sreg0
<=
RecvPacket_CRC_ARP_crc3
;
597
when
RecvPacket_CRC_ARP_crc3
=
>
598
if
dv
=
'
0
'
then
--packets may be padded before CRC
599
Sreg0
<=
RecvPacket_CRC_ARP_crc4
;
600
crc_chk_en_unmasked
<=
'
0
'
;
601
end
if
;
602
when
RecvPacket_CRC_ARP_crc4
=
>
603
Sreg0
<=
Idle
;
604
crc_chk_rd
<=
'
1
'
;
605
-- this allows crc_chk to output error status
606
when
RecvPacket_CRC_IP_S55
=
>
607
udp_countdown
(
10
downto
0
)
<=
udp_zeros
;
608
udp_countdown
(
15
downto
11
)
<=
'
0
'
&
x
"0"
;
609
if
udp_zeros
=
(
"000"
&
x
"00"
)
then
610
Sreg0
<=
RecvPacket_CRC_IP_crc9
;
611
else
612
Sreg0
<=
RecvPacket_CRC_IP_S56
;
613
end
if
;
614
when
RecvPacket_CRC_IP_crc6
=
>
615
Sreg0
<=
Idle
;
616
crc_chk_rd
<=
'
1
'
;
617
-- this allows crc_chk to output error status
618
when
RecvPacket_CRC_IP_crc7
=
>
619
if
dv
=
'
0
'
then
--packet might be padded depending on source... so CRC may come later than FSM accounts for
620
Sreg0
<=
RecvPacket_CRC_IP_crc6
;
621
crc_chk_en_unmasked
<=
'
0
'
;
622
end
if
;
623
when
RecvPacket_CRC_IP_crc8
=
>
624
Sreg0
<=
RecvPacket_CRC_IP_crc7
;
625
when
RecvPacket_CRC_IP_crc9
=
>
626
Sreg0
<=
RecvPacket_CRC_IP_crc8
;
627
when
RecvPacket_CRC_IP_S56
=
>
628
udp_countdown
<=
udp_countdown
-
1
;
629
if
udp_countdown
<=
x
"0001"
then
-- '<' added for size 1 case
630
Sreg0
<=
RecvPacket_CRC_IP_crc9
;
631
end
if
;
632
--vhdl_cover_off
633
when
others
=
>
634
null
;
635
--vhdl_cover_on
636
end
case
;
637
end
if
;
638
end
if
;
639
end
if
;
640
end
process
;
641
642
end
decipherer_arch
;
decipherer
Definition:
decipherer.vhd:26
otsdaq_prepmodernization
firmware
g-2
KickerControllerFirmware
oei
decipherer.vhd
Generated on Wed Apr 29 2020 18:41:40 for otsdaq_prepmodernization by
1.8.5