1 | /* -*- c++ -*- |
---|
2 | * SOCLIB_LGPL_HEADER_BEGIN |
---|
3 | * |
---|
4 | * This file is part of SoCLib, GNU LGPLv2.1. |
---|
5 | * |
---|
6 | * SoCLib is free software; you can redistribute it and/or modify it |
---|
7 | * under the terms of the GNU Lesser General Public License as published |
---|
8 | * by the Free Software Foundation; version 2.1 of the License. |
---|
9 | * |
---|
10 | * SoCLib is distributed in the hope that it will be useful, but |
---|
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
13 | * Lesser General Public License for more details. |
---|
14 | * |
---|
15 | * You should have received a copy of the GNU Lesser General Public |
---|
16 | * License along with SoCLib; if not, write to the Free Software |
---|
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
---|
18 | * 02110-1301 USA |
---|
19 | * |
---|
20 | * SOCLIB_LGPL_HEADER_END |
---|
21 | * |
---|
22 | * Authors : Abdelmalek SI MERABET |
---|
23 | * Franck WAJSBURT |
---|
24 | * Date : Februrary 2013 |
---|
25 | * Copyright: UPMC - LIP6 |
---|
26 | */ |
---|
27 | #ifndef SOCLIB_CABA_DSPIN_ALLOC_RING_TARGET_FAST_H |
---|
28 | #define SOCLIB_CABA_DSPIN_ALLOC_RING_TARGET_FAST_H |
---|
29 | |
---|
30 | #include "generic_fifo.h" |
---|
31 | #include "mapping_table.h" |
---|
32 | #include "ring_signals_fast.h" |
---|
33 | #include "dspin_interface.h" |
---|
34 | |
---|
35 | #define T_DEBUG |
---|
36 | |
---|
37 | namespace soclib { namespace caba { |
---|
38 | |
---|
39 | namespace { |
---|
40 | |
---|
41 | const char *ring_rsp_fsm_state_str_t[] = { |
---|
42 | "RSP_IDLE", |
---|
43 | "OWNER", |
---|
44 | "SENDING", |
---|
45 | "WAIT_PALLOC_END", |
---|
46 | }; |
---|
47 | |
---|
48 | #ifdef T_DEBUG |
---|
49 | |
---|
50 | const char *ring_cmd_fsm_state_str_t[] = { |
---|
51 | "CMD_IDLE", |
---|
52 | "ALLOC", |
---|
53 | "NALLOC", |
---|
54 | "PALLOC2", |
---|
55 | "PALLOC1", |
---|
56 | }; |
---|
57 | #endif |
---|
58 | } // end namespace |
---|
59 | |
---|
60 | template<typename vci_param, int ring_cmd_data_size, int ring_rsp_data_size> |
---|
61 | class DspinLocalRingTargetFastC |
---|
62 | { |
---|
63 | |
---|
64 | typedef typename vci_param::fast_addr_t vci_addr_t; |
---|
65 | typedef LocalRingSignals ring_signal_t; |
---|
66 | typedef DspinOutput<ring_cmd_data_size > cmd_out_t; |
---|
67 | typedef DspinInput<ring_rsp_data_size > rsp_in_t; |
---|
68 | |
---|
69 | private: |
---|
70 | |
---|
71 | enum ring_cmd_fsm_state_e { |
---|
72 | CMD_IDLE, // waiting for first flit of a command packet |
---|
73 | ALLOC, // next flit of a local cmd packet |
---|
74 | NALLOC, // next flit of a ring cmd packet |
---|
75 | PALLOC2, // local target is receiving from init gate (ring is cmd_preempted) while target gate is allocated |
---|
76 | PALLOC1, // local target is receiving from init gate, target gate has finished receiving (target gate is not allocated) |
---|
77 | }; |
---|
78 | |
---|
79 | // cmd token allocation fsm |
---|
80 | enum ring_rsp_fsm_state_e { |
---|
81 | RSP_IDLE, |
---|
82 | OWNER, |
---|
83 | SENDING, |
---|
84 | WAIT_PALLOC_END, |
---|
85 | }; |
---|
86 | |
---|
87 | // structural parameters |
---|
88 | std::string m_name; |
---|
89 | bool m_alloc_target; |
---|
90 | |
---|
91 | // internal fifos |
---|
92 | GenericFifo<uint64_t > m_cmd_fifo; // fifo for the local command paquet |
---|
93 | GenericFifo<uint64_t > m_rsp_fifo; // fifo for the local response paquet |
---|
94 | |
---|
95 | // routing table |
---|
96 | soclib::common::AddressDecodingTable<vci_addr_t, int> m_rt; |
---|
97 | // locality table |
---|
98 | soclib::common::AddressDecodingTable<vci_addr_t, bool> m_lt; |
---|
99 | |
---|
100 | int m_tgtid; |
---|
101 | |
---|
102 | |
---|
103 | #ifdef T_DEBUG |
---|
104 | uint32_t m_cpt; |
---|
105 | #endif |
---|
106 | |
---|
107 | // internal registers |
---|
108 | sc_core::sc_signal<int> r_ring_cmd_fsm; // ring command packet FSM |
---|
109 | sc_core::sc_signal<int> r_ring_rsp_fsm; // ring response packet FSM |
---|
110 | |
---|
111 | |
---|
112 | public : |
---|
113 | |
---|
114 | #define __renRegTgt(x) x((((std::string) name)+"_" #x).c_str()) |
---|
115 | |
---|
116 | DspinLocalRingTargetFastC( |
---|
117 | const char *name, |
---|
118 | bool alloc_target, |
---|
119 | const int &wrapper_fifo_depth, |
---|
120 | const soclib::common::MappingTable &mt, |
---|
121 | const soclib::common::IntTab &ringid, |
---|
122 | const int &tgtid) |
---|
123 | : m_name(name), |
---|
124 | m_alloc_target(alloc_target), |
---|
125 | m_cmd_fifo(((std::string) name)+"m_cmd_fifo", wrapper_fifo_depth), |
---|
126 | m_rsp_fifo(((std::string) name)+"m_rsp_fifo", wrapper_fifo_depth), |
---|
127 | m_rt(mt.getRoutingTable<typename vci_param::fast_addr_t>(ringid)), |
---|
128 | m_lt(mt.getLocalityTable<typename vci_param::fast_addr_t>(ringid)), |
---|
129 | m_tgtid(tgtid), |
---|
130 | __renRegTgt(r_ring_cmd_fsm), |
---|
131 | __renRegTgt(r_ring_rsp_fsm) |
---|
132 | |
---|
133 | {} // end constructor |
---|
134 | |
---|
135 | void reset() |
---|
136 | { |
---|
137 | if(m_alloc_target) |
---|
138 | r_ring_rsp_fsm = OWNER; |
---|
139 | else |
---|
140 | r_ring_rsp_fsm = RSP_IDLE; |
---|
141 | |
---|
142 | r_ring_cmd_fsm = CMD_IDLE; |
---|
143 | m_cmd_fifo.init(); |
---|
144 | m_rsp_fifo.init(); |
---|
145 | |
---|
146 | #ifdef T_DEBUG |
---|
147 | m_cpt = 0; |
---|
148 | #endif |
---|
149 | |
---|
150 | |
---|
151 | } |
---|
152 | void transition(const cmd_out_t &p_cmd_out, const rsp_in_t &p_rsp_in, const ring_signal_t p_ring_in, bool &tgt_cmd_val, rsp_str &tgt_rsp) |
---|
153 | { |
---|
154 | |
---|
155 | bool cmd_fifo_put = false; |
---|
156 | uint64_t cmd_fifo_data = 0; |
---|
157 | |
---|
158 | bool rsp_fifo_get = false; |
---|
159 | bool rsp_fifo_put = false; |
---|
160 | uint64_t rsp_fifo_data = 0; |
---|
161 | |
---|
162 | //////////// DSPIN FIFOS ACCESS ///////////////////////// |
---|
163 | |
---|
164 | if (p_rsp_in.write) { |
---|
165 | #ifdef T_DEBUG |
---|
166 | std::cout << sc_time_stamp() << " -- " << m_name << " -- DSPIN FIFO" |
---|
167 | << " -- rsp in rok : " << p_rsp_in.write |
---|
168 | << " -- in data : " << std::hex << p_rsp_in.data.read() |
---|
169 | << " -- fifo wok : " << m_rsp_fifo.wok() |
---|
170 | << std::endl; |
---|
171 | #endif |
---|
172 | |
---|
173 | rsp_fifo_data = (uint64_t) p_rsp_in.data.read(); |
---|
174 | rsp_fifo_put = m_rsp_fifo.wok(); |
---|
175 | } |
---|
176 | |
---|
177 | bool cmd_fifo_get = p_cmd_out.read; |
---|
178 | |
---|
179 | //////////// RING RSP FSM ///////////////////////// |
---|
180 | |
---|
181 | switch( r_ring_rsp_fsm ) |
---|
182 | { |
---|
183 | case RSP_IDLE: |
---|
184 | |
---|
185 | #ifdef T_DEBUG |
---|
186 | if(m_rsp_fifo.rok()) |
---|
187 | std::cout << std::dec << sc_time_stamp() << " - " << m_name |
---|
188 | << " - ring_rsp_fsm = " << ring_rsp_fsm_state_str_t[r_ring_rsp_fsm] |
---|
189 | << " - fifo ROK : " << m_rsp_fifo.rok() |
---|
190 | << " - in grant : " << p_ring_in.rsp_grant |
---|
191 | << " - in palloc : " << p_ring_in.rsp_palloc |
---|
192 | << " - in wok : " << p_ring_in.rsp_r |
---|
193 | << " - fifo data : " << std::hex << m_rsp_fifo.read() |
---|
194 | << std::endl; |
---|
195 | #endif |
---|
196 | |
---|
197 | if ( p_ring_in.rsp_grant && m_rsp_fifo.rok() ) |
---|
198 | |
---|
199 | r_ring_rsp_fsm = SENDING; |
---|
200 | |
---|
201 | break; |
---|
202 | |
---|
203 | case OWNER: |
---|
204 | { |
---|
205 | |
---|
206 | #ifdef T_DEBUG |
---|
207 | if(m_rsp_fifo.rok()) |
---|
208 | std::cout << std::dec << sc_time_stamp() << " - " << m_name |
---|
209 | << " - ring_rsp_fsm = " << ring_rsp_fsm_state_str_t[r_ring_rsp_fsm] |
---|
210 | << " - in rsp grant : " << p_ring_in.rsp_grant |
---|
211 | << " - in wok : " << p_ring_in.rsp_r |
---|
212 | << " - fifo rok : " << m_rsp_fifo.rok() |
---|
213 | << " - fifo data : " << std::hex << m_rsp_fifo.read() |
---|
214 | << std::endl; |
---|
215 | #endif |
---|
216 | |
---|
217 | bool eop = ( (int) ((m_rsp_fifo.read() >> (ring_rsp_data_size - 1) ) & 0x1) == 1); |
---|
218 | |
---|
219 | if ( m_rsp_fifo.rok() && eop && p_ring_in.rsp_r ) |
---|
220 | { |
---|
221 | rsp_fifo_get = true; |
---|
222 | if ( p_ring_in.rsp_grant ) |
---|
223 | r_ring_rsp_fsm = OWNER; |
---|
224 | else |
---|
225 | r_ring_rsp_fsm = RSP_IDLE; |
---|
226 | } |
---|
227 | |
---|
228 | if ( m_rsp_fifo.rok() && (!eop || !p_ring_in.rsp_r)) |
---|
229 | { |
---|
230 | rsp_fifo_get = p_ring_in.rsp_r; |
---|
231 | r_ring_rsp_fsm = SENDING; |
---|
232 | } |
---|
233 | |
---|
234 | if ( !m_rsp_fifo.rok() && !p_ring_in.rsp_grant ) |
---|
235 | r_ring_rsp_fsm = RSP_IDLE; |
---|
236 | |
---|
237 | if ( !m_rsp_fifo.rok() && p_ring_in.rsp_grant ) |
---|
238 | r_ring_rsp_fsm = OWNER; |
---|
239 | } |
---|
240 | break; |
---|
241 | |
---|
242 | case SENDING: |
---|
243 | |
---|
244 | // stay here while !release + rsp_preempt |
---|
245 | // release = fifo_rok.ring_in.wok.fifo_data.eop |
---|
246 | #ifdef T_DEBUG |
---|
247 | if(m_rsp_fifo.rok()) |
---|
248 | std::cout << std::dec << sc_time_stamp() << " - " << m_name |
---|
249 | << " - ring_rsp_fsm = " << ring_rsp_fsm_state_str_t[r_ring_rsp_fsm] |
---|
250 | << " - fifo ROK : " << m_rsp_fifo.rok() |
---|
251 | << " - in grant : " << p_ring_in.rsp_grant |
---|
252 | << " - in preempt : " << p_ring_in.rsp_preempt |
---|
253 | << " - in palloc : " << p_ring_in.rsp_palloc |
---|
254 | << " - in wok : " << p_ring_in.rsp_r |
---|
255 | << " - fifo data : " << std::hex << m_rsp_fifo.read() |
---|
256 | << std::endl; |
---|
257 | #endif |
---|
258 | if(p_ring_in.rsp_preempt) break; |
---|
259 | |
---|
260 | if(m_rsp_fifo.rok() && p_ring_in.rsp_r) |
---|
261 | { |
---|
262 | rsp_fifo_get = true; |
---|
263 | bool eop = ((int) (m_rsp_fifo.read() >> (ring_rsp_data_size - 1) ) & 0x1) == 1; |
---|
264 | |
---|
265 | if (eop && !p_ring_in.rsp_palloc && p_ring_in.rsp_grant) |
---|
266 | { |
---|
267 | r_ring_rsp_fsm = OWNER; |
---|
268 | } |
---|
269 | else if (eop && !p_ring_in.rsp_palloc && !p_ring_in.rsp_grant) |
---|
270 | { |
---|
271 | r_ring_rsp_fsm = RSP_IDLE; |
---|
272 | } |
---|
273 | else if (eop && p_ring_in.rsp_palloc) |
---|
274 | { |
---|
275 | r_ring_rsp_fsm = WAIT_PALLOC_END; |
---|
276 | } |
---|
277 | } |
---|
278 | |
---|
279 | break; |
---|
280 | |
---|
281 | case WAIT_PALLOC_END: |
---|
282 | // stay here and keep token till Init Gate last flit |
---|
283 | bool eop = ((int) (p_ring_in.rsp_data >> (ring_rsp_data_size - 1) ) & 0x1) == 1; |
---|
284 | #ifdef T_DEBUG |
---|
285 | if(p_ring_in.rsp_w) |
---|
286 | std::cout << std::dec << sc_time_stamp() << " - " << m_name |
---|
287 | << " - ring_rsp_fsm = " << ring_rsp_fsm_state_str_t[r_ring_rsp_fsm] |
---|
288 | << " - palloc : " << p_ring_in.rsp_palloc |
---|
289 | << " - in grant : " << p_ring_in.rsp_grant |
---|
290 | << " - in preempt : " << p_ring_in.rsp_preempt |
---|
291 | << " - in rok : " << p_ring_in.rsp_w |
---|
292 | << " - in wok : " << p_ring_in.rsp_r |
---|
293 | << " - eop : " << eop |
---|
294 | << std::endl; |
---|
295 | #endif |
---|
296 | if(p_ring_in.rsp_w && p_ring_in.rsp_r && eop) // last flit from Init gate |
---|
297 | { |
---|
298 | if (p_ring_in.rsp_grant) |
---|
299 | r_ring_rsp_fsm = OWNER; |
---|
300 | else |
---|
301 | r_ring_rsp_fsm = CMD_IDLE; |
---|
302 | |
---|
303 | } |
---|
304 | |
---|
305 | break; |
---|
306 | } // end switch ring cmd fsm |
---|
307 | |
---|
308 | /////////// RING CMD FSM //////////////////////// |
---|
309 | switch( r_ring_cmd_fsm ) |
---|
310 | { |
---|
311 | |
---|
312 | case CMD_IDLE: |
---|
313 | { // for variable scope |
---|
314 | |
---|
315 | vci_addr_t rtgtid = (vci_addr_t) (((p_ring_in.cmd_data >> (ring_cmd_data_size-vci_param::S-1)) << (vci_param::N-vci_param::S))); |
---|
316 | bool islocalm = m_lt[rtgtid] && (m_rt[rtgtid] == m_tgtid); // multicast |
---|
317 | bool isbrdcst = (p_ring_in.cmd_data & 0x1) == 0x1; |
---|
318 | bool islocalb = ( (int) ((p_ring_in.cmd_data >> 1 ) & 0xF) == m_tgtid); // broadcast |
---|
319 | bool eop = ( (int) ((p_ring_in.cmd_data >> (ring_cmd_data_size - 1) ) & 0x1) == 1); |
---|
320 | |
---|
321 | if(p_ring_in.cmd_w) |
---|
322 | { |
---|
323 | #ifdef T_DEBUG |
---|
324 | std::cout << std::dec << sc_time_stamp() << " - " << m_name |
---|
325 | << " - ring_cmd_fsm = " << ring_cmd_fsm_state_str_t[r_ring_cmd_fsm] |
---|
326 | << " - in preempt : " << p_ring_in.cmd_preempt |
---|
327 | << " - in rok : " << p_ring_in.cmd_w |
---|
328 | << " - in data : " << std::hex << p_ring_in.cmd_data |
---|
329 | << " - in wok : " << p_ring_in.cmd_r |
---|
330 | << " - rtgtid : " << rtgtid |
---|
331 | << " - fifo wok : " << m_cmd_fifo.wok() |
---|
332 | << " - islocalm : " << islocalm |
---|
333 | << " - islocalb : " << islocalb |
---|
334 | << " - eop : " << eop |
---|
335 | << std::endl; |
---|
336 | #endif |
---|
337 | if ( (isbrdcst && islocalb) || (!isbrdcst && islocalm) ) |
---|
338 | { |
---|
339 | |
---|
340 | cmd_fifo_put = m_cmd_fifo.wok(); |
---|
341 | cmd_fifo_data = p_ring_in.cmd_data; |
---|
342 | |
---|
343 | if (eop && m_cmd_fifo.wok()) |
---|
344 | r_ring_cmd_fsm = CMD_IDLE; |
---|
345 | else |
---|
346 | r_ring_cmd_fsm = ALLOC; |
---|
347 | |
---|
348 | } |
---|
349 | |
---|
350 | else |
---|
351 | { |
---|
352 | if (eop && p_ring_in.cmd_r) |
---|
353 | r_ring_cmd_fsm = CMD_IDLE; |
---|
354 | else |
---|
355 | r_ring_cmd_fsm = NALLOC; |
---|
356 | } |
---|
357 | } |
---|
358 | else |
---|
359 | r_ring_cmd_fsm = CMD_IDLE; |
---|
360 | } |
---|
361 | |
---|
362 | break; |
---|
363 | |
---|
364 | case ALLOC: |
---|
365 | #ifdef T_DEBUG |
---|
366 | if(p_ring_in.cmd_w) |
---|
367 | std::cout << std::dec << sc_time_stamp() << " - " << m_name |
---|
368 | << " - ring_cmd_fsm = " << ring_cmd_fsm_state_str_t[r_ring_cmd_fsm] |
---|
369 | << " - in preempt : " << p_ring_in.cmd_preempt |
---|
370 | << " - in rok : " << p_ring_in.cmd_w |
---|
371 | << " - in data : " << std::hex << p_ring_in.cmd_data |
---|
372 | << " - in wok : " << p_ring_in.cmd_r |
---|
373 | << " - fifo wok : " << m_cmd_fifo.wok() |
---|
374 | << std::endl; |
---|
375 | #endif |
---|
376 | { |
---|
377 | bool eop = ( (int) ((p_ring_in.cmd_data >> (ring_cmd_data_size - 1) ) & 0x1) == 1); |
---|
378 | |
---|
379 | |
---|
380 | if ( p_ring_in.cmd_w && m_cmd_fifo.wok() && eop ) |
---|
381 | { |
---|
382 | |
---|
383 | cmd_fifo_put = true; |
---|
384 | cmd_fifo_data = p_ring_in.cmd_data; |
---|
385 | r_ring_cmd_fsm = CMD_IDLE; |
---|
386 | |
---|
387 | } |
---|
388 | |
---|
389 | else // !p_ring_in.cmd_w || !m_cmd_fifo.wok() || !eop |
---|
390 | { |
---|
391 | |
---|
392 | cmd_fifo_put = p_ring_in.cmd_w && m_cmd_fifo.wok(); |
---|
393 | cmd_fifo_data = p_ring_in.cmd_data; |
---|
394 | r_ring_cmd_fsm = ALLOC; |
---|
395 | |
---|
396 | } |
---|
397 | } |
---|
398 | break; |
---|
399 | |
---|
400 | case NALLOC: |
---|
401 | // if preempt (init gate is preempting ring while target gate is allocated), |
---|
402 | // if first flit of a new packet, is it for this local target ? |
---|
403 | #ifdef T_DEBUG |
---|
404 | if(p_ring_in.cmd_preempt || p_ring_in.cmd_w) |
---|
405 | std::cout << std::dec << sc_time_stamp() << " - " << m_name |
---|
406 | << " - ring_cmd_fsm = " << ring_cmd_fsm_state_str_t[r_ring_cmd_fsm] |
---|
407 | << " - preempt : " << p_ring_in.cmd_preempt |
---|
408 | << " - palloc : " << p_ring_in.cmd_palloc |
---|
409 | << " - header : " << p_ring_in.cmd_header |
---|
410 | << " - in rok : " << p_ring_in.cmd_w |
---|
411 | << " - in data : " << std::hex << p_ring_in.cmd_data |
---|
412 | << " - in wok : " << p_ring_in.cmd_r |
---|
413 | << " - fifo wok : " << m_cmd_fifo.wok() |
---|
414 | << std::endl; |
---|
415 | #endif |
---|
416 | { |
---|
417 | bool eop = ( (int) ((p_ring_in.cmd_data >> (ring_cmd_data_size - 1) ) & 0x1) == 1); |
---|
418 | |
---|
419 | |
---|
420 | if(p_ring_in.cmd_preempt) |
---|
421 | { |
---|
422 | // cmd_header : sent by init gate |
---|
423 | if(p_ring_in.cmd_header) |
---|
424 | { |
---|
425 | vci_addr_t rtgtid = (vci_addr_t) (((p_ring_in.cmd_data >> (ring_cmd_data_size-vci_param::S-1)) << (vci_param::N-vci_param::S))); |
---|
426 | bool islocalm = m_lt[rtgtid] && (m_rt[rtgtid] == m_tgtid); // multicast |
---|
427 | bool isbrdcst = (p_ring_in.cmd_data & 0x1) == 0x1; |
---|
428 | bool islocalb = ( (int) ((p_ring_in.cmd_data >> 1 ) & 0xF) == m_tgtid); // broadcast |
---|
429 | bool eop = ( (int) ((p_ring_in.cmd_data >> (ring_cmd_data_size - 1) ) & 0x1) == 1); |
---|
430 | |
---|
431 | |
---|
432 | if ( (isbrdcst && islocalb) || (!isbrdcst && islocalm) ) |
---|
433 | { |
---|
434 | |
---|
435 | cmd_fifo_put = m_cmd_fifo.wok(); |
---|
436 | cmd_fifo_data = p_ring_in.cmd_data; |
---|
437 | |
---|
438 | if (eop && m_cmd_fifo.wok()) |
---|
439 | r_ring_cmd_fsm = CMD_IDLE; |
---|
440 | else |
---|
441 | r_ring_cmd_fsm = PALLOC2; |
---|
442 | |
---|
443 | } |
---|
444 | |
---|
445 | else |
---|
446 | { |
---|
447 | if (eop && p_ring_in.cmd_r) |
---|
448 | r_ring_cmd_fsm = CMD_IDLE; |
---|
449 | else |
---|
450 | r_ring_cmd_fsm = NALLOC; |
---|
451 | } |
---|
452 | |
---|
453 | } |
---|
454 | else // preempt && !header |
---|
455 | { |
---|
456 | // palloc=1, means TG is not allocated, thus, if last flit, all targets must be in IDLE state |
---|
457 | if(eop && p_ring_in.cmd_r && (p_ring_in.cmd_palloc == 1)) |
---|
458 | r_ring_cmd_fsm = CMD_IDLE; |
---|
459 | else |
---|
460 | r_ring_cmd_fsm = NALLOC; |
---|
461 | |
---|
462 | } |
---|
463 | |
---|
464 | } |
---|
465 | |
---|
466 | else // !preempt |
---|
467 | { |
---|
468 | if(p_ring_in.cmd_w && eop && p_ring_in.cmd_r && !p_ring_in.cmd_palloc) |
---|
469 | r_ring_cmd_fsm = CMD_IDLE; |
---|
470 | else |
---|
471 | r_ring_cmd_fsm = NALLOC; |
---|
472 | |
---|
473 | } |
---|
474 | |
---|
475 | } |
---|
476 | break; |
---|
477 | |
---|
478 | case PALLOC2: |
---|
479 | #ifdef T_DEBUG |
---|
480 | if(p_ring_in.cmd_preempt || p_ring_in.cmd_w) |
---|
481 | std::cout << std::dec << sc_time_stamp() << " - " << m_name |
---|
482 | << " - ring_cmd_fsm = " << ring_cmd_fsm_state_str_t[r_ring_cmd_fsm] |
---|
483 | << " - in preempt : " << p_ring_in.cmd_preempt |
---|
484 | << " - in rok : " << p_ring_in.cmd_w |
---|
485 | << " - in data : " << std::hex << p_ring_in.cmd_data |
---|
486 | << " - in wok : " << p_ring_in.cmd_r |
---|
487 | << " - fifo wok : " << m_cmd_fifo.wok() |
---|
488 | << std::endl; |
---|
489 | #endif |
---|
490 | { |
---|
491 | bool eop = ( (int) ((p_ring_in.cmd_data >> (ring_cmd_data_size - 1) ) & 0x1) == 1); |
---|
492 | |
---|
493 | if(p_ring_in.cmd_preempt) |
---|
494 | { |
---|
495 | cmd_fifo_put = m_cmd_fifo.wok(); |
---|
496 | cmd_fifo_data = p_ring_in.cmd_data; |
---|
497 | |
---|
498 | if(eop && m_cmd_fifo.wok()) |
---|
499 | r_ring_cmd_fsm = NALLOC; |
---|
500 | else |
---|
501 | r_ring_cmd_fsm = PALLOC2; |
---|
502 | break; |
---|
503 | } |
---|
504 | |
---|
505 | if(p_ring_in.cmd_w && eop && p_ring_in.cmd_r) |
---|
506 | { |
---|
507 | r_ring_cmd_fsm = PALLOC1; |
---|
508 | } |
---|
509 | |
---|
510 | } |
---|
511 | break; |
---|
512 | |
---|
513 | case PALLOC1: |
---|
514 | #ifdef T_DEBUG |
---|
515 | std::cout << std::dec << sc_time_stamp() << " - " << m_name |
---|
516 | << " - ring_cmd_fsm = " << ring_cmd_fsm_state_str_t[r_ring_cmd_fsm] |
---|
517 | << " - in preempt : " << p_ring_in.cmd_preempt |
---|
518 | << " - in rok : " << p_ring_in.cmd_w |
---|
519 | << " - in data : " << std::hex << p_ring_in.cmd_data |
---|
520 | << " - in wok : " << p_ring_in.cmd_r |
---|
521 | << " - fifo wok : " << m_cmd_fifo.wok() |
---|
522 | << std::endl; |
---|
523 | #endif |
---|
524 | { |
---|
525 | bool eop = ( (int) ((p_ring_in.cmd_data >> (ring_cmd_data_size - 1) ) & 0x1) == 1); |
---|
526 | |
---|
527 | if ( p_ring_in.cmd_preempt && m_cmd_fifo.wok() && eop ) |
---|
528 | { |
---|
529 | |
---|
530 | cmd_fifo_put = true; |
---|
531 | cmd_fifo_data = p_ring_in.cmd_data; |
---|
532 | r_ring_cmd_fsm = CMD_IDLE; |
---|
533 | |
---|
534 | } |
---|
535 | |
---|
536 | else // !p_ring_in.cmd_w || !m_cmd_fifo.wok() || !eop |
---|
537 | { |
---|
538 | |
---|
539 | cmd_fifo_put = p_ring_in.cmd_preempt && m_cmd_fifo.wok(); |
---|
540 | cmd_fifo_data = p_ring_in.cmd_data; |
---|
541 | r_ring_cmd_fsm = PALLOC1; |
---|
542 | |
---|
543 | } |
---|
544 | } |
---|
545 | break; |
---|
546 | |
---|
547 | } // end switch cmd fsm |
---|
548 | |
---|
549 | //////////////////////// |
---|
550 | // fifos update // |
---|
551 | //////////////////////// |
---|
552 | //-- to keep trace on ring traffic : a valid command is received by the target |
---|
553 | tgt_rsp.rspval = rsp_fifo_get; |
---|
554 | tgt_rsp.flit = m_rsp_fifo.read(); |
---|
555 | tgt_rsp.state = ring_rsp_fsm_state_str_t[r_ring_rsp_fsm]; |
---|
556 | |
---|
557 | tgt_cmd_val = cmd_fifo_put; |
---|
558 | //tgt_rsp_val = rsp_fifo_get; |
---|
559 | // local cmd fifo update |
---|
560 | if ( cmd_fifo_put && cmd_fifo_get ) m_cmd_fifo.put_and_get(cmd_fifo_data); |
---|
561 | else if ( cmd_fifo_put && !cmd_fifo_get ) m_cmd_fifo.simple_put(cmd_fifo_data); |
---|
562 | else if ( !cmd_fifo_put && cmd_fifo_get ) m_cmd_fifo.simple_get(); |
---|
563 | // local rsp fifo update |
---|
564 | if ( rsp_fifo_put && rsp_fifo_get ) m_rsp_fifo.put_and_get(rsp_fifo_data); |
---|
565 | else if ( rsp_fifo_put && !rsp_fifo_get ) m_rsp_fifo.simple_put(rsp_fifo_data); |
---|
566 | else if ( !rsp_fifo_put && rsp_fifo_get ) m_rsp_fifo.simple_get(); |
---|
567 | |
---|
568 | |
---|
569 | #ifdef T_DEBUG |
---|
570 | m_cpt +=1; |
---|
571 | #endif |
---|
572 | } // end Transition() |
---|
573 | |
---|
574 | /////////////////////////////////////////////////////////////////// |
---|
575 | void genMoore(cmd_out_t &p_cmd_out, rsp_in_t &p_rsp_in) |
---|
576 | /////////////////////////////////////////////////////////////////// |
---|
577 | { |
---|
578 | p_cmd_out.write = m_cmd_fifo.rok(); |
---|
579 | p_cmd_out.data = (sc_dt::sc_uint<ring_cmd_data_size>) m_cmd_fifo.read(); |
---|
580 | |
---|
581 | p_rsp_in.read = m_rsp_fifo.wok(); |
---|
582 | |
---|
583 | } // end genMoore |
---|
584 | |
---|
585 | /////////////////////////////////////////////////////////////////// |
---|
586 | void update_ring_signals(ring_signal_t p_ring_in, ring_signal_t &p_ring_out) |
---|
587 | /////////////////////////////////////////////////////////////////// |
---|
588 | { |
---|
589 | |
---|
590 | switch( r_ring_rsp_fsm ) |
---|
591 | { |
---|
592 | case RSP_IDLE: |
---|
593 | p_ring_out.rsp_grant = !m_rsp_fifo.rok() && p_ring_in.rsp_grant; |
---|
594 | |
---|
595 | p_ring_out.rsp_palloc = p_ring_in.rsp_palloc; |
---|
596 | p_ring_out.rsp_preempt = p_ring_in.rsp_preempt; |
---|
597 | |
---|
598 | p_ring_out.rsp_w = p_ring_in.rsp_w; |
---|
599 | p_ring_out.rsp_data = p_ring_in.rsp_data; |
---|
600 | |
---|
601 | break; |
---|
602 | |
---|
603 | case OWNER: |
---|
604 | { |
---|
605 | bool eop = ( (int) ((m_rsp_fifo.read() >> (ring_rsp_data_size - 1) ) & 0x1) == 1); |
---|
606 | p_ring_out.rsp_grant = (!m_rsp_fifo.rok() || (eop && p_ring_in.rsp_r)) ; |
---|
607 | |
---|
608 | p_ring_out.rsp_palloc = 0; |
---|
609 | p_ring_out.rsp_preempt = 0; |
---|
610 | |
---|
611 | p_ring_out.rsp_w = m_rsp_fifo.rok(); |
---|
612 | p_ring_out.rsp_data = m_rsp_fifo.read(); |
---|
613 | |
---|
614 | } |
---|
615 | break; |
---|
616 | |
---|
617 | case SENDING: |
---|
618 | { |
---|
619 | bool eop = ( (int) ((m_rsp_fifo.read() >> (ring_rsp_data_size - 1) ) & 0x1) == 1); |
---|
620 | |
---|
621 | p_ring_out.rsp_palloc = p_ring_in.rsp_palloc; |
---|
622 | p_ring_out.rsp_preempt = p_ring_in.rsp_preempt; |
---|
623 | |
---|
624 | // if preempt : Init Gate is sending to Local Target, ring preempted |
---|
625 | if (p_ring_in.rsp_preempt) |
---|
626 | { |
---|
627 | p_ring_out.rsp_w = p_ring_in.rsp_w; |
---|
628 | p_ring_out.rsp_data = p_ring_in.rsp_data; |
---|
629 | p_ring_out.rsp_grant = 0; |
---|
630 | } |
---|
631 | else |
---|
632 | { |
---|
633 | p_ring_out.rsp_w = m_rsp_fifo.rok(); |
---|
634 | p_ring_out.rsp_data = m_rsp_fifo.read(); |
---|
635 | p_ring_out.rsp_grant = m_rsp_fifo.rok() && p_ring_in.rsp_r && eop && !p_ring_in.rsp_palloc; |
---|
636 | } |
---|
637 | } |
---|
638 | break; |
---|
639 | |
---|
640 | case WAIT_PALLOC_END: |
---|
641 | { |
---|
642 | bool eop = ((int) (p_ring_in.rsp_data >> (ring_rsp_data_size - 1) ) & 0x1) == 1; |
---|
643 | |
---|
644 | p_ring_out.rsp_grant = p_ring_in.rsp_w && p_ring_in.rsp_r && eop; |
---|
645 | |
---|
646 | p_ring_out.rsp_palloc = p_ring_in.rsp_palloc; |
---|
647 | p_ring_out.rsp_preempt = p_ring_in.rsp_preempt; |
---|
648 | |
---|
649 | p_ring_out.rsp_w = p_ring_in.rsp_w; //p_ring_in.rsp_preempt; |
---|
650 | p_ring_out.rsp_data = p_ring_in.rsp_data; |
---|
651 | } |
---|
652 | break; |
---|
653 | } // end switch |
---|
654 | |
---|
655 | p_ring_out.rsp_header = p_ring_in.rsp_header; |
---|
656 | p_ring_out.rsp_r = p_ring_in.rsp_r; |
---|
657 | |
---|
658 | p_ring_out.cmd_w = p_ring_in.cmd_w; |
---|
659 | p_ring_out.cmd_data = p_ring_in.cmd_data; |
---|
660 | |
---|
661 | p_ring_out.cmd_grant = p_ring_in.cmd_grant; |
---|
662 | |
---|
663 | p_ring_out.cmd_preempt = p_ring_in.cmd_preempt; |
---|
664 | p_ring_out.cmd_header = p_ring_in.cmd_header; |
---|
665 | p_ring_out.cmd_palloc = p_ring_in.cmd_palloc; |
---|
666 | |
---|
667 | switch( r_ring_cmd_fsm ) |
---|
668 | { |
---|
669 | case CMD_IDLE: |
---|
670 | { |
---|
671 | vci_addr_t rtgtid = (vci_addr_t) (((p_ring_in.cmd_data >> (ring_cmd_data_size-vci_param::S-1)) << (vci_param::N-vci_param::S))); |
---|
672 | bool islocalm = m_lt[rtgtid] && (m_rt[rtgtid] == m_tgtid); // multicast |
---|
673 | bool isbrdcst = (p_ring_in.cmd_data & 0x1) == 0x1; |
---|
674 | bool islocalb = ( (int) ((p_ring_in.cmd_data >> 1 ) & 0xF) == m_tgtid); // broadcast |
---|
675 | |
---|
676 | if (p_ring_in.cmd_w && ((isbrdcst && islocalb) || (!isbrdcst && islocalm))) |
---|
677 | { |
---|
678 | p_ring_out.cmd_r = m_cmd_fifo.wok(); |
---|
679 | } |
---|
680 | else |
---|
681 | { |
---|
682 | p_ring_out.cmd_r = p_ring_in.cmd_r; |
---|
683 | } |
---|
684 | |
---|
685 | } |
---|
686 | break; |
---|
687 | |
---|
688 | case ALLOC: |
---|
689 | p_ring_out.cmd_r = m_cmd_fifo.wok(); |
---|
690 | break; |
---|
691 | |
---|
692 | case NALLOC: |
---|
693 | { |
---|
694 | vci_addr_t rtgtid = (vci_addr_t) (((p_ring_in.cmd_data >> (ring_cmd_data_size-vci_param::S-1)) << (vci_param::N-vci_param::S))); |
---|
695 | bool islocalm = m_lt[rtgtid] && (m_rt[rtgtid] == m_tgtid); // multicast |
---|
696 | bool isbrdcst = (p_ring_in.cmd_data & 0x1) == 0x1; |
---|
697 | bool islocalb = ( (int) ((p_ring_in.cmd_data >> 1 ) & 0xF) == m_tgtid); // broadcast |
---|
698 | |
---|
699 | if (p_ring_in.cmd_preempt && p_ring_in.cmd_header && ((isbrdcst && islocalb) || (!isbrdcst && islocalm))) |
---|
700 | p_ring_out.cmd_r = m_cmd_fifo.wok(); |
---|
701 | else |
---|
702 | p_ring_out.cmd_r = p_ring_in.cmd_r; |
---|
703 | |
---|
704 | } |
---|
705 | break; |
---|
706 | |
---|
707 | case PALLOC2: |
---|
708 | if(p_ring_in.cmd_preempt) |
---|
709 | p_ring_out.cmd_r = m_cmd_fifo.wok(); |
---|
710 | else |
---|
711 | p_ring_out.cmd_r = p_ring_in.cmd_r; |
---|
712 | break; |
---|
713 | |
---|
714 | case PALLOC1: |
---|
715 | p_ring_out.cmd_r = m_cmd_fifo.wok(); |
---|
716 | break; |
---|
717 | |
---|
718 | } // end switch |
---|
719 | |
---|
720 | } // end update_ring_signals |
---|
721 | |
---|
722 | }; |
---|
723 | |
---|
724 | }} // end namespace |
---|
725 | #endif // SOCLIB_CABA_DSPIN_ALLOC_RING_TARGET_FAST_H |
---|
726 | |
---|