source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Core_Glue/src/Core_Glue_genMealy_issue.cpp

Last change on this file was 138, checked in by rosiere, 14 years ago

1) add counters_t type for interface
2) fix in check load in load_store_unit
3) add parameters (but not yet implemented)
4) change environment and add script (distcc_env.sh ...)
5) add warning if an unser change rename flag with l.mtspr instruction
6) ...

  • Property svn:keywords set to Id
File size: 12.7 KB
Line 
1#ifdef SYSTEMC
2/*
3 * $Id: Core_Glue_genMealy_issue.cpp 138 2010-05-12 17:34:01Z rosiere $
4 *
5 * [ Description ]
6 *
7 */
8
9#include "Behavioural/Core/Core_Glue/include/Core_Glue.h"
10#include "Common/include/Max.h"
11
12namespace morpheo                    {
13namespace behavioural {
14namespace core {
15namespace core_glue {
16
17  /*
18      OOO     Execute Loop                                 
19    ---+          +-----
20       |  +-----+ |     
21      -+->|     |-+->   
22       |  |     | |     
23      -+->|     |-+->   
24       |  |     | |     
25      -+->|     | +-----
26       |  |     |       
27      -+->|     | +-----
28       |  |     | |     
29    ---+  | _ _ |-+->   
30          | _X_ | |     
31    ---+  |     |-+->   
32       |  |     | |     
33      -+->|     | +-----
34       |  |     |       
35      -+->|     | +-----
36       |  |     | |     
37      -+->|     |-+->   
38       |  |     | |     
39      -+->|     |-+->   
40       |  +-----+ |     
41    ---+ dispatch +-----
42  */
43
44
45// class num_read_unit_t
46//   {
47//   public : const uint32_t num_execute_loop;
48//   public : const uint32_t num_read_unit;
49   
50//   public : num_read_unit_t (uint32_t num_execute_loop,
51//                             uint32_t num_read_unit) :
52//     this->num_execute_loop (num_execute_loop),
53//     this->num_read_unit    (num_read_unit   )
54//     {};
55//   }
56
57#undef  FUNCTION
58#define FUNCTION "Core_Glue::genMealy_issue"
59  void Core_Glue::genMealy_issue (void)
60  {
61    log_begin(Core_Glue,FUNCTION);
62    log_function(Core_Glue,FUNCTION,_name.c_str());
63
64    Tcontrol_t ISSUE_OOO_ENGINE_ACK   [_param->_nb_ooo_engine  ][_param->_max_nb_inst_issue_queue];
65    Tcontrol_t ISSUE_EXECUTE_LOOP_VAL [_param->_nb_execute_loop][_param->_max_nb_read_unit];
66
67    for (uint32_t i=0; i<_param->_nb_ooo_engine; ++i)
68      for (uint32_t j=0; j<_param->_nb_inst_issue_queue[i]; ++j)
69        ISSUE_OOO_ENGINE_ACK [i][j] = 0;
70    for (uint32_t i=0; i<_param->_nb_execute_loop; ++i)
71      for (uint32_t j=0; j<_param->_nb_read_unit[i]; ++j)
72        ISSUE_EXECUTE_LOOP_VAL [i][j] = 0;
73   
74    if (PORT_READ(in_NRESET))
75      {
76    Tcontrol_t READ_UNIT_ENABLE       [_param->_nb_execute_loop][_param->_max_nb_read_unit];
77   
78    // Init -> all at 0
79    for (uint32_t i=0; i<_param->_nb_execute_loop; ++i)
80      for (uint32_t j=0; j<_param->_nb_read_unit[i]; ++j)
81        {
82          // Read unit is enable is signal ack is set
83          READ_UNIT_ENABLE       [i][j] = (PORT_READ(in_ISSUE_EXECUTE_LOOP_ACK [i][j]) == 1);
84          log_printf(TRACE,Core_Glue,FUNCTION,"  * Read_unit [%d][%d].enable : %d",i,j,READ_UNIT_ENABLE[i][j]);
85        }
86
87    std::list<generic::priority::select_t> * select_ooo_engine = _priority_ooo_engine->select();
88    for (std::list<generic::priority::select_t>::iterator it_ooo_engine=select_ooo_engine->begin();
89         it_ooo_engine!=select_ooo_engine->end();
90         ++it_ooo_engine)
91      {
92        // select the most priotary
93        uint32_t num_ooo_engine = it_ooo_engine->grp;
94
95        for (uint32_t num_inst_issue_queue=0; num_inst_issue_queue<_param->_nb_inst_issue_queue[num_ooo_engine]; ++num_inst_issue_queue)
96          {
97            // init stop condition
98            bool find = false;
99           
100            // Read request information from issue_queue
101            Tcontrol_t val          = PORT_READ(in_ISSUE_OOO_ENGINE_VAL  [num_ooo_engine][num_inst_issue_queue]);
102            Ttype_t    type         = PORT_READ(in_ISSUE_OOO_ENGINE_TYPE [num_ooo_engine][num_inst_issue_queue]);
103            Tcontext_t context_id   = (_param->_have_port_context_id  )?PORT_READ(in_ISSUE_OOO_ENGINE_CONTEXT_ID   [num_ooo_engine][num_inst_issue_queue]):0;
104            Tcontext_t front_end_id = (_param->_have_port_front_end_id)?PORT_READ(in_ISSUE_OOO_ENGINE_FRONT_END_ID [num_ooo_engine][num_inst_issue_queue]):0;
105            uint32_t   num_thread    = _param->_translate_num_context_to_num_thread[num_ooo_engine][front_end_id][context_id];
106           
107            log_printf(TRACE,Core_Glue,FUNCTION,"  * num_ooo_engine                : %d",num_ooo_engine      );
108            log_printf(TRACE,Core_Glue,FUNCTION,"  * num_inst_issue_queue          : %d",num_inst_issue_queue);
109            log_printf(TRACE,Core_Glue,FUNCTION,"    * val                         : %d",val);
110            log_printf(TRACE,Core_Glue,FUNCTION,"    * type                        : %d",type); 
111            log_printf(TRACE,Core_Glue,FUNCTION,"    * context_id                  : %d",context_id);
112            log_printf(TRACE,Core_Glue,FUNCTION,"    * front_end_id                : %d",front_end_id);
113            log_printf(TRACE,Core_Glue,FUNCTION,"    * num_thread                  : %d",num_thread);
114         
115            if (val)
116              // for each execute_loop
117              for (uint32_t num_execute_loop=0; num_execute_loop<_param->_nb_execute_loop; ++num_execute_loop)
118                {
119                  // for each read_unit
120                  std::list<generic::priority::select_t> * select_read_unit = _priority_read_unit[num_execute_loop]->select();
121                  for (std::list<generic::priority::select_t>::iterator it_read_unit=select_read_unit->begin();
122                       it_read_unit!=select_read_unit->end();
123                       ++it_read_unit)
124                    {
125                      // get the most priotary ...
126                      uint32_t num_read_unit = it_read_unit->grp;
127                      Tcontrol_t ack = READ_UNIT_ENABLE [num_execute_loop][num_read_unit];
128                     
129                      log_printf(TRACE,Core_Glue,FUNCTION,"      * num_execute_loop          : %d",num_execute_loop);
130                      log_printf(TRACE,Core_Glue,FUNCTION,"      * num_read_unit             : %d",num_read_unit   );
131                      log_printf(TRACE,Core_Glue,FUNCTION,"        * read_unit_enable        : %d",ack             );
132                     
133                      // test if :
134                      //  * read_unit can accept an instruction (valid and no previous instruction)
135                      //  * read_unit can accept this type
136                      if (ack and
137                          _param->_table_issue_type   [num_execute_loop][num_read_unit][type] and
138                          _param->_table_issue_thread [num_execute_loop][num_read_unit][num_thread])
139                        {
140                          log_printf(TRACE,Core_Glue,FUNCTION,"  * find !!!");
141                         
142                          // find !
143                          // Transaction
144                          find = true;
145
146                          READ_UNIT_ENABLE       [num_execute_loop][num_read_unit] = false; // now, this read_unit is busy
147                          ISSUE_EXECUTE_LOOP_VAL [num_execute_loop][num_read_unit] = 1; // = val
148                          ISSUE_OOO_ENGINE_ACK   [num_ooo_engine][num_inst_issue_queue] = 1; // = ack
149                         
150                          if (_param->_have_port_context_id)
151                          PORT_WRITE(out_ISSUE_EXECUTE_LOOP_CONTEXT_ID            [num_execute_loop][num_read_unit],context_id);
152                          if (_param->_have_port_front_end_id)
153                          PORT_WRITE(out_ISSUE_EXECUTE_LOOP_FRONT_END_ID          [num_execute_loop][num_read_unit],front_end_id);
154                          if (_param->_have_port_ooo_engine_id)
155                            {
156                          Tcontext_t ooo_engine_id = _param->_translate_num_ooo_engine_to_execute_loop_ooo_engine_id [num_ooo_engine][num_execute_loop];
157                          PORT_WRITE(out_ISSUE_EXECUTE_LOOP_OOO_ENGINE_ID         [num_execute_loop][num_read_unit],ooo_engine_id);
158                            }
159                          if (_param->_have_port_rob_ptr)
160                          PORT_WRITE(out_ISSUE_EXECUTE_LOOP_PACKET_ID             [num_execute_loop][num_read_unit],PORT_READ(in_ISSUE_OOO_ENGINE_PACKET_ID             [num_ooo_engine][num_inst_issue_queue]));
161                          PORT_WRITE(out_ISSUE_EXECUTE_LOOP_OPERATION             [num_execute_loop][num_read_unit],PORT_READ(in_ISSUE_OOO_ENGINE_OPERATION             [num_ooo_engine][num_inst_issue_queue]));
162                          PORT_WRITE(out_ISSUE_EXECUTE_LOOP_TYPE                  [num_execute_loop][num_read_unit],type);
163                          PORT_WRITE(out_ISSUE_EXECUTE_LOOP_CANCEL                [num_execute_loop][num_read_unit],PORT_READ(in_ISSUE_OOO_ENGINE_CANCEL                [num_ooo_engine][num_inst_issue_queue]));
164                          PORT_WRITE(out_ISSUE_EXECUTE_LOOP_STORE_QUEUE_PTR_WRITE [num_execute_loop][num_read_unit],PORT_READ(in_ISSUE_OOO_ENGINE_STORE_QUEUE_PTR_WRITE [num_ooo_engine][num_inst_issue_queue]));
165                          PORT_WRITE(out_ISSUE_EXECUTE_LOOP_STORE_QUEUE_PTR_READ  [num_execute_loop][num_read_unit],PORT_READ(in_ISSUE_OOO_ENGINE_STORE_QUEUE_PTR_READ  [num_ooo_engine][num_inst_issue_queue]));
166                          PORT_WRITE(out_ISSUE_EXECUTE_LOOP_STORE_QUEUE_EMPTY     [num_execute_loop][num_read_unit],PORT_READ(in_ISSUE_OOO_ENGINE_STORE_QUEUE_EMPTY     [num_ooo_engine][num_inst_issue_queue]));
167                          if (_param->_have_port_load_queue_ptr)
168                          PORT_WRITE(out_ISSUE_EXECUTE_LOOP_LOAD_QUEUE_PTR_WRITE  [num_execute_loop][num_read_unit],PORT_READ(in_ISSUE_OOO_ENGINE_LOAD_QUEUE_PTR_WRITE  [num_ooo_engine][num_inst_issue_queue]));
169                          PORT_WRITE(out_ISSUE_EXECUTE_LOOP_HAS_IMMEDIAT          [num_execute_loop][num_read_unit],PORT_READ(in_ISSUE_OOO_ENGINE_HAS_IMMEDIAT          [num_ooo_engine][num_inst_issue_queue]));
170                          PORT_WRITE(out_ISSUE_EXECUTE_LOOP_IMMEDIAT              [num_execute_loop][num_read_unit],PORT_READ(in_ISSUE_OOO_ENGINE_IMMEDIAT              [num_ooo_engine][num_inst_issue_queue]));
171                          PORT_WRITE(out_ISSUE_EXECUTE_LOOP_READ_RA               [num_execute_loop][num_read_unit],PORT_READ(in_ISSUE_OOO_ENGINE_READ_RA               [num_ooo_engine][num_inst_issue_queue]));
172                          PORT_WRITE(out_ISSUE_EXECUTE_LOOP_NUM_REG_RA            [num_execute_loop][num_read_unit],PORT_READ(in_ISSUE_OOO_ENGINE_NUM_REG_RA            [num_ooo_engine][num_inst_issue_queue]));
173                          PORT_WRITE(out_ISSUE_EXECUTE_LOOP_READ_RB               [num_execute_loop][num_read_unit],PORT_READ(in_ISSUE_OOO_ENGINE_READ_RB               [num_ooo_engine][num_inst_issue_queue]));
174                          PORT_WRITE(out_ISSUE_EXECUTE_LOOP_NUM_REG_RB            [num_execute_loop][num_read_unit],PORT_READ(in_ISSUE_OOO_ENGINE_NUM_REG_RB            [num_ooo_engine][num_inst_issue_queue]));
175                          PORT_WRITE(out_ISSUE_EXECUTE_LOOP_READ_RC               [num_execute_loop][num_read_unit],PORT_READ(in_ISSUE_OOO_ENGINE_READ_RC               [num_ooo_engine][num_inst_issue_queue]));
176                          PORT_WRITE(out_ISSUE_EXECUTE_LOOP_NUM_REG_RC            [num_execute_loop][num_read_unit],PORT_READ(in_ISSUE_OOO_ENGINE_NUM_REG_RC            [num_ooo_engine][num_inst_issue_queue]));
177                          PORT_WRITE(out_ISSUE_EXECUTE_LOOP_WRITE_RD              [num_execute_loop][num_read_unit],PORT_READ(in_ISSUE_OOO_ENGINE_WRITE_RD              [num_ooo_engine][num_inst_issue_queue]));
178                          PORT_WRITE(out_ISSUE_EXECUTE_LOOP_NUM_REG_RD            [num_execute_loop][num_read_unit],PORT_READ(in_ISSUE_OOO_ENGINE_NUM_REG_RD            [num_ooo_engine][num_inst_issue_queue]));
179                          PORT_WRITE(out_ISSUE_EXECUTE_LOOP_WRITE_RE              [num_execute_loop][num_read_unit],PORT_READ(in_ISSUE_OOO_ENGINE_WRITE_RE              [num_ooo_engine][num_inst_issue_queue]));
180                          PORT_WRITE(out_ISSUE_EXECUTE_LOOP_NUM_REG_RE            [num_execute_loop][num_read_unit],PORT_READ(in_ISSUE_OOO_ENGINE_NUM_REG_RE            [num_ooo_engine][num_inst_issue_queue]));
181                          break;
182                        }
183                      //if (find)
184                      //  break;
185                    }
186                  if (find)
187                    break;
188                }
189           
190            if (_param->_issue_queue_in_order [num_ooo_engine] and
191                not find and
192                (num_inst_issue_queue >= _param->_nb_inst_reexecute [num_ooo_engine]))
193              {
194                log_printf(TRACE,Core_Glue,FUNCTION,"  * stop scan !!!");
195               
196                break; // stop scan
197              }
198          }
199      }
200   
201      }
202
203    // Write output
204    for (uint32_t i=0; i<_param->_nb_ooo_engine; ++i)
205      for (uint32_t j=0; j<_param->_nb_inst_issue_queue[i]; ++j)
206        PORT_WRITE(out_ISSUE_OOO_ENGINE_ACK [i][j], ISSUE_OOO_ENGINE_ACK [i][j]);
207    for (uint32_t i=0; i<_param->_nb_execute_loop; ++i)
208      for (uint32_t j=0; j<_param->_nb_read_unit[i]; ++j)
209        PORT_WRITE(out_ISSUE_EXECUTE_LOOP_VAL [i][j], ISSUE_EXECUTE_LOOP_VAL [i][j]);
210
211    log_end(Core_Glue,FUNCTION);
212  };
213
214}; // end namespace core_glue
215}; // end namespace core
216
217}; // end namespace behavioural
218}; // end namespace morpheo             
219#endif
Note: See TracBrowser for help on using the repository browser.