source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_OOO_Engine/OOO_Engine/Special_Register_unit/src/Special_Register_unit_transition.cpp @ 118

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

1) Stat List : scan all queue to find free register
2) Write_queue : test "genMealy" add bypass [0]
3) Functionnal_unit : add const parameters to add or not the pipeline_in
4) Load Store Unit : if load make an exception, free nb_check
5) Debug, change test to add model

  • Property svn:keywords set to Id
File size: 8.3 KB
Line 
1#ifdef SYSTEMC
2/*
3 * $Id: Special_Register_unit_transition.cpp 118 2009-05-20 22:01:32Z rosiere $
4 *
5 * [ Description ]
6 *
7 */
8
9#include "Behavioural/Core/Multi_OOO_Engine/OOO_Engine/Special_Register_unit/include/Special_Register_unit.h"
10
11namespace morpheo                    {
12namespace behavioural {
13namespace core {
14namespace multi_ooo_engine {
15namespace ooo_engine {
16namespace special_register_unit {
17
18
19#undef  FUNCTION
20#define FUNCTION "Special_Register_unit::transition"
21  void Special_Register_unit::transition (void)
22  {
23    log_begin(Special_Register_unit,FUNCTION);
24    log_function(Special_Register_unit,FUNCTION,_name.c_str());
25
26    if (PORT_READ(in_NRESET) == 0)
27      {
28        for (uint32_t i=0; i<_param->_nb_front_end; i++)
29          for (uint32_t j=0; j<_param->_nb_context[i]; j++)
30            for (uint32_t k=0; k<NB_GROUP; k++)
31              if (_param->_implement_group [i][j][k])
32                for (uint32_t l=0; l<NB_REG_GROUP[k]; l++)
33                  if (_spr_access_mode [i][j]->exist(k,l))
34                    {
35#ifdef DEBUG_TEST
36                      if (_spr [i][j][k]    == NULL)
37                        throw ERRORMORPHEO(FUNCTION,toString(_("Group [%d] is not implemented.\n"),k));
38                      if (_spr [i][j][k][l] == NULL)
39                        throw ERRORMORPHEO(FUNCTION,toString(_("Register [%d][%d] is not implemented.\n"),k,l));
40#endif
41                      log_printf(TRACE,Special_Register_unit,FUNCTION,"  * Reset SPR [%d][%d][%d][%d]",i,j,k,l);
42                      _spr [i][j][k][l]->reset();
43                    }
44
45      }
46    else
47      {
48        // ===================================================================
49        // =====[ SPR_ACCESS ]================================================
50        // ===================================================================
51        for (uint32_t i=0; i<_param->_nb_inst_reexecute; i++)
52          if (PORT_READ(in_SPR_ACCESS_VAL [i]) and internal_SPR_ACCESS_ACK [i])
53            if (PORT_READ(in_SPR_ACCESS_WEN [i]))
54              {
55                log_printf(TRACE,Special_Register_unit,FUNCTION,"  * SPR_ACCESS [%d]",i);
56
57                Tcontext_t     front_end_id = (_param->_have_port_front_end_id)?PORT_READ(in_SPR_ACCESS_FRONT_END_ID [i]):0;
58                Tcontext_t     context_id   = (_param->_have_port_context_id  )?PORT_READ(in_SPR_ACCESS_CONTEXT_ID   [i]):0;
59                Tspr_address_t num_group    = PORT_READ(in_SPR_ACCESS_NUM_GROUP [i]);
60                Tspr_address_t num_reg      = PORT_READ(in_SPR_ACCESS_NUM_REG   [i]);
61
62                log_printf(TRACE,Special_Register_unit,FUNCTION,"    * front_end_id : %d",front_end_id);
63                log_printf(TRACE,Special_Register_unit,FUNCTION,"    * context_id   : %d",context_id  );
64                log_printf(TRACE,Special_Register_unit,FUNCTION,"    * num_group    : %d",num_group   );
65                log_printf(TRACE,Special_Register_unit,FUNCTION,"    * num_reg      : %d",num_reg     );
66
67                SR * sr = static_cast<SR*>(_spr [front_end_id][context_id][GROUP_SYSTEM_AND_CONTROL][SPR_SR]);
68
69                Tcontrol_t sm    = sr->sm   ;
70                Tcontrol_t sumra = sr->sumra;
71                Tcontrol_t valid = _spr_access_mode [front_end_id][context_id]->write(spr_address_t(num_group,num_reg),
72                                                                                      sm,
73                                                                                      sumra);   
74                log_printf(TRACE,Special_Register_unit,FUNCTION,"    * SM           : %d",sm);
75                log_printf(TRACE,Special_Register_unit,FUNCTION,"    * SUMRA        : %d",sumra);
76                log_printf(TRACE,Special_Register_unit,FUNCTION,"    * valid        : %d",valid);
77
78                if (valid)
79                  {
80                    Tspr_t wdata = PORT_READ(in_SPR_ACCESS_WDATA [i]);
81
82                    log_printf(TRACE,Special_Register_unit,FUNCTION,"    * wdata        : %.8x",wdata);
83
84                    _spr[front_end_id][context_id][num_group][num_reg]->write(wdata);
85                  }
86               
87              }
88       
89        // ===================================================================
90        // =====[ SPR_COMMIT ]-===============================================
91        // ===================================================================
92        for (uint32_t i=0; i<_param->_nb_front_end; i++)
93          for (uint32_t j=0; j<_param->_nb_context[i]; j++)
94            {
95              if (PORT_READ(in_SPR_COMMIT_VAL [i][j])) // out_SPR_COMMIT_ACK [i][j]
96                {
97                  log_printf(TRACE,Special_Register_unit,FUNCTION,"  * SPR_COMMIT [%d][%d]",i,j);
98                  log_printf(TRACE,Special_Register_unit,FUNCTION,"    * F            : %d, %d",PORT_READ(in_SPR_COMMIT_SR_F_VAL  [i][j]),PORT_READ(in_SPR_COMMIT_SR_F  [i][j]));
99                  log_printf(TRACE,Special_Register_unit,FUNCTION,"    * CY           : %d, %d",PORT_READ(in_SPR_COMMIT_SR_CY_VAL [i][j]),PORT_READ(in_SPR_COMMIT_SR_CY [i][j]));
100                  log_printf(TRACE,Special_Register_unit,FUNCTION,"    * OV           : %d, %d",PORT_READ(in_SPR_COMMIT_SR_OV_VAL [i][j]),PORT_READ(in_SPR_COMMIT_SR_OV [i][j]));
101
102                  log_printf(TRACE,Special_Register_unit,FUNCTION,"    * SPR (before) : %.8x",_spr [i][j][GROUP_SYSTEM_AND_CONTROL][SPR_SR]->read());
103                  SR * sr = static_cast<SR*>(_spr [i][j][GROUP_SYSTEM_AND_CONTROL][SPR_SR]);
104
105                  if (PORT_READ(in_SPR_COMMIT_SR_F_VAL  [i][j]))
106                    sr->= PORT_READ(in_SPR_COMMIT_SR_F  [i][j]);
107                 
108                  if (PORT_READ(in_SPR_COMMIT_SR_CY_VAL [i][j]))
109                    sr->cy = PORT_READ(in_SPR_COMMIT_SR_CY [i][j]);
110                 
111                  if (PORT_READ(in_SPR_COMMIT_SR_OV_VAL [i][j]))
112                    sr->ov = PORT_READ(in_SPR_COMMIT_SR_OV [i][j]);
113
114                  log_printf(TRACE,Special_Register_unit,FUNCTION,"    * SPR (after)  : %.8x",_spr [i][j][GROUP_SYSTEM_AND_CONTROL][SPR_SR]->read());
115
116                }
117
118              if (PORT_READ(in_SPR_EVENT_VAL [i][j])) // out_SPR_EVENT_ACK [i][j]
119                {
120                  log_printf(TRACE,Special_Register_unit,FUNCTION,"  * SPR_EVENT [%d][%d]",i,j);
121                  log_printf(TRACE,Special_Register_unit,FUNCTION,"    * SPR (before) : %.8x",_spr [i][j][GROUP_SYSTEM_AND_CONTROL][SPR_SR]->read());
122
123                  SR * sr = static_cast<SR*>(_spr [i][j][GROUP_SYSTEM_AND_CONTROL][SPR_SR]);
124                  sr->dsx = PORT_READ(in_SPR_EVENT_SR_DSX [i][j]);
125
126                  _spr [i][j][GROUP_SYSTEM_AND_CONTROL][SPR_EPCR]->write(PORT_READ(in_SPR_EVENT_EPCR [i][j]));
127                  if (PORT_READ(in_SPR_EVENT_EEAR_WEN [i][j]))
128                  _spr [i][j][GROUP_SYSTEM_AND_CONTROL][SPR_EEAR]->write(PORT_READ(in_SPR_EVENT_EEAR [i][j]));
129                  if (PORT_READ(in_SPR_EVENT_SR_TO_ESR [i][j]))
130                  _spr [i][j][GROUP_SYSTEM_AND_CONTROL][SPR_ESR ]->write(sr->read());
131
132                  log_printf(TRACE,Special_Register_unit,FUNCTION,"    * SPR (after)  : %.8x",_spr [i][j][GROUP_SYSTEM_AND_CONTROL][SPR_SR]->read());
133                }
134            }
135
136#if (DEBUG >= DEBUG_TRACE) and (DEBUG_Special_Register_unit == true)
137        {
138          log_printf(TRACE,Special_Register_unit,FUNCTION,"  * Dump SPR");
139
140          for (uint32_t i=0; i<_param->_nb_front_end; i++)
141            for (uint32_t j=0; j<_param->_nb_context[i]; j++)
142              {
143                log_printf(TRACE,Special_Register_unit,FUNCTION,"    * SR        [%d][%d] : %.8x",i,j,_spr [i][j][GROUP_SYSTEM_AND_CONTROL][SPR_SR          ]->read());
144                log_printf(TRACE,Special_Register_unit,FUNCTION,"    * CID       [%d][%d] : %.8x",i,j,_spr [i][j][GROUP_SYSTEM_AND_CONTROL][SPR_CID         ]->read());
145                log_printf(TRACE,Special_Register_unit,FUNCTION,"    * TID       [%d][%d] : %.8x",i,j,_spr [i][j][GROUP_SYSTEM_AND_CONTROL][SPR_TID         ]->read());
146                log_printf(TRACE,Special_Register_unit,FUNCTION,"    * TSR       [%d][%d] : %.8x",i,j,_spr [i][j][GROUP_SYSTEM_AND_CONTROL][SPR_TSR         ]->read());
147//                 log_printf(TRACE,Special_Register_unit,FUNCTION,"    * MACLO     [%d][%d] : %.8x",i,j,_spr [i][j][GROUP_MAC               ][SPR_MACLO      ]->read());
148//                 log_printf(TRACE,Special_Register_unit,FUNCTION,"    * MACHI     [%d][%d] : %.8x",i,j,_spr [i][j][GROUP_MAC               ][SPR_MACHI      ]->read());
149              }
150        }
151#endif
152      }
153
154#if defined(STATISTICS) or defined(VHDL_TESTBENCH)
155    end_cycle ();
156#endif
157
158    log_end(Special_Register_unit,FUNCTION);
159  };
160
161}; // end namespace special_register_unit
162}; // end namespace ooo_engine
163}; // end namespace multi_ooo_engine
164}; // end namespace core
165
166}; // end namespace behavioural
167}; // end namespace morpheo             
168#endif
Note: See TracBrowser for help on using the repository browser.