source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Decod_unit/Decod_queue/src/Decod_queue_transition.cpp @ 108

Last change on this file since 108 was 108, checked in by rosiere, 15 years ago

1) decod_queue : add reg_LAST_SLOT.
2) Commit : insert on event -> to pop decod_queue. Head test : add information (speculative or not)
3) Context State / UPT : Branch miss and Load miss in same cycle.
4) Free List : Bank is on LSB not MSB.
5) Platforms : move data

  • Property svn:keywords set to Id
File size: 7.1 KB
Line 
1#ifdef SYSTEMC
2/*
3 * $Id: Decod_queue_transition.cpp 108 2009-02-12 11:55:06Z rosiere $
4 *
5 * [ Description ]
6 *
7 */
8
9#include "Behavioural/Core/Multi_Front_end/Front_end/Decod_unit/Decod_queue/include/Decod_queue.h"
10
11namespace morpheo                    {
12namespace behavioural {
13namespace core {
14namespace multi_front_end {
15namespace front_end {
16namespace decod_unit {
17namespace decod_queue {
18
19
20#undef  FUNCTION
21#define FUNCTION "Decod_queue::transition"
22  void Decod_queue::transition (void)
23  {
24    log_begin(Decod_queue,FUNCTION);
25    log_function(Decod_queue,FUNCTION,_name.c_str());
26
27    if (PORT_READ(in_NRESET) == 0)
28      {
29        reg_QUEUE->clear();
30
31        for (uint32_t i=0; i<_param->_nb_context; i++)
32          reg_NB_INST [i]=0;
33
34        reg_LAST_SLOT = 0;
35      }
36    else
37      {
38        //--------------------------------------------------------------------
39        //-----[ DECOD_IN ]---------------------------------------------------
40        //-------------------------------------------------------------------- 
41        decod_queue_entry_t * entry = NULL;
42        for (uint32_t i=0; i<_param->_nb_inst_decod; i++)
43          {
44            if (PORT_READ(in_DECOD_IN_VAL [i]) and internal_DECOD_IN_ACK[i])
45              {
46                log_printf(TRACE,Decod_queue,FUNCTION,_("  * DECOD_IN  [%d]"),i);
47
48                if (entry == NULL)
49                 {
50                   // Once creation and insert in queue
51                   entry = new decod_queue_entry_t (_param->_nb_inst_decod);
52                   reg_QUEUE->push_back(entry);
53                 }
54
55                Tcontext_t context = (_param->_have_port_context_id)?PORT_READ(in_DECOD_IN_CONTEXT_ID [i]):0;
56
57                log_printf(TRACE,Decod_queue,FUNCTION,_("    * context : %d"),context);
58
59                entry->_val           [i] = 1;
60                entry->_context_id    [i] = context;
61                entry->_depth         [i] = (_param->_have_port_depth)?PORT_READ(in_DECOD_IN_DEPTH [i]):0;
62                entry->_type          [i] = PORT_READ(in_DECOD_IN_TYPE          [i]);
63                entry->_operation     [i] = PORT_READ(in_DECOD_IN_OPERATION     [i]);
64                entry->_no_execute    [i] = PORT_READ(in_DECOD_IN_NO_EXECUTE    [i]);
65                entry->_is_delay_slot [i] = PORT_READ(in_DECOD_IN_IS_DELAY_SLOT [i]);
66#ifdef DEBUG
67                entry->_address       [i] = PORT_READ(in_DECOD_IN_ADDRESS       [i]);
68#endif
69                entry->_address_next  [i] = PORT_READ(in_DECOD_IN_ADDRESS_NEXT  [i]);
70                entry->_has_immediat  [i] = PORT_READ(in_DECOD_IN_HAS_IMMEDIAT  [i]);
71                entry->_immediat      [i] = PORT_READ(in_DECOD_IN_IMMEDIAT      [i]);
72                entry->_read_ra       [i] = PORT_READ(in_DECOD_IN_READ_RA       [i]);
73                entry->_num_reg_ra    [i] = PORT_READ(in_DECOD_IN_NUM_REG_RA    [i]);
74                entry->_read_rb       [i] = PORT_READ(in_DECOD_IN_READ_RB       [i]);
75                entry->_num_reg_rb    [i] = PORT_READ(in_DECOD_IN_NUM_REG_RB    [i]);
76                entry->_read_rc       [i] = PORT_READ(in_DECOD_IN_READ_RC       [i]);
77                entry->_num_reg_rc    [i] = PORT_READ(in_DECOD_IN_NUM_REG_RC    [i]);
78                entry->_write_rd      [i] = PORT_READ(in_DECOD_IN_WRITE_RD      [i]);
79                entry->_num_reg_rd    [i] = PORT_READ(in_DECOD_IN_NUM_REG_RD    [i]);
80                entry->_write_re      [i] = PORT_READ(in_DECOD_IN_WRITE_RE      [i]);
81                entry->_num_reg_re    [i] = PORT_READ(in_DECOD_IN_NUM_REG_RE    [i]);
82                entry->_exception_use [i] = PORT_READ(in_DECOD_IN_EXCEPTION_USE [i]);
83                entry->_exception     [i] = PORT_READ(in_DECOD_IN_EXCEPTION     [i]);
84
85                reg_NB_INST [context] ++;
86
87                log_printf(TRACE,Decod_queue,FUNCTION,_("    * nb_inst : %d"),reg_NB_INST [context]);
88                log_printf(TRACE,Decod_queue,FUNCTION,_("    * PUSH queue"));
89              }
90          }
91
92        //--------------------------------------------------------------------
93        //-----[ DECOD_OUT ]--------------------------------------------------
94        //--------------------------------------------------------------------
95        if (not reg_QUEUE->empty())
96          {
97            bool find = false;
98           
99            for (uint32_t i=0; i<_param->_nb_inst_decod; i++)
100              {
101                // Test transaction : if ok then invalid slot
102                // In order by rename logic
103                if (internal_DECOD_OUT_VAL [i] and internal_DECOD_OUT_ACK[i])
104                  {
105                    log_printf(TRACE,Decod_queue,FUNCTION,_("  * DECOD_OUT [%d]"),i);
106               
107#ifdef DEBUG_TEST
108                    if (reg_LAST_SLOT != i)
109                      throw ERRORMORPHEO(FUNCTION,toString(_("reg_LAST_SLOT (%d) is different at decod_out port (%d)."),reg_LAST_SLOT,i));
110#endif
111                    reg_LAST_SLOT ++;
112
113                    reg_QUEUE->front()->_val [i] = 0;
114
115                    Tcontext_t context = reg_QUEUE->front()->_context_id [i];
116                    log_printf(TRACE,Decod_queue,FUNCTION,_("    * context : %d"),context);
117                   
118                    reg_NB_INST [context] --;
119                    log_printf(TRACE,Decod_queue,FUNCTION,_("    * nb_inst : %d"),reg_NB_INST [context]);
120                  }
121                // Test if slot is (again) valid, if yes, then have less one instruction in the entry
122                find |= reg_QUEUE->front()->_val [i];
123              }
124           
125            // test if can free the entry : test if have consume all entry
126            if (not find) // no valid instruction in current slot
127              {
128                log_printf(TRACE,Decod_queue,FUNCTION,_("    * POP  queue"));
129
130                // can pop the slot
131                delete reg_QUEUE->front();
132                reg_QUEUE->pop_front();
133
134                reg_LAST_SLOT = 0;
135              }
136          }
137      }
138
139#if defined(DEBUG) and defined(DEBUG_Decod_queue) and (DEBUG >= DEBUG_TRACE)
140    log_printf(TRACE,Decod_queue,FUNCTION,"  * Dump decod_queue");
141    log_printf(TRACE,Decod_queue,FUNCTION,"    * reg_LAST_SLOT : %d",reg_LAST_SLOT);
142    uint32_t x=0;
143    for (std::list<decod_queue_entry_t*>::iterator it=reg_QUEUE->begin();
144         it!=reg_QUEUE->end();
145         it++)
146      {
147        log_printf(TRACE,Decod_queue,FUNCTION,"    * [%d] ",x);
148
149        for (uint32_t i=0; i<_param->_nb_inst_decod; i++)
150          {
151            if ((*it)->_val [i])
152              log_printf(TRACE,Decod_queue,FUNCTION,"      * [%.4d] %.1d, %.3d %.2d, %.2d %.3d %.1d %.1d, 0x%.8x (0x%.8x), %.1d 0x%.8x, %.1d %.2d, %.1d %.2d, %.1d %.2d, %.1d %.2d, %.1d %.2d, %.1d %.2d"
153                         ,i
154                         ,(*it)->_val           [i]
155                         ,(*it)->_context_id    [i]
156                         ,(*it)->_depth         [i]
157                         ,(*it)->_type          [i]
158                         ,(*it)->_operation     [i]
159                         ,(*it)->_no_execute    [i]
160                         ,(*it)->_is_delay_slot [i]
161                         ,(*it)->_address       [i]
162                         ,(*it)->_address       [i]<<2
163                         ,(*it)->_has_immediat  [i]
164                         ,(*it)->_immediat      [i]
165                         ,(*it)->_read_ra       [i]
166                         ,(*it)->_num_reg_ra    [i]
167                         ,(*it)->_read_rb       [i]
168                         ,(*it)->_num_reg_rb    [i]
169                         ,(*it)->_read_rc       [i]
170                         ,(*it)->_num_reg_rc    [i]
171                         ,(*it)->_write_rd      [i]
172                         ,(*it)->_num_reg_rd    [i]
173                         ,(*it)->_write_re      [i]
174                         ,(*it)->_num_reg_re    [i]
175                         ,(*it)->_exception_use [i]
176                         ,(*it)->_exception     [i]
177                         );
178            else
179              log_printf(TRACE,Decod_queue,FUNCTION,"      * [%d] %d"
180                         ,i
181                         ,(*it)->_val           [i]
182                         );
183
184          }
185        x++;
186      }
187#endif
188   
189#ifdef STATISTICS
190    if (usage_is_set(_usage,USE_STATISTICS))
191      { 
192        *(_stat_use_queue) += reg_QUEUE->size();
193        for (uint32_t i=0; i<_param->_nb_context; i++)
194          *(_stat_nb_inst [i]) += reg_NB_INST [i];
195      }
196#endif
197
198#if defined(STATISTICS) or defined(VHDL_TESTBENCH)
199    end_cycle ();
200#endif
201
202    log_end(Decod_queue,FUNCTION);
203  };
204
205}; // end namespace decod_queue
206}; // end namespace decod_unit
207}; // end namespace front_end
208}; // end namespace multi_front_end
209}; // end namespace core
210
211}; // end namespace behavioural
212}; // end namespace morpheo             
213#endif
Note: See TracBrowser for help on using the repository browser.