1 |
2 |
acastong |
//final_reordering_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 |
|
|
* Ami Castonguay <acastong@grm.polymtl.ca>
|
24 |
|
|
* Laurent Aubray
|
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 |
|
|
#ifndef FINAL_REORDERING_L3_H
|
41 |
|
|
#define FINAL_REORDERING_L3_H
|
42 |
|
|
|
43 |
|
|
#include "../core_synth/synth_datatypes.h"
|
44 |
|
|
#include "../core_synth/constants.h"
|
45 |
|
|
|
46 |
|
|
/*
|
47 |
|
|
bit 5 = There is space in the PC VC
|
48 |
|
|
bit 4 = There is space in the PC data VC
|
49 |
|
|
bit 3 = There is space in the NPC VC
|
50 |
|
|
bit 2 = There is space in the NPC data VC
|
51 |
|
|
bit 1 = There is space in the R VC
|
52 |
|
|
bit 0 = There is space in the R data VC
|
53 |
|
|
*/
|
54 |
|
|
|
55 |
|
|
#define BIT_PC_FREE 5
|
56 |
|
|
#define BIT_PC_FREE_DATA 4
|
57 |
|
|
#define BIT_NPC_FREE 3
|
58 |
|
|
#define BIT_NPC_FREE_DATA 2
|
59 |
|
|
#define BIT_RC_FREE 1
|
60 |
|
|
#define BIT_RC_FREE_DATA 0
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
/// Sends the most important packet to the User, CSR and FC
|
64 |
|
|
/** This module is the last module of Reordering. All virtual
|
65 |
|
|
channels are sending use their highest priority packet for
|
66 |
|
|
every destination. This last modules chooses one packet
|
67 |
|
|
for every distination*/
|
68 |
|
|
class final_reordering_l3 : public sc_module
|
69 |
|
|
{
|
70 |
|
|
|
71 |
|
|
public:
|
72 |
|
|
///Main clock of the system
|
73 |
|
|
sc_in<bool> clk;
|
74 |
|
|
///Low logic reset signal
|
75 |
|
|
sc_in<bool> resetx;
|
76 |
|
|
|
77 |
|
|
|
78 |
|
|
|
79 |
|
|
//***********************************
|
80 |
|
|
// Control signal from Flow Control
|
81 |
|
|
//***********************************
|
82 |
|
|
|
83 |
|
|
/// Contains information about the Command buffers of the upper module.
|
84 |
|
|
/**A set bit indicates:
|
85 |
|
|
bit 5 = There is space in the PC VC
|
86 |
|
|
bit 4 = There is space in the PC data VC
|
87 |
|
|
bit 3 = There is space in the NPC VC
|
88 |
|
|
bit 2 = There is space in the NPC data VC
|
89 |
|
|
bit 1 = There is space in the R VC
|
90 |
|
|
bit 0 = There is space in the R data VC
|
91 |
|
|
A command packet cannot be sent if ther is room in both data and command
|
92 |
|
|
buffers of the upper module*/
|
93 |
|
|
sc_in<sc_bv<6> > fwd_next_node_buffer_status_ro;//24
|
94 |
|
|
|
95 |
|
|
|
96 |
|
|
//***********************************
|
97 |
|
|
// Interface with VCs
|
98 |
|
|
//***********************************
|
99 |
|
|
|
100 |
|
|
/// Packets Received from the differents VCs.
|
101 |
|
|
/** The most important packet is then chosen for each output modules.
|
102 |
|
|
YY_Packet_XX -> YY means the VC that sends the packet, XX the destination
|
103 |
|
|
of the packet*/
|
104 |
|
|
sc_in<syn_ControlPacketComplete> fetched_packet[2];
|
105 |
|
|
|
106 |
|
|
//Decoded virtual channel of the fetched packet
|
107 |
|
|
sc_in<VirtualChannel> fetched_packet_vc[2];
|
108 |
|
|
|
109 |
|
|
/// Indicates if a packet is available on the input packet signal
|
110 |
|
|
sc_in<bool> fetched_packet_available[2];
|
111 |
|
|
|
112 |
|
|
sc_in<sc_uint<LOG2_NB_OF_BUFFERS+1> > fetched_packet_nposted_refid[2];
|
113 |
|
|
sc_in<sc_uint<LOG2_NB_OF_BUFFERS+1> > fetched_packet_response_refid[2];
|
114 |
|
|
|
115 |
|
|
/// Request the different types of packets from the VCs
|
116 |
|
|
/** */
|
117 |
|
|
//@{
|
118 |
|
|
sc_out<bool> posted_requested[2];
|
119 |
|
|
sc_out<bool> nposted_requested[2];
|
120 |
|
|
sc_out<bool> response_requested[2];
|
121 |
|
|
//@}
|
122 |
|
|
|
123 |
|
|
//***********************************
|
124 |
|
|
// Interface with CSR, User and FC
|
125 |
|
|
//***********************************
|
126 |
|
|
|
127 |
|
|
sc_out<syn_ControlPacketComplete> out_packet_accepted;
|
128 |
|
|
/// Packet sent to the FC module
|
129 |
|
|
sc_out<syn_ControlPacketComplete> out_packet_fwd;
|
130 |
|
|
sc_out<VirtualChannel> out_packet_vc_fwd;
|
131 |
|
|
|
132 |
|
|
/// Indicates if a packet is available on the CSR output port
|
133 |
|
|
sc_out<bool> out_packet_available_csr;
|
134 |
|
|
/// Indicates if a packet is available on the User output port
|
135 |
|
|
sc_out<bool> out_packet_available_ui;
|
136 |
|
|
/// Indicates if a packet is available on the FC output port
|
137 |
|
|
sc_out<bool> out_packet_available_fwd;
|
138 |
|
|
|
139 |
|
|
/// Acknowledge signal form the CSR, User and FC modules
|
140 |
|
|
/** Indicates if the sent packet will be consummed by the module
|
141 |
|
|
If the Acknowledge signal is not set, the packet will not be consummed and thus
|
142 |
|
|
must stay in the VC.*/
|
143 |
|
|
sc_in<bool> ack[3];
|
144 |
|
|
|
145 |
|
|
/**If the cd is currently receiving data. This is used to know if a packet
|
146 |
|
|
that has associated data can be sent*/
|
147 |
|
|
sc_in<bool> cd_data_pending_ro;
|
148 |
|
|
/**Where the cd is storing data. This is used to know if a packet
|
149 |
|
|
that has associated data can be sent*/
|
150 |
|
|
sc_in<sc_uint<BUFFERS_ADDRESS_WIDTH> > cd_data_pending_addr_ro;
|
151 |
|
|
|
152 |
|
|
///If we are currently in sync mode
|
153 |
|
|
sc_in<bool> csr_sync;
|
154 |
|
|
|
155 |
|
|
/**
|
156 |
|
|
Register what was done last cycle
|
157 |
|
|
*/
|
158 |
|
|
sc_signal<sc_bv<3> > registered_accepted_vc_decoded;
|
159 |
|
|
sc_signal<sc_bv<3> > registered_rejected_vc_decoded;
|
160 |
|
|
sc_signal<bool> registered_ack_rejected;
|
161 |
|
|
sc_signal<bool> registered_ack_accepted;
|
162 |
|
|
|
163 |
|
|
|
164 |
|
|
/**
|
165 |
|
|
With two buffers, it is possible to send a packet every TWO cycles. If
|
166 |
|
|
we try to output a packet every cycle, we might empty a buffer of a
|
167 |
|
|
vc. This MUST NOT happen or we might break an ordering rule. To output
|
168 |
|
|
a packet every cycle, buffers must have a depth of 3 (at least the posted
|
169 |
|
|
VC needs it)!
|
170 |
|
|
*/
|
171 |
|
|
|
172 |
|
|
sc_signal<syn_ControlPacketComplete> posted_packet_buffer_accepted[2];
|
173 |
|
|
sc_signal<sc_uint<MAX_PASSPW_P1_LOG2_COUNT> > posted_packet_wait_count_accepted[2];
|
174 |
|
|
sc_signal<bool> posted_packet_buffer_accepted_loaded[2];
|
175 |
|
|
sc_signal<sc_uint<LOG2_NB_OF_BUFFERS+1> > posted_packet_buffer_accepted_nposted_refid[2];
|
176 |
|
|
sc_signal<sc_uint<LOG2_NB_OF_BUFFERS+1> > posted_packet_buffer_accepted_response_refid[2];
|
177 |
|
|
|
178 |
|
|
sc_signal<syn_ControlPacketComplete> nposted_packet_buffer_accepted[2];
|
179 |
|
|
sc_signal<sc_uint<MAX_PASSPW_P1_LOG2_COUNT> > nposted_packet_wait_count_accepted[2];
|
180 |
|
|
sc_signal<bool> nposted_packet_buffer_accepted_loaded[2];
|
181 |
|
|
sc_signal<sc_uint<LOG2_NB_OF_BUFFERS+1> > nposted_packet_buffer_accepted_refid[2];
|
182 |
|
|
|
183 |
|
|
sc_signal<syn_ResponseControlPacketComplete> response_packet_buffer_accepted[2];
|
184 |
|
|
sc_signal<sc_uint<MAX_PASSPW_P1_LOG2_COUNT> > response_packet_wait_count_accepted[2];
|
185 |
|
|
sc_signal<bool> response_packet_buffer_accepted_loaded[2];
|
186 |
|
|
sc_signal<sc_uint<LOG2_NB_OF_BUFFERS+1> > response_packet_buffer_accepted_refid[2];
|
187 |
|
|
|
188 |
|
|
/// Packet sent to the FC module
|
189 |
|
|
sc_signal<syn_ControlPacketComplete> posted_packet_buffer_rejected[2];
|
190 |
|
|
sc_signal<sc_uint<MAX_PASSPW_P1_LOG2_COUNT> > posted_packet_wait_count_rejected[2];
|
191 |
|
|
sc_signal<bool> posted_packet_buffer_rejected_loaded[2];
|
192 |
|
|
sc_signal<sc_uint<LOG2_NB_OF_BUFFERS+1> > posted_packet_buffer_rejected_nposted_refid[2];
|
193 |
|
|
sc_signal<sc_uint<LOG2_NB_OF_BUFFERS+1> > posted_packet_buffer_rejected_response_refid[2];
|
194 |
|
|
|
195 |
|
|
sc_signal<syn_ControlPacketComplete> nposted_packet_buffer_rejected[2];
|
196 |
|
|
sc_signal<sc_uint<MAX_PASSPW_P1_LOG2_COUNT> > nposted_packet_wait_count_rejected[2];
|
197 |
|
|
sc_signal<bool> nposted_packet_buffer_rejected_loaded[2];
|
198 |
|
|
sc_signal<sc_uint<LOG2_NB_OF_BUFFERS+1> > nposted_packet_buffer_rejected_refid[2];
|
199 |
|
|
|
200 |
|
|
sc_signal<syn_ResponseControlPacketComplete> response_packet_buffer_rejected[2];
|
201 |
|
|
sc_signal<sc_uint<MAX_PASSPW_P1_LOG2_COUNT> > response_packet_wait_count_rejected[2];
|
202 |
|
|
sc_signal<bool> response_packet_buffer_rejected_loaded[2];
|
203 |
|
|
sc_signal<sc_uint<LOG2_NB_OF_BUFFERS+1> > response_packet_buffer_rejected_refid[2];
|
204 |
|
|
|
205 |
|
|
|
206 |
|
|
sc_signal<bool> rejected_output_loaded;
|
207 |
|
|
sc_signal<bool> accepted_output_loaded;
|
208 |
|
|
|
209 |
|
|
///If there is a valid packet in the accepted output register
|
210 |
|
|
sc_signal<sc_bv<3> > accepted_vc_decoded;
|
211 |
|
|
///If there is a valid packet in the forward output register
|
212 |
|
|
sc_signal<sc_bv<3> > rejected_vc_decoded;
|
213 |
|
|
|
214 |
|
|
|
215 |
|
|
sc_signal<syn_ControlPacketComplete> rc_packet_rejected;
|
216 |
|
|
sc_signal<bool> rc_packet_rejected_maxwait_reached;
|
217 |
|
|
sc_signal<syn_ControlPacketComplete> pc_packet_rejected;
|
218 |
|
|
sc_signal<bool> pc_packet_rejected_maxwait_reached;
|
219 |
|
|
sc_signal<syn_ControlPacketComplete> npc_packet_rejected;
|
220 |
|
|
sc_signal<bool> npc_packet_rejected_maxwait_reached;
|
221 |
|
|
|
222 |
|
|
sc_signal<syn_ControlPacketComplete> rc_packet_accepted;
|
223 |
|
|
sc_signal<bool> rc_packet_accepted_maxwait_reached;
|
224 |
|
|
sc_signal<syn_ControlPacketComplete> pc_packet_accepted;
|
225 |
|
|
sc_signal<bool> pc_packet_accepted_maxwait_reached;
|
226 |
|
|
sc_signal<syn_ControlPacketComplete> npc_packet_accepted;
|
227 |
|
|
sc_signal<bool> npc_packet_accepted_maxwait_reached;
|
228 |
|
|
|
229 |
|
|
void clocked_process();
|
230 |
|
|
///Choose the packet to be sent to the CSR/CSR
|
231 |
|
|
void doFinalReorderingAccepted();
|
232 |
|
|
///Choose the packet to be sent to the FWD/EH
|
233 |
|
|
void doFinalReorderingFWD();
|
234 |
|
|
|
235 |
|
|
void updateBufferContent();
|
236 |
|
|
void output_request();
|
237 |
|
|
|
238 |
|
|
///Verify if an accepted packet goes to the CSR
|
239 |
|
|
/**
|
240 |
|
|
@param pkt The packet to check
|
241 |
|
|
@return true if the accepted packet goes to CSR
|
242 |
|
|
*/
|
243 |
|
|
bool request_goes_to_csr(const sc_bv<64> &pkt) const;
|
244 |
|
|
|
245 |
|
|
void find_next_packet_buf_workaround();
|
246 |
|
|
|
247 |
|
|
//SystemC Macro
|
248 |
|
|
SC_HAS_PROCESS(final_reordering_l3);
|
249 |
|
|
|
250 |
|
|
/// Main constructor.
|
251 |
|
|
final_reordering_l3(sc_module_name name);
|
252 |
|
|
|
253 |
|
|
};
|
254 |
|
|
|
255 |
|
|
|
256 |
|
|
#endif
|
257 |
|
|
|