OpenCores
URL https://opencores.org/ocsvn/ht_tunnel/ht_tunnel/trunk

Subversion Repositories ht_tunnel

[/] [ht_tunnel/] [trunk/] [rtl/] [systemc/] [flow_control_l2/] [flow_control_l2.cpp] - Blame information for rev 19

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 acastong
//flow_control_l2.cpp
2
 
3
/* ***** BEGIN LICENSE BLOCK *****
4
 * Version: MPL 1.1
5
 *
6
 * The contents of this file are subject to the Mozilla Public License Version
7
 * 1.1 (the "License"); you may not use this file except in compliance with
8
 * the License. You may obtain a copy of the License at
9
 * http://www.mozilla.org/MPL/
10
 *
11
 * Software distributed under the License is distributed on an "AS IS" basis,
12
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13
 * for the specific language governing rights and limitations under the
14
 * License.
15
 *
16
 * The Original Code is HyperTransport Tunnel IP Core.
17
 *
18
 * The Initial Developer of the Original Code is
19
 * Ecole Polytechnique de Montreal.
20
 * Portions created by the Initial Developer are Copyright (C) 2005
21
 * the Initial Developer. All Rights Reserved.
22
 *
23
 * Contributor(s):
24
 *   Jean-Francois Belanger
25
 *   Ami Castonguay <acastong@grm.polymtl.ca>
26
 *
27
 * Alternatively, the contents of this file may be used under the terms
28
 * of the Polytechnique HyperTransport Tunnel IP Core Source Code License
29
 * (the  "PHTICSCL License", see the file PHTICSCL.txt), in which case the
30
 * provisions of PHTICSCL License are applicable instead of those
31
 * above. If you wish to allow use of your version of this file only
32
 * under the terms of the PHTICSCL License and not to allow others to use
33
 * your version of this file under the MPL, indicate your decision by
34
 * deleting the provisions above and replace them with the notice and
35
 * other provisions required by the PHTICSCL License. If you do not delete
36
 * the provisions above, a recipient may use your version of this file
37
 * under either the MPL or the PHTICSCL License."
38
 *
39
 * ***** END LICENSE BLOCK ***** */
40
 
41
#include "flow_control_l2.h"
42
#include "flow_control_l3.h"
43
#include "nop_framer_l3.h"
44
#include "multiplexer_l3.h"
45
#include "rx_farend_cnt_l3.h"
46
#include "user_fifo_l3.h"
47
#include "fairness_l3.h"
48
 
49
#ifdef RETRY_MODE_ENABLED
50
#include "history_buffer_l3.h"
51
#include "fc_packet_crc_l3.h"
52
#endif
53
/**  *************************************************************
54
This file contain the linking of all submodule of flow_control
55
*************************************************************
56
**/
57
 
