source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Front_end/Front_end/Ifetch_unit/Address_management/src/Address_management_transition.cpp @ 82

Last change on this file since 82 was 82, checked in by rosiere, 16 years ago
  • support locale (now must "just" translate)
  • update all component with new test format
  • update all component with usage
  • New component : decod queue and prediction_unit
  • Property svn:keywords set to Id
File size: 5.6 KB
Line 
1#ifdef SYSTEMC
2/*
3 * $Id: Address_management_transition.cpp 82 2008-05-01 16:48:45Z rosiere $
4 *
5 * [ Description ]
6 *
7 */
8
9#include "Behavioural/Core/Multi_Front_end/Front_end/Ifetch_unit/Address_management/include/Address_management.h"
10
11namespace morpheo                    {
12namespace behavioural {
13namespace core {
14namespace multi_front_end {
15namespace front_end {
16namespace ifetch_unit {
17namespace address_management {
18
19
20#undef  FUNCTION
21#define FUNCTION "Address_management::transition"
22  void Address_management::transition (void)
23  {
24    log_printf(FUNC,Address_management,FUNCTION,"Begin");
25
26    if (PORT_READ(in_NRESET) == 0)
27      {
28        reg_PC_PREVIOUS_VAL = 0;
29        reg_PC_CURRENT_VAL  = 0;
30        reg_PC_NEXT_VAL     = 0;       
31      }
32    else
33      {
34        // =========================================
35        // ===== ADDRESS ===========================
36        // =========================================
37        // transaction with icache
38        if (internal_ADDRESS_VAL and PORT_READ(in_ADDRESS_ACK))
39          {
40            // current pc became previous pc
41            reg_PC_PREVIOUS_VAL                        = 1;
42            reg_PC_PREVIOUS                            = reg_PC_CURRENT    ;
43           
44            // next    pc became next     pc
45            reg_PC_CURRENT_VAL                         = reg_PC_NEXT_VAL; // can be not valid
46
47            // if pc_next is not valid : don't erase PC and PC_IS_DS_TAKE : this register is send a the predict (to compute pc_next)
48            if (reg_PC_NEXT_VAL)
49              {
50            reg_PC_CURRENT                             = reg_PC_NEXT    ;
51            reg_PC_CURRENT_IS_DS_TAKE                  = reg_PC_NEXT_IS_DS_TAKE                 ;
52              }
53
54            reg_PC_CURRENT_INST_IFETCH_PTR             = reg_PC_NEXT_INST_IFETCH_PTR            ;
55            reg_PC_CURRENT_BRANCH_STATE                = reg_PC_NEXT_BRANCH_STATE               ;
56            reg_PC_CURRENT_BRANCH_UPDATE_PREDICTION_ID = reg_PC_NEXT_BRANCH_UPDATE_PREDICTION_ID;
57
58            for (uint32_t i=0; i<_param->_nb_instruction; i++)
59              reg_PC_CURRENT_INSTRUCTION_ENABLE [i] = reg_PC_NEXT_INSTRUCTION_ENABLE [i];
60
61            // have not next pc
62            reg_PC_NEXT_VAL                            = 0;
63          }
64       
65        // =========================================
66        // ===== PREDICT ===========================
67        // =========================================
68        bool new_pc_current = not reg_PC_CURRENT_VAL;
69        if (PORT_READ(in_PREDICT_ACK) and internal_PREDICT_VAL)
70          if (new_pc_current)
71            {
72              reg_PC_CURRENT_VAL                         = 1;
73              reg_PC_CURRENT                             = PORT_READ(in_PREDICT_PC_NEXT                    );
74              reg_PC_CURRENT_IS_DS_TAKE                  = PORT_READ(in_PREDICT_PC_NEXT_IS_DS_TAKE         );
75              if (_param->_have_port_instruction_ptr)
76              reg_PC_CURRENT_INST_IFETCH_PTR             = PORT_READ(in_PREDICT_INST_IFETCH_PTR            );
77              reg_PC_CURRENT_BRANCH_STATE                = PORT_READ(in_PREDICT_BRANCH_STATE               );
78              if (_param->_have_port_branch_update_prediction_id)
79              reg_PC_CURRENT_BRANCH_UPDATE_PREDICTION_ID = PORT_READ(in_PREDICT_BRANCH_UPDATE_PREDICTION_ID);
80
81// #error "INSTRUCTION_ENABLE : ERROR implémentation, remplacer PC_PREVIOUS par PC_NEXT_NEXT"
82
83              for (uint32_t i=0; i<_param->_nb_instruction; i++)
84                reg_PC_CURRENT_INSTRUCTION_ENABLE [i] = PORT_READ(in_PREDICT_INSTRUCTION_ENABLE [i]);
85            }
86          else
87            {
88              reg_PC_NEXT_VAL                         = 1;
89              reg_PC_NEXT                             = PORT_READ(in_PREDICT_PC_NEXT                    );
90              reg_PC_NEXT_IS_DS_TAKE                  = PORT_READ(in_PREDICT_PC_NEXT_IS_DS_TAKE         );
91              if (_param->_have_port_instruction_ptr)
92              reg_PC_NEXT_INST_IFETCH_PTR             = PORT_READ(in_PREDICT_INST_IFETCH_PTR            );
93              reg_PC_NEXT_BRANCH_STATE                = PORT_READ(in_PREDICT_BRANCH_STATE               );
94              if (_param->_have_port_branch_update_prediction_id)
95              reg_PC_NEXT_BRANCH_UPDATE_PREDICTION_ID = PORT_READ(in_PREDICT_BRANCH_UPDATE_PREDICTION_ID);
96
97              for (uint32_t i=0; i<_param->_nb_instruction; i++)
98                reg_PC_NEXT_INSTRUCTION_ENABLE [i] = PORT_READ(in_PREDICT_INSTRUCTION_ENABLE [i]);
99            }
100
101        // =========================================
102        // ===== EVENT =============================
103        // =========================================
104        if (PORT_READ(in_EVENT_VAL) and internal_EVENT_ACK)
105          {
106            reg_PC_CURRENT_VAL                         = 1;
107            reg_PC_CURRENT                             = PORT_READ(in_EVENT_ADDRESS);
108            // Event is never is ds_take :
109            //  * branch miss speculation : can't be place a branch in delay slot
110            //  * load   miss speculation : the load is execute, the event_address is the next address (also the destination of branch)
111            //  * exception               : goto the first instruction of exception handler (also is not in delay slot).
112            reg_PC_CURRENT_IS_DS_TAKE                  = 0;
113            reg_PC_CURRENT_INST_IFETCH_PTR             = 0;
114            reg_PC_CURRENT_BRANCH_STATE                = BRANCH_STATE_NONE;
115            reg_PC_CURRENT_BRANCH_UPDATE_PREDICTION_ID = 0;
116           
117            reg_PC_CURRENT_INSTRUCTION_ENABLE [0]      = 1; // only the instruction at the event address is valid, because we have no information on the branch presence in the instruction bundle.
118            for (uint32_t i=1; i<_param->_nb_instruction; i++)
119              reg_PC_CURRENT_INSTRUCTION_ENABLE [i] = 0;
120
121            reg_PC_NEXT_VAL                            = 0; // cancel all prediction (event is send at the predict unit)
122          }
123      }
124
125#if defined(STATISTICS) or defined(VHDL_TESTBENCH)
126    end_cycle ();
127#endif
128
129    log_printf(FUNC,Address_management,FUNCTION,"End");
130  };
131
132}; // end namespace address_management
133}; // end namespace ifetch_unit
134}; // end namespace front_end
135}; // end namespace multi_front_end
136}; // end namespace core
137
138}; // end namespace behavioural
139}; // end namespace morpheo             
140#endif
Note: See TracBrowser for help on using the repository browser.