1 |
2 |
acastong |
//flow_control_l3.h
|
2 |
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
3 |
|
|
* Version: MPL 1.1
|
4 |
|
|
*
|
5 |
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
6 |
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
7 |
|
|
* the License. You may obtain a copy of the License at
|
8 |
|
|
* http://www.mozilla.org/MPL/
|
9 |
|
|
*
|
10 |
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
11 |
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
12 |
|
|
* for the specific language governing rights and limitations under the
|
13 |
|
|
* License.
|
14 |
|
|
*
|
15 |
|
|
* The Original Code is HyperTransport Tunnel IP Core.
|
16 |
|
|
*
|
17 |
|
|
* The Initial Developer of the Original Code is
|
18 |
|
|
* Ecole Polytechnique de Montreal.
|
19 |
|
|
* Portions created by the Initial Developer are Copyright (C) 2005
|
20 |
|
|
* the Initial Developer. All Rights Reserved.
|
21 |
|
|
*
|
22 |
|
|
* Contributor(s):
|
23 |
|
|
* Jean-Francois Belanger
|
24 |
|
|
* Ami Castonguay <acastong@grm.polymtl.ca>
|
25 |
|
|
*
|
26 |
|
|
* Alternatively, the contents of this file may be used under the terms
|
27 |
|
|
* of the Polytechnique HyperTransport Tunnel IP Core Source Code License
|
28 |
|
|
* (the "PHTICSCL License", see the file PHTICSCL.txt), in which case the
|
29 |
|
|
* provisions of PHTICSCL License are applicable instead of those
|
30 |
|
|
* above. If you wish to allow use of your version of this file only
|
31 |
|
|
* under the terms of the PHTICSCL License and not to allow others to use
|
32 |
|
|
* your version of this file under the MPL, indicate your decision by
|
33 |
|
|
* deleting the provisions above and replace them with the notice and
|
34 |
|
|
* other provisions required by the PHTICSCL License. If you do not delete
|
35 |
|
|
* the provisions above, a recipient may use your version of this file
|
36 |
|
|
* under either the MPL or the PHTICSCL License."
|
37 |
|
|
*
|
38 |
|
|
* ***** END LICENSE BLOCK ***** */
|
39 |
|
|
|
40 |
|
|
#include "../core_synth/synth_datatypes.h"
|
41 |
|
|
#include "../core_synth/constants.h"
|
42 |
|
|
|
43 |
|
|
#ifndef FLOW_CONTROL_L3_H
|
44 |
|
|
#define FLOW_CONTROL_L3_H
|
45 |
|
|
|
46 |
|
|
///State machine possible state list
|
47 |
|
|
enum fc_state {
|
48 |
|
|
NOP_SENT, ///< Sending a nop
|
49 |
|
|
FWD_CMD32_SENT,/**< Sending the first dword of command packet from the
|
50 |
|
|
reordering of the other side of the tunnel*/
|
51 |
|
|
FWD_CMD64_FIRST_SENT,///< Sending first dword packet (of a quad word packet) from reordering
|
52 |
|
|
FWD_CMD64_SECOND_SENT,///< Sending second dword packet (of a quad word packet) from reordering
|
53 |
|
|
NOP_SENT_IN_FWD,/**< Sending nop in the middle of transmission of data from
|
54 |
|
|
reordering of the other side of the tunnel*/
|
55 |
|
|
FWD_DATA_SENT, ///< Sending data from reordering of the other side of the tunnel
|
56 |
|
|
CSR_CMD_SENT, ///< Sending a packet from CSR
|
57 |
|
|
EH_CMD_SENT, ///< Sending a packet from the error handler
|
58 |
|
|
USER_CMD32_SENT, ///< Sending a dword packet from user fifo
|
59 |
|
|
USER_CMD64_FIRST_SENT,///< Sending first dword packet (of a quad word packet) from user fifo
|
60 |
|
|
USER_CMD64_SECOND_SENT,///< Sending second dword packet (of a quad word packet) from user fifo
|
61 |
|
|
USER_DATA_SENT, ///< Sending data from the User Interface data buffers
|
62 |
|
|
CSR_DATA_SENT, ///< Sending data from the CSR
|
63 |
|
|
ERROR_DATA_SENT, ///< Sending data from the Error Handler
|
64 |
|
|
NOP_SENT_IN_USER,///< Sending nop in the middle of transmission of data from UI
|
65 |
|
|
NOP_SENT_IN_CSR,///< Sending nop in the middle of transmission of data from CSR
|
66 |
|
|
NOP_SENT_IN_EH,///< Sending nop in the middle of transmission of data from EH
|
67 |
|
|
LDTSTOP_DISCONNECT,///< State where we end up when the link is stopped through LDTSTOP, *not retry mode*
|
68 |
|
|
#ifdef RETRY_MODE_ENABLED
|
69 |
|
|
RETRY_SEND_DISCONNECT,///< Send disconnects NOP to initiate the retry sequence
|
70 |
|
|
RETRY_WAIT_FOR_ACK,/**< After a retry disconnect, wait for the next node to send
|
71 |
|
|
the it's RxNextPacketToAck value so that we know were to start the histor
|
72 |
|
|
playback*/
|
73 |
|
|
RETRY_CMD32_SENT,///< Sending a dword packet from history buffer
|
74 |
|
|
RETRY_CMD64_FIRST_SENT,///< Sending first dword packet (of a quad word packet) from history buffer
|
75 |
|
|
RETRY_CMD64_SECOND_SENT,///< Sending second dword packet (of a quad word packet) from history buffer
|
76 |
|
|
RETRY_DATA_SENT,///< Sending data payload of a history packet
|
77 |
|
|
RETRY_SEND_DISCONNECT_CRC,///< Sends the CRC associated with the disconnect nop
|
78 |
|
|
RETRY_WAIT_FOR_RX_DISCONNECT,/**< Wait for RX to disconnect before attempting to
|
79 |
|
|
reconnect TX */
|
80 |
|
|
RETRY_WAIT_FOR_ACK_AND_BUFFER_COUNT_SENT,/**< After a retry disconnect, wait for
|
81 |
|
|
the next node to send the it's RxNextPacketToAck value so that we know were
|
82 |
|
|
to start the history playback.
|
83 |
|
|
|
84 |
|
|
Retry also requires that we advertise at least the same amount of buffers then
|
85 |
|
|
we had before the retry sequence, so we also wait until all our free buffers
|
86 |
|
|
have been advertised as free*/
|
87 |
|
|
RETRY_WAIT_FOR_ACK_AND_BUFFER_COUNT_SENT_CRC,/**< When in the state
|
88 |
|
|
RETRY_WAIT_FOR_ACK_AND_BUFFER_COUNT_SENT, we send nop. Since we are in
|
89 |
|
|
retry mode, we are also required to send the CRC's of the nop */
|
90 |
|
|
RETRY_SEND_CMD_CRC,///< Send CRC of a history packet
|
91 |
|
|
SEND_CMD_CRC,///< Send the CRC of a packet with no data associated
|
92 |
|
|
SEND_NOP_CRC,///<Send the crc of a nop packet
|
93 |
|
|
SEND_DATA_CRC,///< Send the CRC of a packet with data associated
|
94 |
|
|
NOP_CRC_SENT_IN_FWD,///< Send the CRC of a nop inserted in a FWD data transfer
|
95 |
|
|
NOP_CRC_SENT_IN_USER,///<Send the CRC of a nop inserted in a UI data transfer
|
96 |
|
|
NOP_CRC_SENT_IN_CSR,///< Send the CRC of a nop inserted in a CSR data transfer
|
97 |
|
|
NOP_CRC_SENT_IN_EH,///< Send the CRC of a nop inserted in a EH data transfer
|
98 |
|
|
RETRY_NOP_SENT,///< Send a nop while playing back history
|
99 |
|
|
RETRY_NOP_CRC_SENT,///< Sending the CRC of a nop packet while playing back history
|
100 |
|
|
RETRY_NOP_SENT_IN_DATA,/**< Send a nop while playing back history,
|
101 |
|
|
in the middle of a data packet*/
|
102 |
|
|
RETRY_NOP_CRC_SENT_IN_DATA/**< Sending the CRC of a nop packet while
|
103 |
|
|
playing back history, in the middle of a data packet*/
|
104 |
|
|
#endif
|
105 |
|
|
};
|
106 |
|
|
|
107 |
|
|
//State values for storing if we are sending a chain
|
108 |
|
|
enum fc_chain_state { NO_CHAIN_STATE,FWD_CHAIN_STATE,USER_CHAIN_STATE};
|
109 |
|
|
|
110 |
|
|
|
111 |
|
|
|
112 |
|
|
/// Finite state machine of the flow control
|
113 |
|
|
/**see flow_control_l2.h for explanation of the role of the flow_control*/
|
114 |
|
|
class flow_control_l3 : public sc_module
|
115 |
|
|
{
|
116 |
|
|
public:
|
117 |
|
|
|
118 |
|
|
|
119 |
|
|
//Signals to internal FIFO
|
120 |
|
|
///If there is a packet that can be sent from the internal user fifo
|
121 |
|
|
sc_in <bool> fifo_user_available ;
|
122 |
|
|
///The packet to be sent from the user fifo
|
123 |
|
|
sc_in <sc_bv<64> > fifo_user_packet;
|
124 |
|
|
///The packet fifo_user_packet is being consumed
|
125 |
|
|
sc_out<bool> consume_user_fifo;
|
126 |
|
|
///Hold the packet so it doesn't change after sending the first dword
|
127 |
|
|
sc_out<bool> hold_user_fifo;
|
128 |
|
|
|
129 |
|
|
/**
|
130 |
|
|
These signals are not necessary, but they are registered in the
|
131 |
|
|
user_fifo to accelerate the combinatorial path of this module.
|
132 |
|
|
*/
|
133 |
|
|
//@{
|
134 |
|
|
///Virtual channel of the ::fifo_user_packet
|
135 |
|
|
sc_in<VirtualChannel> fifo_user_packet_vc;
|
136 |
|
|
///If ::fifo_user_packet is a double word packet (as opposed to a quad word, word = 16 bits)
|
137 |
|
|
sc_in<bool> fifo_user_packet_dword;
|
138 |
|
|
///If ::fifo_user_packet has any data associated
|
139 |
|
|
sc_in<bool> fifo_user_packet_data_asociated;
|
140 |
|
|
#ifdef RETRY_MODE_ENABLED
|
141 |
|
|
///The command of fifo_user_packet
|
142 |
|
|
sc_in<PacketCommand > fifo_user_packet_command;
|
143 |
|
|
#endif
|
144 |
|
|
///Size of ::fifo_user_packet data in dwords minus 1
|
145 |
|
|
sc_in<bool> fifo_user_packet_isChain;
|
146 |
|
|
///If ::fifo_user_packet has the chain bit on (also checks if it's a posted packet)
|
147 |
|
|
sc_in<sc_uint<4> > fifo_user_packet_data_count_m1;
|
148 |
|
|
//@}
|
149 |
|
|
|
150 |
|
|
//Signals to error handler
|
151 |
|
|
|
152 |
|
|
///If the error handler has a packet available to send
|
153 |
|
|
sc_in <bool> eh_available_fc ;
|
154 |
|
|
///Acknowledge that the packet from the error handler has been read
|
155 |
|
|
sc_out <bool> fc_ack_eh;
|
156 |
|
|
///The dword to be sent from the errorhandler
|
157 |
|
|
sc_in <sc_bv<32> > eh_cmd_data_fc;
|
158 |
|
|
|
159 |
|
|
|
160 |
|
|
//Signals to CSR
|
161 |
|
|
|
162 |
|
|
///CSR has a packet to be sent
|
163 |
|
|
sc_in <bool> csr_available_fc;
|
164 |
|
|
///Acknowledge that the packet from the CSR has been read
|
165 |
|
|
sc_out <bool> fc_ack_csr;
|
166 |
|
|
///The dword to be sent from the CSR
|
167 |
|
|
sc_in <sc_bv<32> > csr_dword_fc;
|
168 |
|
|
|
169 |
|
|
|
170 |
|
|
//Signals to Reordering
|
171 |
|
|
|
172 |
|
|
///Reordering has a packet to be sent
|
173 |
|
|
sc_in <bool> ro_available_fwd;
|
174 |
|
|
///Reordering requests that a nop be sent to notify of free buffers
|
175 |
|
|
sc_in <bool> ro_nop_req_fc;
|
176 |
|
|
///Packt to send from reordering
|
177 |
|
|
sc_in <syn_ControlPacketComplete> ro_packet_fwd;
|
178 |
|
|
sc_in<VirtualChannel> ro_packet_vc_fwd;
|
179 |
|
|
///To consume the data from the reordering_l2 module
|
180 |
|
|
sc_out<bool> fwd_ack_ro;
|
181 |
|
|
|
182 |
|
|
//Signals to User Interface
|
183 |
|
|
|
184 |
|
|
///To read data from the userinterface buffers
|
185 |
|
|
sc_out <bool> fc_consume_data_ui;
|
186 |
|
|
///The virtual channel of the data to fetch from the user interface buffers
|
187 |
|
|
sc_out<VirtualChannel> fc_data_vc_ui;
|
188 |
|
|
|
189 |
|
|
|
190 |
|
|
|
191 |
|
|
//Signals from databuffer from other side
|
192 |
|
|
|
193 |
|
|
///Databuffer requests that a nop be sent to notify of free buffers
|
194 |
|
|
sc_in <bool> db_nop_req_fc;
|
195 |
|
|
///The address to read data from the databuffer from the other side
|
196 |
|
|
sc_out <sc_uint<BUFFERS_ADDRESS_WIDTH> > fwd_address_db;
|
197 |
|
|
///Read the data from the databuffer of the other side
|
198 |
|
|
sc_out <bool> fwd_read_db;
|
199 |
|
|
///The virtual channel to read data from the databuffer from the other side
|
200 |
|
|
sc_out<VirtualChannel> fwd_vctype_db;
|
201 |
|
|
///To erase the data packet
|
202 |
|
|
sc_out <bool> fwd_erase_db;
|
203 |
|
|
|
204 |
|
|
//Signals from nop_framer
|
205 |
|
|
|
206 |
|
|
///The next packet to send should be a nop
|
207 |
|
|
sc_in <bool> nop_next_to_send;
|
208 |
|
|
///nophandler should generate disconnect nops
|
209 |
|
|
sc_out<bool> generate_disconnect_nop;
|
210 |
|
|
///If there are buffer to be notified as free with a nop
|
211 |
|
|
sc_in<bool> has_nop_buffers_to_send;
|
212 |
|
|
|
213 |
|
|
//Signals to fairness
|
214 |
|
|
|
215 |
|
|
///If the local side has priority
|
216 |
|
|
sc_in<bool> local_priority;
|
217 |
|
|
///If a local packet is issued (can be sent or reserved to send when buffers available)
|
218 |
|
|
sc_out<bool> local_packet_issued;
|
219 |
|
|
|
220 |
|
|
|
221 |
|
|
//Signals to rx_farend_cnt
|
222 |
|
|
|
223 |
|
|
///The VC of the packet currenlty being sent and if it has data (one hot encoding)
|
224 |
|
|
sc_out <sc_bv<6> > current_sent_type;
|
225 |
|
|
///Status of the buffers of every VC's for command and data buffers
|
226 |
|
|
/**Set if it has free buffer (one hot encoding)
|
227 |
|
|
ResponseData bit 0
|
228 |
|
|
Response bit 1
|
229 |
|
|
NonPostData bit 2
|
230 |
|
|
NonPostCmd bit 3
|
231 |
|
|
PostData bit 4
|
232 |
|
|
PostCmd bit 5
|
233 |
|
|
*/
|
234 |
|
|
sc_in<sc_bv<6> > fwd_next_node_buffer_status_ro;
|
235 |
|
|
|
236 |
|
|
#ifdef RETRY_MODE_ENABLED
|
237 |
|
|
///Clear the count of buffers for the next HT node to zero
|
238 |
|
|
sc_out <bool> clear_farend_count;
|
239 |
|
|
|
240 |
|
|
//Misc signals
|
241 |
|
|
|
242 |
|
|
///Link requests that we start a retry disconnect sequence
|
243 |
|
|
sc_in <bool> lk_initiate_retry_disconnect;
|
244 |
|
|
///Force the link to disconnect
|
245 |
|
|
/**Disconnect will occur after the current dword is done sending*/
|
246 |
|
|
sc_out <bool> fc_disconnect_lk;
|
247 |
|
|
///Command decoder requests that we start a retry disconnect sequence
|
248 |
|
|
sc_in <bool> cd_initiate_retry_disconnect;
|
249 |
|
|
|
250 |
|
|
#endif
|
251 |
|
|
//Signal to multiplexer
|
252 |
|
|
|
253 |
|
|
///Select which signal to send to link
|
254 |
|
|
sc_out <sc_uint<4> > fc_ctr_mux;
|
255 |
|
|
|
256 |
|
|
|
257 |
|
|
//Signals to link
|
258 |
|
|
|
259 |
|
|
///LCTL output signal
|
260 |
|
|
sc_out <bool> fc_lctl_lk;
|
261 |
|
|
///HCTL output signal
|
262 |
|
|
sc_out <bool> fc_hctl_lk;
|
263 |
|
|
///For the link to consume data we send to it
|
264 |
|
|
sc_in <bool> lk_consume_fc;
|
265 |
|
|
#ifdef RETRY_MODE_ENABLED
|
266 |
|
|
///If the RX part of the link is connected
|
267 |
|
|
sc_in <bool> lk_rx_connected;
|
268 |
|
|
#endif
|
269 |
|
|
|
270 |
|
|
|
271 |
|
|
//Misc signals
|
272 |
|
|
|
273 |
|
|
///If a nop is being sent to the link
|
274 |
|
|
sc_out <bool> fc_nop_sent;
|
275 |
|
|
///Reset
|
276 |
|
|
sc_in <bool> resetx;
|
277 |
|
|
///LDTSTOP# - Stop the transfer of data to save power
|
278 |
|
|
sc_in <bool> ldtstopx;
|
279 |
|
|
///Clock
|
280 |
|
|
sc_in_clk clock;
|
281 |
|
|
|
282 |
|
|
///Configuration register bit to turn the transmitter off
|
283 |
|
|
//sc_in <bool> csr_transmitteroff;
|
284 |
|
|
///A nop was just received - new ack value and new freed buffers value
|
285 |
|
|
sc_in<bool> nop_received;
|
286 |
|
|
|
287 |
|
|
#ifdef RETRY_MODE_ENABLED
|
288 |
|
|
///If we are in retry mode
|
289 |
|
|
sc_in<bool> csr_retry;
|
290 |
|
|
|
291 |
|
|
|
292 |
|
|
//History signals
|
293 |
|
|
|
294 |
|
|
///Packet from the output of the history buffers
|
295 |
|
|
sc_in <sc_bv<32> > history_packet;
|
296 |
|
|
|
297 |
|
|
///Everything in the history buffers has bee played back
|
298 |
|
|
sc_in <bool > history_playback_done;
|
299 |
|
|
///When the history is ready to begin playback
|
300 |
|
|
sc_in <bool > history_playback_ready;
|
301 |
|
|
///Start to replay the content of the history buffer
|
302 |
|
|
sc_out <bool > begin_history_playback;
|
303 |
|
|
///Interrupt the replay of the content of the history buffer
|
304 |
|
|
sc_out <bool > stop_history_playback;
|
305 |
|
|
///To read the data from the history buffer
|
306 |
|
|
sc_out <bool > consume_history;
|
307 |
|
|
|
308 |
|
|
///The amount of dwords left in the history
|
309 |
|
|
sc_in <bool > room_available_in_history;
|
310 |
|
|
|
311 |
|
|
///Add a dword to the current history entry
|
312 |
|
|
/**
|
313 |
|
|
You must have created an history entry before entering dwords in it...
|
314 |
|
|
*/
|
315 |
|
|
sc_out <bool > add_to_history;
|
316 |
|
|
///Start a new history entry (packet) of size new_history_entry_size_m1
|
317 |
|
|
sc_out <bool > new_history_entry;
|
318 |
|
|
///Size of the new history entry
|
319 |
|
|
sc_out<sc_uint<5> > new_history_entry_size_m1;
|
320 |
|
|
|
321 |
|
|
|
322 |
|
|
//Signals to CRC unit
|
323 |
|
|
|
324 |
|
|
///Calculate the CRC on the current output to the link
|
325 |
|
|
sc_out<bool> calculate_crc;
|
326 |
|
|
///Clear the current calculated CRC value
|
327 |
|
|
sc_out<bool> clear_crc;
|
328 |
|
|
///Calculate the CRC on the current output to the link for nop packets
|
329 |
|
|
sc_out<bool> calculate_nop_crc;
|
330 |
|
|
///Calculate the CRC on the current output to the link for nop packets
|
331 |
|
|
sc_out<bool> clear_nop_crc;
|
332 |
|
|
|
333 |
|
|
///If we should output the current calculated CRC
|
334 |
|
|
sc_out<bool> select_crc_output;
|
335 |
|
|
///If we should output the current calculated nop CRC
|
336 |
|
|
sc_out<bool> select_nop_crc_output;
|
337 |
|
|
|
338 |
|
|
|
339 |
|
|
///Next value of ::fc_disconnect_lk
|
340 |
|
|
sc_signal <bool> next_fc_disconnect_lk;
|
341 |
|
|
///Next value of ::calculate_nop_crc
|
342 |
|
|
sc_signal<bool> next_calculate_nop_crc;
|
343 |
|
|
///Next value of ::calculate_crc
|
344 |
|
|
sc_signal<bool> next_calculate_crc;
|
345 |
|
|
///Next value of ::select_crc_output
|
346 |
|
|
sc_signal<bool> next_select_crc_output;
|
347 |
|
|
///Next value of ::select_nop_crc_output
|
348 |
|
|
sc_signal<bool> next_select_nop_crc_output;
|
349 |
|
|
#endif
|
350 |
|
|
|
351 |
|
|
|
352 |
|
|
///Saved value of fwd_vctype_db
|
353 |
|
|
sc_signal<VirtualChannel> buffered_fwd_vctype_db;
|
354 |
|
|
///Saved value of fwd_address_db
|
355 |
|
|
sc_signal <sc_uint<BUFFERS_ADDRESS_WIDTH> > buffered_fwd_address_db;
|
356 |
|
|
///The next value fc_data_vc_ui will take
|
357 |
|
|
sc_signal<VirtualChannel> buffered_fc_data_vc_ui;
|
358 |
|
|
///Registered value of ::lk_rx_connected
|
359 |
|
|
sc_signal<bool> registered_lk_rx_connected;
|
360 |
|
|
///Registered value of ::registered_lk_initiate_retry_disconnect
|
361 |
|
|
sc_signal<bool> registered_lk_initiate_retry_disconnect;
|
362 |
|
|
|
363 |
|
|
//Buffer signals to link
|
364 |
|
|
|
365 |
|
|
///LCTL output signal
|
366 |
|
|
sc_signal<bool> next_fc_lctl_lk;
|
367 |
|
|
///HCTL output signal
|
368 |
|
|
sc_signal <bool> next_fc_hctl_lk;
|
369 |
|
|
|
370 |
|
|
///Next value of next_data_cnt
|
371 |
|
|
sc_signal<sc_uint<4> > next_data_cnt;
|
372 |
|
|
///The number of dwords left to send all the data payload of a packet
|
373 |
|
|
sc_signal<sc_uint<4> > data_cnt;
|
374 |
|
|
|
375 |
|
|
///Next value of ::has_data
|
376 |
|
|
sc_signal<bool > next_has_data;
|
377 |
|
|
///If there is still data to be sent for the current packet
|
378 |
|
|
sc_signal<bool > has_data;
|
379 |
|
|
|
380 |
|
|
///Next value of chain_current_state
|
381 |
|
|
sc_signal<fc_chain_state> next_chain_current_state;
|
382 |
|
|
///The current state for sending posted packets that have chain bits
|
383 |
|
|
/** When sending a posted packet that has chain bit set, it means it is
|
384 |
|
|
a chain of packets that cannot be seperated by inserting other posted
|
385 |
|
|
packets, so we remember it by going in a chain state*/
|
386 |
|
|
sc_signal<fc_chain_state> chain_current_state;
|
387 |
|
|
|
388 |
|
|
///The next value curr_state will take (at rising edge of the clock)
|
389 |
|
|
sc_signal <fc_state> next_state;
|
390 |
|
|
///The current state of the flow_control_l3
|
391 |
|
|
sc_signal <fc_state> curr_state;
|
392 |
|
|
|
393 |
|
|
#ifdef RETRY_MODE_ENABLED
|
394 |
|
|
///Register to store that a retry disconnect has been initiated
|
395 |
|
|
sc_signal<bool> retry_disconnect_initiated;
|
396 |
|
|
///To clear the retry_disconnect_initiated signal
|
397 |
|
|
sc_signal<bool> clear_retry_disconnect_initiated;
|
398 |
|
|
|
399 |
|
|
///Register to store if we have received at least one ack (a nop packet) from
|
400 |
|
|
//the other link
|
401 |
|
|
/** It is important to wait for this to be set before replaying the history in
|
402 |
|
|
a retry sequence, to be sure that we start playing back the history at the right
|
403 |
|
|
position*/
|
404 |
|
|
sc_signal<bool> received_ack;
|
405 |
|
|
|
406 |
|
|
#endif
|
407 |
|
|
|
408 |
|
|
///Register to reserve a local fairness spot for a VC
|
409 |
|
|
sc_signal<bool> fairness_vc_reserved[3];
|
410 |
|
|
///next value of fairness_vc_reserved
|
411 |
|
|
sc_signal<bool> next_fairness_vc_reserved[3];
|
412 |
|
|
|
413 |
|
|
///Signals calculated by ::find_next_state()
|
414 |
|
|
//@{
|
415 |
|
|
sc_signal <fc_state> found_next_state;
|
416 |
|
|
sc_signal<bool> found_load_fwd_pkt;
|
417 |
|
|
sc_signal<bool> found_load_eh_pkt;
|
418 |
|
|
sc_signal<bool> found_load_csr_pkt;
|
419 |
|
|
sc_signal<bool> found_load_user_fifo_pkt;
|
420 |
|
|
sc_signal<bool> found_hold_user_fifo_pkt;
|
421 |
|
|
sc_signal<fc_chain_state> found_next_chain_current_state;
|
422 |
|
|
sc_signal<sc_bv<6> > found_current_sent_type;
|
423 |
|
|
sc_signal<sc_uint<4> > found_fc_ctr_mux;
|
424 |
|
|
sc_signal<bool> found_generate_disconnect_nop;
|
425 |
|
|
sc_signal<bool> found_fc_nop_sent;
|
426 |
|
|
sc_signal<VirtualChannel> found_fwd_vctype_db;
|
427 |
|
|
sc_signal<sc_uint<BUFFERS_ADDRESS_WIDTH> > found_fwd_address_db;
|
428 |
|
|
sc_signal<sc_uint<4> > found_next_data_cnt;
|
429 |
|
|
sc_signal<bool> found_next_has_data;
|
430 |
|
|
sc_signal<VirtualChannel> found_fc_data_vc_ui;
|
431 |
|
|
sc_signal<bool> found_local_packet_issued;
|
432 |
|
|
sc_signal<bool> found_next_fairness_vc_reserved[3];
|
433 |
|
|
|
434 |
|
|
#ifdef RETRY_MODE_ENABLED
|
435 |
|
|
sc_signal<sc_uint<5> > found_new_history_entry_size_m1;
|
436 |
|
|
sc_signal<bool > found_new_history_entry;
|
437 |
|
|
sc_signal<bool> found_next_calculate_crc;
|
438 |
|
|
sc_signal<bool> found_next_calculate_nop_crc;
|
439 |
|
|
#endif
|
440 |
|
|
//@}
|
441 |
|
|
|
442 |
|
|
#ifdef RETRY_MODE_ENABLED
|
443 |
|
|
|
444 |
|
|
///Signals calculated by ::find_next_retry_state()
|
445 |
|
|
//@{
|
446 |
|
|
sc_signal<sc_uint<4> > foundh_fc_ctr_mux;
|
447 |
|
|
sc_signal<bool> foundh_fc_nop_sent;
|
448 |
|
|
sc_signal<fc_state> foundh_next_state;
|
449 |
|
|
sc_signal<bool> foundh_next_fc_lctl_lk;
|
450 |
|
|
sc_signal<bool> foundh_next_fc_hctl_lk;
|
451 |
|
|
sc_signal<bool> foundh_next_calculate_nop_crc;
|
452 |
|
|
sc_signal<bool> foundh_next_calculate_crc;
|
453 |
|
|
sc_signal<sc_uint<4> > foundh_next_data_cnt;
|
454 |
|
|
sc_signal<bool> foundh_next_has_data;
|
455 |
|
|
sc_signal<sc_bv<6> > foundh_current_sent_type;
|
456 |
|
|
sc_signal<bool> foundh_consume_history;
|
457 |
|
|
sc_signal<bool> foundh_generate_disconnect_nop;
|
458 |
|
|
//@}
|
459 |
|
|
|
460 |
|
|
#endif
|
461 |
|
|
|
462 |
|
|
|
463 |
|
|
///The clocked process for the state machine
|
464 |
|
|
void fc_fsm_state( void );
|
465 |
|
|
///Finds the next state of the flow_control_l3
|
466 |
|
|
void fc_fsm( void );
|
467 |
|
|
///Verify that that type of packet can be sent to the other link
|
468 |
|
|
/**
|
469 |
|
|
@param vc The virtual channel to verify
|
470 |
|
|
@param data If we are looking at the data buffers. false for command buffers
|
471 |
|
|
@return If a packet of VirtulChannel vc and that does (data==true) or
|
472 |
|
|
does not(data==false) can be sent to the next HT node. The next HT node
|
473 |
|
|
must have enough free buffers to accept the packet
|
474 |
|
|
*/
|
475 |
|
|
bool verify_buffer_status (VirtualChannel vc , bool data);
|
476 |
|
|
///Find the one hot encoded value of what packet type is being sent
|
477 |
|
|
void set_found_sent_type (VirtualChannel vc , bool data);
|
478 |
|
|
///Find the next state to go in when a new packet has to be sent (combinatory process)
|
479 |
|
|
/** @description
|
480 |
|
|
This part needs a bit of explaining. The method find_next_state finds
|
481 |
|
|
what is the next thing we need to do when not in a retry sequence and
|
482 |
|
|
also finds the different outputs of the design. It is called after a
|
483 |
|
|
packet has finished being sent : we are ready so send a new packet.
|
484 |
|
|
|
485 |
|
|
This needs to be done at multiple places in the code. If the function
|
486 |
|
|
is called directly from the state machine, during synthesis, the function
|
487 |
|
|
will be embeded multiple times in the states machines. Since the method
|
488 |
|
|
is quite big, it really blows up the size of the final verilog or vhdl
|
489 |
|
|
code, making it VERY long to synthesize afterwards.
|
490 |
|
|
|
491 |
|
|
To cut back on this time, the method find_next_state is a combinatory process
|
492 |
|
|
which set signals named found_*, then the state machine can calls ::set_next_state()
|
493 |
|
|
to set the outputs to what was found in the next state. This way, only the
|
494 |
|
|
assignation is placed in the state machine during synthesis.
|
495 |
|
|
*/
|
496 |
|
|
void find_next_state();
|
497 |
|
|
///Set what ::find_next_state() has found
|
498 |
|
|
void set_next_state();
|
499 |
|
|
|
500 |
|
|
|
501 |
|
|
///Methods to go to specific state while also setting correct outputs
|
502 |
|
|
//@{
|
503 |
|
|
void go_NOP_SENT();
|
504 |
|
|
void go_NOP_SENT_IN_FWD();
|
505 |
|
|
void go_NOP_SENT_IN_USER();
|
506 |
|
|
void go_NOP_SENT_IN_EH();
|
507 |
|
|
void go_NOP_SENT_IN_CSR();
|
508 |
|
|
void go_FWD_DATA_SENT();
|
509 |
|
|
void go_USER_DATA_SENT();
|
510 |
|
|
void go_ERROR_DATA_SENT();
|
511 |
|
|
void go_CSR_DATA_SENT();
|
512 |
|
|
void go_LDTSTOP_DISCONNECT();
|
513 |
|
|
|
514 |
|
|
#ifdef RETRY_MODE_ENABLED
|
515 |
|
|
void go_RETRY_NOP_SENT();
|
516 |
|
|
void go_SEND_DATA_CRC();
|
517 |
|
|
void go_RETRY_NOP_SENT_IN_DATA();
|
518 |
|
|
void go_SEND_CMD_CRC();
|
519 |
|
|
void go_RETRY_SEND_CMD_CRC_DATA();
|
520 |
|
|
void go_RETRY_SEND_CMD_CRC();
|
521 |
|
|
void go_RETRY_DATA_SENT();
|
522 |
|
|
void go_RETRY_SEND_DISCONNECT();
|
523 |
|
|
void go_NOP_CRC_SENT_IN_FWD();
|
524 |
|
|
#endif
|
525 |
|
|
//@}
|
526 |
|
|
|
527 |
|
|
#ifdef RETRY_MODE_ENABLED
|
528 |
|
|
///Find the next state during retry mode(combinatory process)
|
529 |
|
|
/**
|
530 |
|
|
@description This is the equivalent of the ::find_next_state() ,
|
531 |
|
|
except that it is for when we are in a retry sequence
|
532 |
|
|
*/
|
533 |
|
|
void find_next_retry_state();
|
534 |
|
|
///Set what ::find_next_retry_state() has found
|
535 |
|
|
void go_next_retry_state();
|
536 |
|
|
///Find the one hot encoded value of what packet type is being sent
|
537 |
|
|
void set_foundh_sent_type (VirtualChannel vc , bool data);
|
538 |
|
|
#endif
|
539 |
|
|
|
540 |
|
|
///SystemC Macro
|
541 |
|
|
SC_HAS_PROCESS(flow_control_l3);
|
542 |
|
|
|
543 |
|
|
///Macro CTOR SystemC - flow_control_l3 constructor
|
544 |
|
|
flow_control_l3(sc_module_name name);
|
545 |
|
|
};
|
546 |
|
|
|
547 |
|
|
#endif
|