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

Subversion Repositories ht_tunnel

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 acastong
//fetch_packet_l3.cpp
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
 *
25
 * Alternatively, the contents of this file may be used under the terms
26
 * of the Polytechnique HyperTransport Tunnel IP Core Source Code License
27
 * (the  "PHTICSCL License", see the file PHTICSCL.txt), in which case the
28
 * provisions of PHTICSCL License are applicable instead of those
29
 * above. If you wish to allow use of your version of this file only
30
 * under the terms of the PHTICSCL License and not to allow others to use
31
 * your version of this file under the MPL, indicate your decision by
32
 * deleting the provisions above and replace them with the notice and
33
 * other provisions required by the PHTICSCL License. If you do not delete
34
 * the provisions above, a recipient may use your version of this file
35
 * under either the MPL or the PHTICSCL License."
36
 *
37
 * ***** END LICENSE BLOCK ***** */
38
 
39
#include "fetch_packet_l3.h"
40
 
41
fetch_packet_l3::fetch_packet_l3(sc_module_name name) : sc_module(name){
42
        SC_METHOD(register_signals);
43
        sensitive_pos(clk);
44
        sensitive_neg(resetx);
45
 
46
        SC_METHOD(select_and_ack_packet);
47
        for(int destination = 0; destination < 2; destination++){
48
                sensitive << posted_available[destination]
49
                                  << nposted_available[destination]
50
                                  << response_available[destination]
51
                                  << posted_requested[destination]
52
                                  << nposted_requested[destination]
53
                                  << response_requested[destination]
54
                                  << posted_packet_addr[destination]
55
                                  << nposted_packet_addr[destination]
56
                                  << response_packet_addr[destination];
57
        }
58
 
59
        SC_METHOD(reconstruct_packet);
60
        sensitive << command_packet_rd_data_ro[0] << command_packet_rd_data_ro[1]
61
#ifdef ENABLE_REORDERING
62
                          << packet_passpw[0] << packet_passpw[1]
63
                          << packet_seqid[0] << packet_seqid[1]
64
                          << packet_chain[0] << packet_chain[1]
65
#endif
66
                          << packet_vc[0] << packet_vc[0]
67
                          << packet_fetched[0] << packet_fetched[1];
68
 
69
}
70
 
71
void fetch_packet_l3::select_and_ack_packet(){
72
        for(int destination = 0; destination < 2; destination++){
73
                sc_uint<LOG2_NB_OF_BUFFERS+2> ro_command_packet_rd_addr_tmp;
74
 
75
                //Some default values for outputs
76
                ack_posted[destination] = false;
77
                ack_nposted[destination] = false;
78
                ack_response[destination] = false;
79
                selected_vc[destination] = VC_NONE;
80
                packet_selected[destination] = false;
81
                ro_command_packet_rd_addr_tmp = 0;
82
 
83
                //Retrieve posted packets first, if there is a packet of that type available
84
                //and it is being requested
85
                if(posted_requested[destination].read() && posted_available[destination].read()){
86
                        ack_posted[destination] = true;
87
                        selected_vc[destination] = VC_POSTED;
88
                        packet_selected[destination] = true;
89
                        ro_command_packet_rd_addr_tmp.range(LOG2_NB_OF_BUFFERS+1,LOG2_NB_OF_BUFFERS) = VC_POSTED;
90
                        ro_command_packet_rd_addr_tmp.range(LOG2_NB_OF_BUFFERS-1,0) = posted_packet_addr[destination];
91
                }
92
                //Then responses
93
                else if(response_requested[destination].read() && response_available[destination].read()){
94
                        ack_response[destination] = true;
95
                        selected_vc[destination] = VC_RESPONSE;
96
                        packet_selected[destination] = true;
97
                        ro_command_packet_rd_addr_tmp.range(LOG2_NB_OF_BUFFERS+1,LOG2_NB_OF_BUFFERS) = VC_RESPONSE;
98
                        ro_command_packet_rd_addr_tmp.range(LOG2_NB_OF_BUFFERS-1,0) = response_packet_addr[destination];
99
                }
100
                //Finally nposted packets
101
                else if(nposted_requested[destination].read() && nposted_available[destination].read()){
102
                        ack_nposted[destination] = true;
103
                        selected_vc[destination] = VC_NON_POSTED;
104
                        packet_selected[destination] = true;
105
                        ro_command_packet_rd_addr_tmp.range(LOG2_NB_OF_BUFFERS+1,LOG2_NB_OF_BUFFERS) = VC_NON_POSTED;
106
                        ro_command_packet_rd_addr_tmp.range(LOG2_NB_OF_BUFFERS-1,0) = nposted_packet_addr[destination];
107
                }
108
 
109
                //Output the result
110
                ro_command_packet_rd_addr[destination] = ro_command_packet_rd_addr_tmp;
111
        }
112
}
113
 