58
flow_control_l2::flow_control_l2(sc_module_name name) : sc_module(name)
59
{
60
 
61
#ifdef RETRY_MODE_ENABLED
62
        SC_METHOD(send_clear_single_error_and_stomp);
63
        sensitive << clear_crc << clear_nop_crc;
64
#endif
65
 
66
        the_flow_control = new flow_control_l3("the_flow_control_l3");
67
 
68
        //      Linking of the flow control state-machine sub module
69
 
70
 
71
        //************ THE FLOW CONTROL ******************
72
 
73
        //Signals to internal FIFO
74
        the_flow_control->fifo_user_available(fifo_user_available);                             //fifo have a packet to send
75
        the_flow_control->fifo_user_packet(fifo_user_packet);
76
        the_flow_control->fifo_user_packet_vc(fifo_user_packet_vc);
77
        the_flow_control->fifo_user_packet_dword(fifo_user_packet_dword);
78
        the_flow_control->fifo_user_packet_data_asociated(fifo_user_packet_data_asociated);
79
#ifdef RETRY_MODE_ENABLED
80
        the_flow_control->fifo_user_packet_command(fifo_user_packet_command);
81
#endif
82
        the_flow_control->fifo_user_packet_data_count_m1(fifo_user_packet_data_count_m1);
83
        the_flow_control->fifo_user_packet_isChain(fifo_user_packet_isChain);
84
        the_flow_control->consume_user_fifo(consume_user_fifo);                 //acknowledge signal    
85
        the_flow_control->hold_user_fifo(hold_user_fifo);               //acknowledge signal    
86
 
87
        //Signals to error handler
88
        the_flow_control->fc_ack_eh(fc_ack_eh);
89
        the_flow_control->eh_cmd_data_fc(eh_cmd_data_fc);
90
        the_flow_control->eh_available_fc(eh_available_fc);
91
 
92
 
93
        //Signals to CSR
94
        the_flow_control->fc_ack_csr(fc_ack_csr);
95
        the_flow_control->csr_dword_fc(csr_dword_fc);
96
        the_flow_control->csr_available_fc(csr_available_fc);
97
 
98
 
99
 
100
        //Signals to Reordering
101
        the_flow_control->ro_available_fwd(ro_available_fwd);           //RO have a packet to send
102
        the_flow_control->ro_nop_req_fc(ro_nop_req_fc);
103
        the_flow_control->ro_packet_fwd(ro_packet_fwd);
104
        the_flow_control->ro_packet_vc_fwd(ro_packet_vc_fwd);
105
        the_flow_control->fwd_ack_ro(fwd_ack_ro);               //acknowledge signal
106
 
107
 
108
        //Signals to User Interface
109
        the_flow_control->fc_data_vc_ui(fc_data_vc_ui);         //dant state Local_cmd_sent
110
        the_flow_control->fc_consume_data_ui(fc_consume_data_ui);                               //data consumme
111
 
112
 
113
        //Signals from databuffer from this side   
114
        the_flow_control->db_nop_req_fc(db_nop_req_fc);
115
 
116
 
117
        //Signals from databuffer from other side   
118
        the_flow_control->fwd_address_db(fwd_address_db);
119
        the_flow_control->fwd_vctype_db(fwd_vctype_db);
120
        the_flow_control->fwd_read_db(fwd_read_db);
121
        the_flow_control->fwd_erase_db(fwd_erase_db);
122
 
123
        //Signals from nop_framer
124
        the_flow_control->nop_next_to_send(nop_next_to_send);
125
        the_flow_control->generate_disconnect_nop(generate_disconnect_nop);
126
        the_flow_control->has_nop_buffers_to_send(has_nop_buffers_to_send);
127
 
128
 
129
        //Signals to rx_farend_cnt
130
        the_flow_control->current_sent_type(current_sent_type);
131
        the_flow_control->fwd_next_node_buffer_status_ro(fwd_next_node_buffer_status_ro);
132
#ifdef RETRY_MODE_ENABLED
133
        the_flow_control->clear_farend_count(clear_farend_count);
134
#endif
135
 
136
        //Signal for output selection (Multiplexer)
137
        the_flow_control->fc_ctr_mux(fc_ctr_mux);
138
 
139
        //Signals to link
140
        the_flow_control->fc_lctl_lk(fc_lctl_lk);
141
        the_flow_control->fc_hctl_lk(fc_hctl_lk);
142
        the_flow_control->lk_consume_fc(lk_consume_fc);
143
#ifdef RETRY_MODE_ENABLED
144
        the_flow_control->lk_rx_connected(lk_rx_connected);
145
        the_flow_control->fc_disconnect_lk(fc_disconnect_lk);
146
        the_flow_control->lk_initiate_retry_disconnect(lk_initiate_retry_disconnect);
147
        //Signals to command decoder
148
        the_flow_control->cd_initiate_retry_disconnect(cd_initiate_retry_disconnect);
149
        the_flow_control->csr_retry(csr_retry);
150
#endif  
151
 
152
        //Signals to fairness
153
        the_flow_control->local_priority(local_priority);
154
        the_flow_control->local_packet_issued(local_packet_issued);
155
 
156
 
157
        //Misc signals
158
        the_flow_control->clock(clk);
159
        the_flow_control->resetx(resetx);
160
        the_flow_control->ldtstopx(ldtstopx);
161
        the_flow_control->fc_nop_sent(fc_nop_sent);
162
        the_flow_control->nop_received(cd_nop_received_fc);
163
 
164
 
165
 
166
 
167
#ifdef RETRY_MODE_ENABLED
168
        //History signals
169
        the_flow_control->history_packet(history_packet);
170
 
171
        the_flow_control->history_playback_done(history_playback_done);
172
        the_flow_control->begin_history_playback(begin_history_playback);
173
        the_flow_control->stop_history_playback(stop_history_playback);
174
        the_flow_control->consume_history(consume_history);
175
 
176
        the_flow_control->room_available_in_history(room_available_in_history);
177
 
178
        the_flow_control->add_to_history(add_to_history);
179
        the_flow_control->new_history_entry(new_history_entry);
180
        the_flow_control->new_history_entry_size_m1(new_history_entry_size_m1);
181
        the_flow_control->history_playback_ready(history_playback_ready);
182
 
183
        //Signals to CRC unit
184
        the_flow_control->calculate_crc(calculate_crc);
185
        the_flow_control->clear_crc(clear_crc);
186
        the_flow_control->calculate_nop_crc(calculate_nop_crc);
187
        the_flow_control->clear_nop_crc(clear_nop_crc);
188
 
189
        the_flow_control->select_crc_output(select_crc_output);
190
        the_flow_control->select_nop_crc_output(select_nop_crc_output);
191
#endif  
192
 
193
 
194
 
195
 
196
        //*********************************
197
        //Linking of the nop_framer module
198
        //*********************************
199
 
200
        the_nop_framer = new nop_framer_l3("the_nop_framer");
201
 
202
        the_nop_framer->db_buffer_cnt_fc(db_buffer_cnt_fc);
203
        the_nop_framer->ro_buffer_cnt_fc(ro_buffer_cnt_fc);
204
        the_nop_framer->ro_nop_req_fc(ro_nop_req_fc);
205
        the_nop_framer->db_nop_req_fc(db_nop_req_fc);
206
        the_nop_framer->generate_disconnect_nop(generate_disconnect_nop);
207
        the_nop_framer->has_nop_buffers_to_send(has_nop_buffers_to_send);
208
        the_nop_framer->ht_nop_pkt(ht_nop_pkt);
209
        the_nop_framer->fc_nop_sent(fc_nop_sent);
210
#ifdef RETRY_MODE_ENABLED
211
        the_nop_framer->cd_rx_next_pkt_to_ack_fc(cd_rx_next_pkt_to_ack_fc);
212
        the_nop_framer->csr_retry(csr_retry);
213
#endif  
214
        the_nop_framer->resetx(resetx);
215
        the_nop_framer->clock(clk);
216
        the_nop_framer->nop_next_to_send(nop_next_to_send);
217
 
218
        //Linking of the multiplexer module
219
 
220
        the_multiplexer = new multiplexer_l3("the_multiplexer");
221
        the_multiplexer->fc_ctr_mux(fc_ctr_mux);
222
        the_multiplexer->resetx(resetx);
223
        the_multiplexer->clk(clk);
224
        the_multiplexer->fc_dword_lk(fc_dword_lk);
225
        the_multiplexer->ht_nop_pkt(ht_nop_pkt);                                                //0
226
        the_multiplexer->fwd_packet(ro_packet_fwd);                     //1-2
227
        the_multiplexer->db_data_fwd(db_data_fwd);                                              //3
228
        the_multiplexer->eh_cmd_data_fc(eh_cmd_data_fc);                        //4
229
        the_multiplexer->csr_dword_fc(csr_dword_fc);                    //5
230
        the_multiplexer->user_packet(fifo_user_packet);                  //6-7
231
        the_multiplexer->ui_data_fc(ui_data_fc);
232
#ifdef RETRY_MODE_ENABLED
233
        the_multiplexer->history_packet(history_packet);
234
        the_multiplexer->crc_output(crc_output);
235
        the_multiplexer->nop_crc_output(nop_crc_output);
236
        the_multiplexer->select_crc_output(select_crc_output);
237
        the_multiplexer->select_nop_crc_output(select_nop_crc_output);
238
        the_multiplexer->registered_output(mux_registered_output);
239
#endif
240
 
241
        /**
242
        Linking of the rx_farend_cnd module
243
        This module is used to trace the amount of buffer that are free
244
        in the command and data buffer of a far end HT interface.
245
 
246
        **/
247
 
248
        the_rx_farend_cnt = new rx_farend_cnt_l3("the_rx_farend_cnt");
249
 
250
        the_rx_farend_cnt->cd_nopinfo_fc(cd_nopinfo_fc);
251
        the_rx_farend_cnt->cd_nop_received_fc(cd_nop_received_fc);
252
        the_rx_farend_cnt->resetx(resetx);
253
        the_rx_farend_cnt->clock(clk);
254
        the_rx_farend_cnt->fwd_next_node_buffer_status_ro(fwd_next_node_buffer_status_ro);
255
        the_rx_farend_cnt->current_sent_type(current_sent_type);
256
#ifdef RETRY_MODE_ENABLED
257
        the_rx_farend_cnt->clear_farend_count(clear_farend_count);
258
#endif  
259
 
260
        /**
261
        Linking of the user_fifo module
262
 
263
        **/
264
        the_user_fifo = new user_fifo_l3("the_user_fifo");
265
 
266
 
267
        the_user_fifo->fc_user_fifo_ge2_ui(fc_user_fifo_ge2_ui);
268
        the_user_fifo->ui_available_fc(ui_available_fc);
269
        the_user_fifo->ui_packet_fc(ui_packet_fc);
270
        the_user_fifo->clock(clk);
271
        the_user_fifo->resetx(resetx);
272
        the_user_fifo->fifo_user_packet(fifo_user_packet);
273
        the_user_fifo->fifo_user_packet_vc(fifo_user_packet_vc);
274
        the_user_fifo->fifo_user_packet_dword(fifo_user_packet_dword);
275
        the_user_fifo->fifo_user_packet_data_asociated(fifo_user_packet_data_asociated);
276
#ifdef RETRY_MODE_ENABLED
277
        the_user_fifo->fifo_user_packet_command(fifo_user_packet_command);
278
#endif
279
        the_user_fifo->fifo_user_packet_data_count_m1(fifo_user_packet_data_count_m1);
280
        the_user_fifo->fifo_user_packet_isChain(fifo_user_packet_isChain);
281
 
282
        the_user_fifo->fwd_next_node_buffer_status_ro(fwd_next_node_buffer_status_ro);
283
        the_user_fifo->fifo_user_available(fifo_user_available);
284
        the_user_fifo->consume_user_fifo(consume_user_fifo);
285
        the_user_fifo->hold_user_fifo(hold_user_fifo);
286
 
287
        /**
288
        Linking of the fairness algorithm module
289
        */
290
 
291
        the_fairness = new fairness_l3("the_fairness_l3");
292
        the_fairness->clk(clk);
293
        the_fairness->resetx(resetx);
294
        the_fairness->ro_available_fwd(ro_available_fwd);
295
        the_fairness->ro_packet_fwd(ro_packet_fwd);
296
        the_fairness->fwd_ack_ro(fwd_ack_ro);
297
        the_fairness->local_priority(local_priority);
298
        the_fairness->local_packet_issued(local_packet_issued);
299
 
300
 
301
#ifdef RETRY_MODE_ENABLED
302
        /** Link to the CRC unit */
303
        the_fc_packet_crc = new fc_packet_crc_l3("the_fc_packet_crc");
304
 
305
        the_fc_packet_crc->clk(clk);
306
        the_fc_packet_crc->resetx(resetx);
307
 
308
        the_fc_packet_crc->data_in(mux_registered_output);
309
        the_fc_packet_crc->fc_hctl_lk(fc_hctl_lk);
310
        the_fc_packet_crc->fc_lctl_lk(fc_lctl_lk);
311
 
312
        the_fc_packet_crc->calculate_crc(calculate_crc);
313
        the_fc_packet_crc->clear_crc(clear_crc);
314
        the_fc_packet_crc->calculate_nop_crc(calculate_nop_crc);
315
        the_fc_packet_crc->clear_nop_crc(clear_nop_crc);
316
        the_fc_packet_crc->crc_output(crc_output);
317
        the_fc_packet_crc->nop_crc_output(nop_crc_output);
318
        the_fc_packet_crc->csr_force_single_stomp_fc(csr_force_single_stomp_fc);
319
        the_fc_packet_crc->csr_force_single_error_fc(csr_force_single_error_fc);
320
 
321
 
322
        /** Link to the history buffer */
323
        the_history_buffer = new history_buffer_l3("the_history_buffer");
324
 
325
        the_history_buffer->ack_value(cd_nop_ack_value_fc);
326
        the_history_buffer->add_to_history(add_to_history);
327
        the_history_buffer->begin_history_playback(begin_history_playback);
328
        the_history_buffer->stop_history_playback(stop_history_playback);
329
        the_history_buffer->clk(clk);
330
        the_history_buffer->consume_history(consume_history);
331 14 acastong
        the_history_buffer->mux_registered_output(mux_registered_output);
332 2 acastong
        the_history_buffer->history_packet(history_packet);
333
        the_history_buffer->history_playback_done(history_playback_done);
334
        the_history_buffer->new_history_entry(new_history_entry);
335
        the_history_buffer->new_history_entry_size_m1(new_history_entry_size_m1);
336
        the_history_buffer->nop_received(cd_nop_received_fc);
337
        the_history_buffer->resetx(resetx);
338
        the_history_buffer->room_available_in_history(room_available_in_history);
339
        the_history_buffer->history_memory_write(history_memory_write);
340
        the_history_buffer->history_memory_write_address(history_memory_write_address);
341
        the_history_buffer->history_memory_write_data(history_memory_write_data);
342
        the_history_buffer->history_memory_read_address(history_memory_read_address);
343
        the_history_buffer->history_memory_output(history_memory_output);
344
        the_history_buffer->history_playback_ready(history_playback_ready);
345
#endif  
346
}
347
 
348
#ifdef RETRY_MODE_ENABLED
349
void flow_control_l2::send_clear_single_error_and_stomp(){
350
        fc_clear_single_error_csr = clear_crc.read() || clear_nop_crc.read();
351
        fc_clear_single_stomp_csr =     clear_crc.read();
352
}
353
#endif  
354
 
355
 
356
#ifdef SYSTEMC_SIM
357
flow_control_l2::~flow_control_l2(){
358
                delete the_flow_control;
359
                delete the_nop_framer;
360
                delete the_multiplexer;
361
                delete the_rx_farend_cnt;
362
                delete the_user_fifo;
363
#ifdef RETRY_MODE_ENABLED
364
                delete the_fc_packet_crc;
365
                delete the_history_buffer;
366
#endif  
367
        }
368
#endif

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.