otsdaq_prepmodernization
v2_05_02_indev
Return to top level
Main Page
Classes
Files
File List
tx_seq_ctl.vhd
1
-------------------------------------------------------------------------------
2
--
3
-- Title : GEC_TX_SEQ_CTL
4
-- Design : ethernet_controller
5
-- Author : aprosser
6
-- Company : CD_CEPA_ESE
7
--
8
-------------------------------------------------------------------------------
9
--
10
-- File : d:\Projects\otsdaq\OtS Ethernet MAC firmware\ActiveHDL_proj\ethernet_controller\compile\tx_seq_ctl.vhd
11
-- Generated : 06/01/16 15:03:44
12
-- From : d:/Projects/otsdaq/OtS Ethernet MAC firmware/ActiveHDL_proj/ethernet_controller/src/tx_seq_ctl.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.NUMERIC_STD.
all
;
24
use
work.params_package.
all
;
25
26
entity
tx_seq_ctl
is
27
port
(
28
clk
:
in
STD_LOGIC
;
29
ctrl_info_fifo_empty
:
in
STD_LOGIC
;
30
data_fifo_empty
:
in
STD_LOGIC
;
31
data_fifo_rd_data
:
in
STD_LOGIC_VECTOR
(
63
downto
0
)
;
32
data_info_fifo_empty
:
in
STD_LOGIC
;
33
dest_busy
:
in
STD_LOGIC
;
34
four_bit_mode
:
in
STD_LOGIC
;
35
info_fifo_rd_data
:
in
STD_LOGIC_VECTOR
(
15
downto
0
)
;
36
reset
:
in
STD_LOGIC
;
37
user_tx_enable_out
:
in
STD_LOGIC
;
38
data_fifo_rden
:
out
STD_LOGIC
;
39
fifo_sel
:
out
STD_LOGIC
;
40
info_fifo_rden
:
out
STD_LOGIC
;
41
ret_to_sender
:
out
STD_LOGIC
;
42
tx_data
:
out
STD_LOGIC_VECTOR
(
7
downto
0
)
;
43
user_trigger
:
out
STD_LOGIC
;
44
user_tx_size_in
:
out
STD_LOGIC_VECTOR
(
10
downto
0
)
)
;
45
end
tx_seq_ctl
;
46
47
architecture
arch
of
tx_seq_ctl
is
48
49
-- diagram signals declarations
50
signal
byte_count
:
UNSIGNED
(
2
downto
0
)
;
51
signal
clken
:
STD_LOGIC
;
52
signal
data_fifo_rd_data_reg
:
STD_LOGIC_VECTOR
(
63
downto
0
)
;
53
signal
data_fifo_rden_sig
:
STD_LOGIC
;
54
signal
fifo_sel_sig
:
STD_LOGIC
;
55
signal
info_fifo_rden_sig
:
STD_LOGIC
;
56
signal
qw_count
:
UNSIGNED
(
7
downto
0
)
;
57
signal
seq_count
:
UNSIGNED
(
7
downto
0
)
;
58
signal
tx_data_count
:
UNSIGNED
(
10
downto
0
)
;
59
60
-- BINARY ENCODED state machine: Sreg0
61
attribute
ENUM_ENCODING
:
string
;
62
type
Sreg0_type
is
(
63
S7
,
S1
,
savecount
,
read_Ififo
,
S2
,
idle
,
txmtdone
,
chk_busy
,
S5
,
trgrd
64
)
;
65
attribute
ENUM_ENCODING
of
Sreg0_type
:
type
is
66
"0000 "
&
-- S7
67
"0001 "
&
-- S1
68
"0010 "
&
-- savecount
69
"0011 "
&
-- read_Ififo
70
"0100 "
&
-- S2
71
"0101 "
&
-- idle
72
"0110 "
&
-- txmtdone
73
"0111 "
&
-- chk_busy
74
"1000 "
&
-- S5
75
"1001"
;
-- trgrd
76
77
signal
Sreg0
:
Sreg0_type
;
78
79
attribute
STATE_VECTOR
:
string
;
80
attribute
STATE_VECTOR
of
arch
:
architecture
is
"Sreg0"
;
81
82
begin
83
84
-- concurrent signals assignments
85
86
-- Diagram ACTION
87
info_fifo_rden
<=
info_fifo_rden_sig
and
clken
;
88
data_fifo_rden
<=
data_fifo_rden_sig
and
clken
;
89
fifo_sel
<=
fifo_sel_sig
;
90
four_bit_proc :
process
(clk)
91
begin
92
if
rising_edge
(
clk
)
then
93
if
(
four_bit_mode
=
'
1
'
)
then
94
clken
<=
not
clken
;
95
else
96
clken
<=
'
1
'
;
97
end
if
;
98
end
if
;
99
end
process
;
100
101
----------------------------------------------------------------------
102
-- Machine: Sreg0
103
----------------------------------------------------------------------
104
Sreg0_machine:
process
(clk)
105
begin
106
if
clk
'
event
and
clk
=
'
1
'
then
107
if
reset
=
'
1
'
then
108
Sreg0
<=
idle
;
109
-- Set default values for outputs, signals and variables
110
info_fifo_rden_sig
<=
'
0
'
;
111
data_fifo_rden_sig
<=
'
0
'
;
112
seq_count
<=
(
others
=
>
'
0
'
)
;
113
user_trigger
<=
'
0
'
;
114
user_tx_size_in
<=
(
others
=
>
'
0
'
)
;
115
qw_count
<=
(
others
=
>
'
0
'
)
;
116
tx_data_count
<=
(
others
=
>
'
0
'
)
;
117
data_fifo_rd_data_reg
<=
(
others
=
>
'
0
'
)
;
118
byte_count
<=
(
others
=
>
'
0
'
)
;
119
fifo_sel_sig
<=
'
0
'
;
120
ret_to_sender
<=
'
0
'
;
121
else
122
if
clken
=
'
1
'
then
123
-- Set default values for outputs, signals and variables
124
info_fifo_rden_sig
<=
'
0
'
;
125
data_fifo_rden_sig
<=
'
0
'
;
126
case
Sreg0
is
127
when
S7
=
>
128
Sreg0
<=
txmtdone
;
129
user_trigger
<=
'
0
'
;
130
seq_count
<=
seq_count
+
1
;
131
when
S1
=
>
132
Sreg0
<=
S2
;
133
-- add return code and sequence counter byte to
134
-- produce the final number of bytes
135
tx_data_count
<=
tx_data_count
+
2
;
136
when
savecount
=
>
137
Sreg0
<=
S1
;
138
-- get number of quad words
139
qw_count
<=
unsigned
(
info_fifo_rd_data
(
15
downto
8
)
)
;
140
-- assert the return code to the Ethernet Controller
141
-- so that the first byte is ready and waiting
142
tx_data
(
7
downto
2
)
<=
info_fifo_rd_data
(
7
downto
2
)
;
143
if
(
fifo_sel_sig
=
'
1
'
)
then
-- data fifo, use burst codes
144
tx_data
(
1
downto
0
)
<=
info_fifo_rd_data
(
1
downto
0
)
;
145
ret_to_sender
<=
'
0
'
;
146
else
-- ctrl fifo, use ret to sender bit
147
tx_data
(
1
downto
0
)
<=
'
0
'
&
info_fifo_rd_data
(
0
)
;
148
ret_to_sender
<=
not
info_fifo_rd_data
(
1
)
;
149
end
if
;
150
-- compute number of bytes in quad words to be returned to PC
151
-- multiplies quad word count by 8
152
tx_data_count
<=
unsigned
(
info_fifo_rd_data
(
15
downto
8
)
&
"000"
)
;
153
if
(
unsigned
(
info_fifo_rd_data
(
15
downto
8
)
)
/=
0
)
then
154
-- read a data quad word for initialization
155
data_fifo_rden_sig
<=
'
1
'
;
156
end
if
;
157
when
read_Ififo
=
>
158
Sreg0
<=
savecount
;
159
when
S2
=
>
160
Sreg0
<=
chk_busy
;
161
user_tx_size_in
<=
std_logic_vector
(
tx_data_count
)
;
162
-- present byte count to GEC
163
when
idle
=
>
164
if
data_info_fifo_empty
=
'
0
'
or
165
ctrl_info_fifo_empty
=
'
0
'
then
-- Then there is data to send!
166
Sreg0
<=
read_Ififo
;
167
-- Read the info word
168
info_fifo_rden_sig
<=
'
1
'
;
169
byte_count
<=
(
others
=
>
'
0
'
)
;
170
-- 0 for ctrl fifo, 1 for burst data fifo
171
fifo_sel_sig
<=
not
data_info_fifo_empty
;
172
end
if
;
173
when
txmtdone
=
>
174
Sreg0
<=
idle
;
175
when
chk_busy
=
>
176
if
dest_busy
=
'
0
'
then
177
Sreg0
<=
trgrd
;
178
-- EC not busy, assert trigger
179
user_trigger
<=
'
1
'
;
180
-- prepare first quad word if there is one
181
data_fifo_rd_data_reg
<=
data_fifo_rd_data
;
182
elsif
dest_busy
=
'
1
'
then
183
Sreg0
<=
chk_busy
;
184
end
if
;
185
when
S5
=
>
186
if
byte_count
=
0
and
qw_count
=
0
then
187
Sreg0
<=
S7
;
188
else
189
Sreg0
<=
S5
;
190
tx_data
<=
data_fifo_rd_data_reg
(
7
downto
0
)
;
191
byte_count
<=
byte_count
+
1
;
192
if
(
byte_count
=
2
and
qw_count
>
1
)
then
193
-- Read a new data quad word from data fifo with plenty of time to spare
194
data_fifo_rden_sig
<=
'
1
'
;
195
end
if
;
196
if
(
byte_count
=
7
)
then
--ready for next quadword
197
-- register next quad word from data fifo
198
data_fifo_rd_data_reg
<=
data_fifo_rd_data
;
199
qw_count
<=
qw_count
-
1
;
200
else
-- on current quadword
201
-- shift next byte into position
202
data_fifo_rd_data_reg
<=
x
"00"
&
data_fifo_rd_data_reg
(
63
downto
8
)
;
203
end
if
;
204
end
if
;
205
when
trgrd
=
>
206
if
user_tx_enable_out
=
'
1
'
then
207
Sreg0
<=
S5
;
208
tx_data
<=
std_logic_vector
(
seq_count
)
;
209
elsif
-- trigger sent, wait for tx enable
210
user_tx_enable_out
=
'
0
'
then
211
Sreg0
<=
trgrd
;
212
end
if
;
213
--vhdl_cover_off
214
when
others
=
>
215
null
;
216
--vhdl_cover_on
217
end
case
;
218
end
if
;
219
end
if
;
220
end
if
;
221
end
process
;
222
223
end
arch
;
tx_seq_ctl
Definition:
tx_seq_ctl.vhd:26
otsdaq_prepmodernization
firmware
g-2
KickerControllerFirmware
oei
tx_seq_ctl.vhd
Generated on Wed Apr 29 2020 18:41:42 for otsdaq_prepmodernization by
1.8.5