114
void fetch_packet_l3::register_signals(){
115
        if(!resetx.read()){
116
                for(int destination = 0; destination < 2; destination++){
117
#ifdef ENABLE_REORDERING
118
                        packet_passpw[destination] = false;
119
                        packet_seqid[destination] = 0;
120
                        packet_chain[destination] = false;
121
#else
122
                        currently_posted_chain[destination] = false;
123
#endif
124
 
125
                        packet_vc[destination] = VC_NONE;
126
                        packet_fetched[destination] = false;
127
                }
128
        }
129
        else{
130
                for(int destination = 0; destination < 2; destination++){
131
                        //Register the decision from the other combinatorial process
132
                        packet_vc[destination] = selected_vc[destination].read();
133
                        packet_fetched[destination] = packet_selected[destination].read();
134
 
135
 
136
#ifdef ENABLE_REORDERING
137
                        //Register information about the packet depending on the virtual channel
138
                        //of the packet
139
                        switch(selected_vc[destination].read()){
140
                                case VC_NON_POSTED:
141
                                        packet_passpw[destination] = nposted_packet_passpw[destination].read();
142
                                        packet_seqid[destination] = nposted_packet_seqid[destination].read();
143
                                        packet_chain[destination] = false;
144
                                        break;
145
                                case VC_RESPONSE:
146
                                        packet_passpw[destination] = response_packet_passpw[destination].read();
147
                                        packet_seqid[destination] = 0;
148
                                        packet_chain[destination] = false;
149
 
150
                                        break;
151
                                default:
152
                                        packet_passpw[destination] = posted_packet_passpw[destination].read();
153
                                        packet_seqid[destination] = posted_packet_seqid[destination].read();
154
                                        packet_chain[destination] = posted_packet_chain[destination].read();
155
                        }
156
#else
157
                        if(packet_vc[destination].read() == VC_POSTED)
158
                                currently_posted_chain[destination] = (sc_bit)command_packet_rd_data_ro[destination].read()[19];
159
#endif
160
                }
161
        }
162
 
163
}
164
 
