source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Execute_loop/Execute_loop/Multi_Read_unit/Read_unit/Read_queue/src/Read_queue_transition.cpp @ 76

Last change on this file since 76 was 76, checked in by rosiere, 16 years ago

Add new component : Read_unit (no tested)
Change functionnal_unit : now use type and operation to execute the good function
Change New_Component's script

File size: 5.4 KB
Line 
1#ifdef SYSTEMC
2//#if defined(STATISTICS) or defined(VHDL_TESTBENCH)
3/*
4 * $Id$
5 *
6 * [ Description ]
7 *
8 */
9
10#include "Behavioural/Core/Multi_Execute_loop/Execute_loop/Multi_Read_unit/Read_unit/Read_queue/include/Read_queue.h"
11
12namespace morpheo                    {
13namespace behavioural {
14namespace core {
15namespace multi_execute_loop {
16namespace execute_loop {
17namespace multi_read_unit {
18namespace read_unit {
19namespace read_queue {
20
21
22#undef  FUNCTION
23#define FUNCTION "Read_queue::transition"
24  void Read_queue::transition (void)
25  {
26    log_printf(FUNC,Read_queue,FUNCTION,"Begin");
27
28    if (PORT_READ(in_NRESET) == 0)
29      {
30        // Flush queue
31        // FIXME "queue reset"
32        // > 1) flush one slot by cycle
33        // > 2) flush all slot in one cycle
34
35        while (_queue->empty() == false)
36          _queue->pop();
37      }
38    else
39      {
40//      cout << "Transition Begin  : Print queue_head" << endl;
41//      if (_queue->empty ())
42//        cout << "queue is empty !!!" << endl;
43//      else
44//        cout << (*_queue_head) << endl;
45
46        log_printf(TRACE,Read_queue,FUNCTION,"Read_queue size (begin) : %d",_queue->size());
47        // Write to read_queue
48
49        bool not_full      = not (_queue->size() == _param->_size_queue);
50        bool     empty     =     _queue->empty();
51        bool need_new_head = false;
52       
53        log_printf(TRACE,Read_queue,FUNCTION," * test transaction READ_QUEUE_IN  : %d,%d",PORT_READ(in_READ_QUEUE_IN_VAL), not_full);
54        if ((PORT_READ(in_READ_QUEUE_IN_VAL) == 1) and not_full)
55          {
56            Tread_queue_entry_t * entry = new Tread_queue_entry_t;
57
58            if(_param->_have_port_context_id   )
59              entry->_context_id   = PORT_READ(in_READ_QUEUE_IN_CONTEXT_ID  );
60            if(_param->_have_port_front_end_id )
61              entry->_front_end_id = PORT_READ(in_READ_QUEUE_IN_FRONT_END_ID);
62            if(_param->_have_port_ooo_engine_id)
63              entry->_ooo_engine_id= PORT_READ(in_READ_QUEUE_IN_OOO_ENGINE_ID);
64            if(_param->_have_port_rob_id       )
65              entry->_rob_id       = PORT_READ(in_READ_QUEUE_IN_ROB_ID      );
66            entry->_operation    = PORT_READ(in_READ_QUEUE_IN_OPERATION   );
67            entry->_type         = PORT_READ(in_READ_QUEUE_IN_TYPE        );
68            entry->_store_queue_ptr_write = PORT_READ(in_READ_QUEUE_IN_STORE_QUEUE_PTR_WRITE);
69            entry->_load_queue_ptr_write  = PORT_READ(in_READ_QUEUE_IN_LOAD_QUEUE_PTR_WRITE );
70            entry->_has_immediat = PORT_READ(in_READ_QUEUE_IN_HAS_IMMEDIAT);
71            entry->_immediat     = PORT_READ(in_READ_QUEUE_IN_IMMEDIAT    );
72            entry->_read_ra      = PORT_READ(in_READ_QUEUE_IN_READ_RA     );
73            entry->_num_reg_ra   = PORT_READ(in_READ_QUEUE_IN_NUM_REG_RA  );
74            entry->_read_rb      = PORT_READ(in_READ_QUEUE_IN_READ_RB     );
75            entry->_num_reg_rb   = PORT_READ(in_READ_QUEUE_IN_NUM_REG_RB  );
76            entry->_read_rc      = PORT_READ(in_READ_QUEUE_IN_READ_RC     );
77            entry->_num_reg_rc   = PORT_READ(in_READ_QUEUE_IN_NUM_REG_RC  );
78            entry->_write_rd     = PORT_READ(in_READ_QUEUE_IN_WRITE_RD    );
79            entry->_num_reg_rd   = PORT_READ(in_READ_QUEUE_IN_NUM_REG_RD  );
80            entry->_write_re     = PORT_READ(in_READ_QUEUE_IN_WRITE_RE    );
81            entry->_num_reg_re   = PORT_READ(in_READ_QUEUE_IN_NUM_REG_RE  );
82
83            log_printf(TRACE,Read_queue,FUNCTION,"   * push (id : %d-%d)",entry->_context_id, entry->_rob_id);
84            _queue->push(entry);
85
86
87            // read next new head
88            if (empty)
89              {
90                log_printf(TRACE,Read_queue,FUNCTION,"     * queue was    empty");
91                need_new_head = true;
92              }
93          }
94
95        // Read from read_queue
96        log_printf(TRACE,Read_queue,FUNCTION," * test transaction READ_QUEUE_OUT : %d,%d",internal_READ_QUEUE_OUT_VAL, PORT_READ(in_READ_QUEUE_OUT_ACK));
97        if ((    internal_READ_QUEUE_OUT_VAL  == 1) and
98            (PORT_READ(in_READ_QUEUE_OUT_ACK) == 1))
99          {
100            // Pop the entry
101            log_printf(TRACE,Read_queue,FUNCTION,"   * pop  (id : %d-%d)",_queue->front()->_context_id, _queue->front()->_rob_id);
102            _queue->pop();
103
104            // read next new head
105            if (_queue->empty() == false)
106              {
107                log_printf(TRACE,Read_queue,FUNCTION,"     * queue was not empty");
108                need_new_head = true;
109              }
110          }
111        else
112          {
113            // no transaction, update queue_head
114            _queue_head->_read_ra_val = internal_READ_QUEUE_OUT_READ_RA_VAL ;
115            _queue_head->_data_ra_val = internal_READ_QUEUE_OUT_DATA_RA_VAL ;
116            _queue_head->_data_ra     = internal_READ_QUEUE_OUT_DATA_RA     ;
117
118            _queue_head->_read_rb_val = internal_READ_QUEUE_OUT_READ_RB_VAL ;
119            _queue_head->_data_rb_val = internal_READ_QUEUE_OUT_DATA_RB_VAL ;
120            _queue_head->_data_rb     = internal_READ_QUEUE_OUT_DATA_RB     ;
121
122            _queue_head->_read_rc_val = internal_READ_QUEUE_OUT_READ_RC_VAL ;
123            _queue_head->_data_rc_val = internal_READ_QUEUE_OUT_DATA_RC_VAL ;
124            _queue_head->_data_rc     = internal_READ_QUEUE_OUT_DATA_RC     ;
125          }
126
127        if (need_new_head == true)
128          {
129            log_printf(TRACE,Read_queue,FUNCTION," * new head");
130            (*_queue_head) = (*_queue->front());
131          }
132       
133//      cout << "Transition End    : Print queue_head" << endl;
134//      if (_queue->empty ())
135//        cout << "queue is empty !!!" << endl;
136//      else
137//        cout << (*_queue_head) << endl;
138
139        log_printf(TRACE,Read_queue,FUNCTION,"Read_queue size (end  ) : %d",_queue->size());
140      }
141
142#if defined(STATISTICS) or defined(VHDL_TESTBENCH)
143    end_cycle ();
144#endif
145
146    log_printf(FUNC,Read_queue,FUNCTION,"End");
147  };
148
149}; // end namespace read_queue
150}; // end namespace read_unit
151}; // end namespace multi_read_unit
152}; // end namespace execute_loop
153}; // end namespace multi_execute_loop
154}; // end namespace core
155
156}; // end namespace behavioural
157}; // end namespace morpheo             
158#endif
159//#endif
Note: See TracBrowser for help on using the repository browser.