source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_OOO_Engine/OOO_Engine/Rename_unit/Register_translation_unit/Register_Address_Translation_unit/src/Register_Address_Translation_unit_transition.cpp @ 100

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

1) Bug fix (Operation, Instruction)
2) Modif Return Address Stack
3) Add Soft Test
4) Add Soc Test

  • Property svn:keywords set to Id
File size: 6.6 KB
Line 
1#ifdef SYSTEMC
2/*
3 * $Id: Register_Address_Translation_unit_transition.cpp 100 2009-01-08 13:06:27Z rosiere $
4 *
5 * [ Description ]
6 *
7 */
8
9#include "Behavioural/Core/Multi_OOO_Engine/OOO_Engine/Rename_unit/Register_translation_unit/Register_Address_Translation_unit/include/Register_Address_Translation_unit.h"
10
11namespace morpheo                    {
12namespace behavioural {
13namespace core {
14namespace multi_ooo_engine {
15namespace ooo_engine {
16namespace rename_unit {
17namespace register_translation_unit {
18namespace register_address_translation_unit {
19
20
21#undef  FUNCTION
22#define FUNCTION "Register_Address_Translation_unit::transition"
23  void Register_Address_Translation_unit::transition (void)
24  {
25    log_begin(Register_Address_Translation_unit,FUNCTION);
26    log_function(Register_Address_Translation_unit,FUNCTION,_name.c_str());
27
28    if (PORT_READ(in_NRESET) == 0)
29      {
30        uint32_t gpr = 1;
31        uint32_t spr = 0;
32
33        for (uint32_t i=0; i<_param->_nb_front_end; i++)
34          for (uint32_t j=0; j<_param->_nb_context[i]; j++)
35            {
36              rat_gpr [i][j][0] = 0;
37
38              for (uint32_t k=1; k<_param->_nb_general_register_logic; k++)
39                {
40                  rat_gpr             [i][j][k] = gpr++;
41//                rat_gpr_update_table[i][j][k] = 0;
42                }
43              for (uint32_t k=0; k<_param->_nb_special_register_logic; k++)
44                {
45                  rat_spr             [i][j][k] = spr++;
46//                rat_spr_update_table[i][j][k] = 0;
47                }
48            }
49      }
50    else
51      {
52        // Note : GPR[0] is never write (in decod's stage : write_rd = 0 when num_reg_rd_log == 0)
53
54        // =====================================================
55        // ====[ INSERT ]=======================================
56        // =====================================================
57        // First : interface insert
58        for (uint32_t i=0; i<_param->_nb_inst_insert; i++)
59          // Test transaction
60          if (PORT_READ(in_INSERT_VAL [i]) and internal_INSERT_ACK  [i])
61            {
62              Tcontext_t front_end_id = (_param->_have_port_front_end_id)?PORT_READ(in_RENAME_FRONT_END_ID [i]):0;
63              Tcontext_t context_id   = (_param->_have_port_context_id  )?PORT_READ(in_RENAME_CONTEXT_ID   [i]):0;
64             
65              // Test if write
66              if (PORT_READ(in_INSERT_WRITE_RD [i]) == 1)
67                rat_gpr[front_end_id][context_id][PORT_READ(in_INSERT_NUM_REG_RD_LOG [i])] = PORT_READ(in_INSERT_NUM_REG_RD_PHY [i]);
68              if (PORT_READ(in_INSERT_WRITE_RE [i]) == 1)
69                rat_spr[front_end_id][context_id][PORT_READ(in_INSERT_NUM_REG_RE_LOG [i])] = PORT_READ(in_INSERT_NUM_REG_RE_PHY [i]);
70            }
71
72        // =====================================================
73        // ====[ RETIRE ]=======================================
74        // =====================================================
75        // Second : interface retire
76        //  (because if an event on the same thread : the instruction is already renamed)
77        for (uint32_t i=0; i<_param->_nb_inst_retire; i++)
78          if (PORT_READ(in_RETIRE_VAL [i]) and internal_RETIRE_ACK [i])
79            {
80              // if no event : no effect, because the RAT content the most recently register
81              // but if they have a event (exception or miss speculation), the rat must restore the oldest value
82              // To restore the oldest valid value, we use the rat_update_table. if the bit is unset, also they have none update on this register
83              // the retire interface became of the Re Order Buffer, also is in program sequence !
84              if (PORT_READ(in_RETIRE_EVENT_STATE [i]) != EVENT_STATE_NO_EVENT)
85                {
86                  Tcontext_t         front_end_id = (_param->_have_port_front_end_id)?PORT_READ(in_RETIRE_FRONT_END_ID [i]):0;
87                  Tcontext_t         context_id   = (_param->_have_port_context_id  )?PORT_READ(in_RETIRE_CONTEXT_ID   [i]):0;
88
89                  // Test if event have just occure
90                  if (PORT_READ(in_RETIRE_EVENT_STATE [i]) == EVENT_STATE_EVENT)
91                    {
92                      // Reset update_table
93                      for (uint32_t j=0; j<_param->_nb_general_register_logic; j++)
94                        rat_gpr_update_table[front_end_id][context_id][j] = 0;
95                      for (uint32_t j=0; j<_param->_nb_special_register_logic; j++)
96                        rat_spr_update_table[front_end_id][context_id][j] = 0;
97                    }
98
99                  // Test if write and have not a previous update
100                  if (PORT_READ(in_RETIRE_WRITE_RD [i]) == 1)
101                    {
102                      Tgeneral_address_t rd_log = PORT_READ(in_RETIRE_NUM_REG_RD_LOG [i]);
103                     
104                      log_printf(TRACE,Register_Address_Translation_unit,FUNCTION,"  * retire[%d]",i);
105                      log_printf(TRACE,Register_Address_Translation_unit,FUNCTION,"    * front_end_id : %d",front_end_id);
106                      log_printf(TRACE,Register_Address_Translation_unit,FUNCTION,"    * context_id   : %d",context_id  );
107                      log_printf(TRACE,Register_Address_Translation_unit,FUNCTION,"    * rd_log       : %d",rd_log      );
108                     
109//                    if (RETIRE_RESTORE_RD_PHY_OLD [i])
110                      if (rat_gpr_update_table[front_end_id][context_id][rd_log] == 0)
111                        {
112                          rat_gpr             [front_end_id][context_id][rd_log] = PORT_READ(in_RETIRE_NUM_REG_RD_PHY_OLD [i]);
113                          rat_gpr_update_table[front_end_id][context_id][rd_log] = 1;
114                        }
115                    }
116
117                  if (PORT_READ(in_RETIRE_WRITE_RE [i]) == 1)
118                    {
119                      Tspecial_address_t re_log = PORT_READ(in_RETIRE_NUM_REG_RE_LOG [i]);
120
121//                    if (RETIRE_RESTORE_RE_PHY_OLD [i])
122                      if (rat_spr_update_table[front_end_id][context_id][re_log] == 0)
123                        {
124                          rat_spr             [front_end_id][context_id][re_log] = PORT_READ(in_RETIRE_NUM_REG_RE_PHY_OLD [i]);
125                          rat_spr_update_table[front_end_id][context_id][re_log] = 1;
126                        }
127                    }
128                }
129            }
130      }
131
132#if (DEBUG >= DEBUG_TRACE) and (DEBUG_Register_Address_Translation_unit == true)
133    log_printf(TRACE,Register_Address_Translation_unit,FUNCTION,"  * Dump RAT (Register_Address_Translation_unit)");
134    for (uint32_t i=0; i<_param->_nb_front_end; ++i)
135      for (uint32_t j=0; j<_param->_nb_context[i]; ++j)
136        {
137          log_printf(TRACE,Register_Address_Translation_unit,FUNCTION,"    * front_end[%d].context[%d]",i,j);
138
139          for (uint32_t k=0; k<_param->_nb_general_register_logic; ++k)
140            log_printf(TRACE,Register_Address_Translation_unit,FUNCTION,"      * GPR[%.4d] - %.5d %.1d",k,rat_gpr[i][j][k],rat_gpr_update_table[i][j][k]);
141
142          for (uint32_t k=0; k<_param->_nb_special_register_logic; ++k)
143            log_printf(TRACE,Register_Address_Translation_unit,FUNCTION,"      * SPR[%.4d] - %.5d %.1d",k,rat_spr[i][j][k],rat_spr_update_table[i][j][k]);
144        }
145#endif
146
147#if defined(STATISTICS) or defined(VHDL_TESTBENCH)
148    end_cycle ();
149#endif
150
151    log_end(Register_Address_Translation_unit,FUNCTION);
152  };
153
154}; // end namespace register_address_translation_unit
155}; // end namespace register_translation_unit
156}; // end namespace rename_unit
157}; // end namespace ooo_engine
158}; // end namespace multi_ooo_engine
159}; // end namespace core
160
161}; // end namespace behavioural
162}; // end namespace morpheo             
163#endif
Note: See TracBrowser for help on using the repository browser.