ROD firmware
1.0.5
ATLAS l1-calo - ROD_eFEX and ROD_jFEX firmware for the L1Calo ROD board
Back to ROD documentation
ROD
packet_processor
hdl
event_hdr_crc9.vhd
1
----------------------------------------------------------------------------------
2
-- Company: University of Cambridge
3
-- Engineer: Ed Flaherty
4
--
5
-- Create Date: 25.09.2018 14:22:06
6
-- Design Name:
7
-- Module Name: event_hdr_crc9 - RTL
8
-----------------------------------------------------------------------------------
9
-- This block generates the crc9 for the outgoing event header
10
-- since there are 3 * 32-bit header words going out, it takes 3 cycles to generate the crc
11
-- in order to avoid a dead cycle, the first word of the crc is processed while the controller is in "idle"
12
-- this is possible because crc start can be continuously asserted while in idle, and the output will only be
13
-- a function of the input. The input will become valid during idle because the TTC fifo is a fall through,
14
-- allowing the first BCN to be stable on the output before reading the fifo.
15
--------------------------------------------------------------------------------------------
16
-- Project Name:
17
-- Target Devices:
18
-- Tool Versions:
19
-- Description:
20
--
21
-- Dependencies:
22
--
23
-- Revision:
24
-- Revision 0.01 - File Created
25
-- Additional Comments:
26
--
27
----------------------------------------------------------------------------------
28
29
30
library
IEEE
;
31
use
IEEE.STD_LOGIC_1164.
ALL
;
32
33
-- Uncomment the following library declaration if using
34
-- arithmetic functions with Signed or Unsigned values
35
--use IEEE.NUMERIC_STD.ALL;
36
37
-- Uncomment the following library declaration if instantiating
38
-- any Xilinx leaf cells in this code.
39
--library UNISIM;
40
--use UNISIM.VComponents.all;
41
42
entity
event_hdr_crc9
is
43
Port
(
44
clock
:
in
STD_LOGIC
;
45
crc_reset
:
in
STD_LOGIC
;
--connect to hdr_sel_2 in the level above
46
BCN
:
in
STD_LOGIC_VECTOR
(
11
downto
0
)
;
47
version
:
in
STD_LOGIC_VECTOR
(
2
downto
0
)
;
48
tob_stream_id
:
in
STD_LOGIC_VECTOR
(
7
downto
0
)
;
49
ECRID
:
in
STD_LOGIC_VECTOR
(
7
downto
0
)
;
50
L1ID
:
in
STD_LOGIC_VECTOR
(
23
downto
0
)
;
51
-- header_reg_0 : in STD_LOGIC_VECTOR (31 downto 0);
52
header_reg_1
:
in
STD_LOGIC_VECTOR
(
31
downto
0
)
;
53
header_reg_2
:
in
STD_LOGIC_VECTOR
(
31
downto
0
)
;
54
crc_start
:
in
STD_LOGIC
;
--connect to (hdr_out_crc9_start and ttc_valid) in the level above
55
load_hdr_reg
:
in
STD_LOGIC
;
56
CRC_out
:
out
STD_LOGIC_VECTOR
(
8
downto
0
)
;
57
hdr_out_crc9_valid
:
out
STD_LOGIC
58
)
;
59
end
event_hdr_crc9
;
60
61
architecture
RTL
of
event_hdr_crc9
is
62
component
osum_crc9d32
63
port
(
64
clock :
in
std_logic
;
65
66
crc_start :
in
std_logic
;
67
d_in :
in
std_logic_vector
(
31
downto
0
);
68
69
crc_out :
out
std_logic_vector
(
8
downto
0
)
70
);
71
72
end
component
;
73
signal
CRC_d_in
:
std_logic_vector
(
31
downto
0
)
;
74
--signal crc_din_reg : std_logic_vector(31 downto 0);
75
signal
cyc_1
:
std_logic
:=
'
0
'
;
76
signal
cyc_2
:
std_logic
:=
'
0
'
;
77
signal
cyc_3
:
std_logic
:=
'
0
'
;
78
signal
crc_valid_i
:
std_logic
:=
'
0
'
;
79
signal
state_sequence
:
std_logic_vector
(
2
downto
0
)
;
80
signal
crc_result
:
std_logic_vector
(
8
downto
0
)
;
81
signal
crc_out_reg
:
std_logic_vector
(
8
downto
0
)
:=
9
x
"00"
;
82
83
84
begin
85
hdr_chk_crc :
osum_crc9d32
86
port
map
(
87
clock => clock,
88
89
-- CRC_out => CRC_out,
90
CRC_out => crc_result,
91
-- crc_start => crc_start,
92
crc_start => load_hdr_reg,
93
d_in => CRC_d_in
94
-- Reset => reset
95
)
;
96
97
-- wait two cycles and then capture the crc calculation result
98
process
(clock)
begin
99
if
rising_edge
(
clock
)
then
100
if
(
crc_reset
=
'
1
'
)
then
101
cyc_1
<=
'
0
'
;
102
cyc_2
<=
'
0
'
;
103
cyc_3
<=
'
0
'
;
104
105
else
106
-- cyc_1 <= load_hdr_reg;
107
---- cyc_2 <= cyc_1;
108
-- cyc_2 <= crc_start;
109
-- cyc_3 <= cyc_2;
110
111
112
cyc_1
<=
load_hdr_reg
;
113
cyc_2
<=
cyc_1
;
114
cyc_3
<=
cyc_2
;
115
116
117
end
if
;
118
end
if
;
119
end
process
;
120
121
122
123
124
--state_sequence <= crc_start & load_hdr_reg & cyc_1;
125
state_sequence
<=
load_hdr_reg
&
cyc_1
&
cyc_2
;
126
127
with
state_sequence
select
128
CRC_d_in
<=
version
&
"000000000"
&
BCN
&
tob_stream_id
when
"100"
,
129
ECRID
&
L1ID
when
"010"
,
130
header_reg_2
when
"001"
,
131
x
"00000000"
when
others
;
132
133
134
--the crc result needs to be saved for header building
135
process
(clock)
begin
136
if
rising_edge
(
clock
)
then
137
if
(
crc_reset
=
'
1
'
)
then
138
crc_out_reg
<=
9
x
"00"
;
139
crc_valid_i
<=
'
0
'
;
140
elsif
(
cyc_3
=
'
1
'
)
then
141
crc_out_reg
<=
crc_result
;
142
crc_valid_i
<=
'
1
'
;
143
else
144
crc_out_reg
<=
crc_out_reg
;
145
end
if
;
146
end
if
;
147
end
process
;
148
149
with
cyc_3
select
150
crc_out
<=
crc_result
when
'
1
'
,
151
crc_out_reg
when
others
;
152
153
with
cyc_3
select
154
hdr_out_crc9_valid
<=
'
1
'
when
'
1
'
,
155
crc_valid_i
when
others
;
156
157
--hdr_out_crc9_valid <= crc_valid_i;
158
159
end
RTL;
event_hdr_crc9.RTL
Definition:
event_hdr_crc9.vhd:61
event_hdr_crc9
Definition:
event_hdr_crc9.vhd:42
osum_crc9d32
Definition:
osum_crc9d32.vhd:28
Generated on Sat Dec 14 2024 13:33:14 for ROD firmware by
1.9.1