165
void fetch_packet_l3::reconstruct_packet(){
166
        //The role of this function is to reconstruct packets for output by merging
167
        //the information coming from the buffers and the information from the
168
        //embedded memory.  The reconstruction is exactly the inverse of what was
169
        //done in the entrance reordering.  There is a better explanation about what
170
        //is going on in that module (entrance reordering) if it is needed to understand 
171
        //this code.
172
        for(int destination = 0; destination < 2; destination++){
173
                fetched_packet_available[destination] = packet_fetched[destination];
174
                fetched_packet_vc[destination] = packet_vc[destination];
175
 
176
                syn_ControlPacketComplete fetched_packet_tmp;
177
 
178
                //A default value, might be mofidied below depending on preprocessor directives
179
                fetched_packet_tmp.packet = command_packet_rd_data_ro[destination].read().range(63,0);
180
 
181
#ifndef ENABLE_REORDERING
182
                bool posted_part_of_chain = packet_vc[destination].read() == VC_POSTED &&
183
                        ((sc_bit)command_packet_rd_data_ro[destination].read()[19] ||
184
                         (sc_bit)currently_posted_chain[destination].read());
185
 
186
                fetched_packet_tmp.error64BitExtension = (sc_bit)command_packet_rd_data_ro[destination].read()[64];
187
                fetched_packet_tmp.data_address = (sc_bv<BUFFERS_ADDRESS_WIDTH>)command_packet_rd_data_ro[destination].read().range(LOG2_NB_OF_BUFFERS+64,65);
188
                fetched_packet_tmp.isPartOfChain = posted_part_of_chain;
189
                if(destination == FWD_DEST){
190
                        fetched_packet_nposted_refid[destination] = (sc_bv<LOG2_NB_OF_BUFFERS+1>)command_packet_rd_data_ro[destination].read().range(LOG2_NB_OF_BUFFERS+BUFFERS_ADDRESS_WIDTH+65,BUFFERS_ADDRESS_WIDTH+65);
191
                        fetched_packet_response_refid[destination] = (sc_bv<LOG2_NB_OF_BUFFERS+1>)command_packet_rd_data_ro[destination].read().range(2 * LOG2_NB_OF_BUFFERS+BUFFERS_ADDRESS_WIDTH+66,LOG2_NB_OF_BUFFERS+BUFFERS_ADDRESS_WIDTH+66);
192
                }
193
                else{
194
                        fetched_packet_nposted_refid[destination] = (sc_bv<LOG2_NB_OF_BUFFERS+1>)command_packet_rd_data_ro[destination].read().range(3*LOG2_NB_OF_BUFFERS+BUFFERS_ADDRESS_WIDTH+67,2*LOG2_NB_OF_BUFFERS+BUFFERS_ADDRESS_WIDTH+67);
195
                        fetched_packet_response_refid[destination] = (sc_bv<LOG2_NB_OF_BUFFERS+1>)command_packet_rd_data_ro[destination].read().range(4 * LOG2_NB_OF_BUFFERS+BUFFERS_ADDRESS_WIDTH+68,3*LOG2_NB_OF_BUFFERS+BUFFERS_ADDRESS_WIDTH+68);
196
                }
197
#else
198
                //Recover error64bit at passPW position
199
                fetched_packet_tmp.error64BitExtension = (sc_bit)command_packet_rd_data_ro[destination].read()[15];
200
                fetched_packet_tmp.packet[15] = packet_passpw[destination].read();
201
 
202
                //Recover the refid
203
                if(packet_vc[destination].read() == VC_POSTED){
204
                        fetched_packet_nposted_refid[destination] =  posted_packet_nposted_refid[destination];
205
                        fetched_packet_response_refid[destination] =  posted_packet_response_refid[destination];
206
                }
207
                else{
208
                        //If the packet is NPOSTED, only the nposted_refid will be read
209
                        //If the packet is RESPONSE, only the response_refid will be read
210
                        //This is why we output the same thing for both values (simplifies logic)
211
#if BUFFERS_ADDRESS_WIDTH < 5
212
                        fetched_packet_nposted_refid[destination] =  (sc_bv<LOG2_NB_OF_BUFFERS+1>)command_packet_rd_data_ro[destination].read().range(LOG2_NB_OF_BUFFERS+64,64);
213
                        fetched_packet_response_refid[destination] =  (sc_bv<LOG2_NB_OF_BUFFERS+1>)command_packet_rd_data_ro[destination].read().range(LOG2_NB_OF_BUFFERS+64,64);
214
  #else
215
                        fetched_packet_nposted_refid[destination] = (sc_bv<LOG2_NB_OF_BUFFERS+1>)command_packet_rd_data_ro[destination].read().range(60+LOG2_NB_OF_BUFFERS + BUFFERS_ADDRESS_WIDTH,60+BUFFERS_ADDRESS_WIDTH);
216
                        fetched_packet_response_refid[destination] = (sc_bv<LOG2_NB_OF_BUFFERS+1>)command_packet_rd_data_ro[destination].read().range(60+LOG2_NB_OF_BUFFERS + BUFFERS_ADDRESS_WIDTH,60+BUFFERS_ADDRESS_WIDTH);
217
  #endif
218
                }
219
 
220
                //For other field, place differently depending on if it is a response or not
221
                if(packet_vc[destination].read() == VC_RESPONSE){
222
                        fetched_packet_tmp.packet.range(5,2) = "1100";
223
  #if BUFFERS_ADDRESS_WIDTH < 5
224
                        fetched_packet_tmp.data_address = (sc_bv<BUFFERS_ADDRESS_WIDTH>)command_packet_rd_data_ro[destination].read().range(1 + BUFFERS_ADDRESS_WIDTH,2);
225
  #else
226
                        fetched_packet_tmp.data_address.range(3,0) = command_packet_rd_data_ro[destination].read().range(5,2);
227
                        fetched_packet_tmp.data_address.range(BUFFERS_ADDRESS_WIDTH-1,4)
228
                                = command_packet_rd_data_ro[destination].read().range(27 + BUFFERS_ADDRESS_WIDTH,32);
229
  #endif
230
                }
231
                else{
232
        //              -seqID is sent to registers : bits 7..6 and 14..13
233
  #if BUFFERS_ADDRESS_WIDTH < 3
234
                        fetched_packet_tmp.data_address = (sc_bv<BUFFERS_ADDRESS_WIDTH>)command_packet_rd_data_ro[destination].read().range(BUFFERS_ADDRESS_WIDTH+5,6);
235
                        fetched_packet_tmp.packet.range(7,6) = packet_seqid[destination].read().range(3,2);
236
  #elif BUFFERS_ADDRESS_WIDTH < 5
237
                        fetched_packet_tmp.data_address.range(1,0) = (sc_bv<2>)command_packet_rd_data_ro[destination].read().range(7,6);
238
                        fetched_packet_tmp.packet.range(7,6) = packet_seqid[destination].read().range(3,2);
239
                        fetched_packet_tmp.data_address.range(BUFFERS_ADDRESS_WIDTH-1,2) = (sc_bv<BUFFERS_ADDRESS_WIDTH-2>)command_packet_rd_data_ro[destination].read().range(BUFFERS_ADDRESS_WIDTH+10,13);
240
                        fetched_packet_tmp.packet.range(14,13) = packet_seqid[destination].read().range(1,0);
241
  #else
242
                        fetched_packet_tmp.data_address.range(1,0) = (sc_bv<2>)command_packet_rd_data_ro[destination].read().range(7,6);
243
                        fetched_packet_tmp.packet.range(7,6) = packet_seqid[destination].read().range(3,2);
244
                        fetched_packet_tmp.data_address.range(3,2) = command_packet_rd_data_ro[destination].read().range(14,13);
245
                        fetched_packet_tmp.packet.range(14,13) = packet_seqid[destination].read().range(1,0);
246
                        fetched_packet_tmp.data_address.range(BUFFERS_ADDRESS_WIDTH-1,4) = command_packet_rd_data_ro[destination].read().range(59+BUFFERS_ADDRESS_WIDTH,64);
247
  #endif
248
                }
249
#endif
250
 
251
                fetched_packet[destination] = fetched_packet_tmp;
252
        }
253
}
254
 

powered by: WebSVN 2.1.0

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