source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/RegisterFile/RegisterFile_Monolithic/src/RegisterFile_Monolithic_transition.cpp @ 138

Last change on this file since 138 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: 5.6 KB
Line 
1#ifdef SYSTEMC
2/*
3 * $Id: RegisterFile_Monolithic_transition.cpp 138 2010-05-12 17:34:01Z rosiere $
4 *
5 * [ Description ]
6 *
7 */
8
9#include "Behavioural/Generic/RegisterFile/RegisterFile_Monolithic/include/RegisterFile_Monolithic.h"
10
11namespace morpheo                    {
12namespace behavioural                {
13namespace generic                    {
14namespace registerfile               {
15namespace registerfile_monolithic    {
16
17#undef  FUNCTION
18#define FUNCTION "RegisterFile_Monolithic::transition"
19  void RegisterFile_Monolithic::transition (void)
20  {
21    log_begin(RegisterFile_Monolithic,FUNCTION);
22    log_function(RegisterFile_Monolithic,FUNCTION,_name.c_str());
23
24    if (PORT_READ(in_NRESET) == 0)
25      {
26        if (_param->_have_init_value)
27          {
28            for (uint32_t i=0; i<_param->_nb_word; ++i)
29              reg_DATA[i] = fromString<Tdata_t>(_param->_init_value);
30          }
31        else
32          {
33            for (uint32_t i=0; i<_param->_nb_word; ++i)
34              reg_DATA[i] = 0;
35          }
36      }
37    else
38      {
39#ifdef STATISTICS
40        uint32_t stat_nb_read      =0;
41        uint32_t stat_nb_write     =0;
42        uint32_t stat_nb_read_write=0;
43#endif
44        for (uint32_t i=0; i<_param->_nb_port_write; i++)
45          {
46            log_printf(TRACE,RegisterFile,FUNCTION,"  * WRITE [%d] : %d",i,PORT_READ(in_WRITE_VAL[i]));
47
48            // Have a write?
49            if ( PORT_READ(in_WRITE_VAL[i]) == true)
50              {
51#ifdef STATISTICS
52                stat_nb_write++;
53#endif
54
55// #ifdef STATISTICS
56//                 if (usage_is_set(_usage,USE_STATISTICS))
57//                   (*_stat_nb_write) ++;
58// #endif   
59
60                Taddress_t address = (_param->_have_port_address)?PORT_READ(in_WRITE_ADDRESS[i]):0;
61                Tdata_t    data    = PORT_READ(in_WRITE_DATA   [i]);
62
63                log_printf(TRACE,RegisterFile,FUNCTION,"    * address : %d",address);
64                log_printf(TRACE,RegisterFile,FUNCTION,"    * gloup");
65                log_printf(TRACE,RegisterFile,FUNCTION,"    * data    : %d",data);
66               
67                log_printf(TRACE,RegisterFile,FUNCTION,"  * [%d] <- %.8x",static_cast<uint32_t>(address),static_cast<uint32_t>(data));
68
69#ifdef DEBUG_TEST
70                if (address >= _param->_nb_word)
71                  throw ERRORMORPHEO(FUNCTION,toString(_("Address (%d) is invalid (size : %d).\n"),address,_param->_nb_word));
72#endif
73               
74                // Write in registerFile
75                reg_DATA[address] = data;
76              }
77          }
78        for (uint32_t i=0; i<_param->_nb_port_read_write; i++)
79          {
80            log_printf(TRACE,RegisterFile,FUNCTION,"  * READ_WRITE [%d] : %d",i,PORT_READ(in_READ_WRITE_VAL[i]));
81
82            // Have a read_write?
83            if (PORT_READ(in_READ_WRITE_VAL[i]) == true)
84              {
85#ifdef STATISTICS
86                stat_nb_read_write++;
87#endif
88
89                if (PORT_READ(in_READ_WRITE_RW [i]) == RW_WRITE)
90                  {
91// #ifdef STATISTICS
92//                     if (usage_is_set(_usage,USE_STATISTICS))
93//                       (*_stat_nb_write) ++;
94// #endif   
95                   
96                    Taddress_t address = (_param->_have_port_address)?PORT_READ(in_READ_WRITE_ADDRESS[i]):0;
97                    Tdata_t    data    = PORT_READ(in_READ_WRITE_WDATA  [i]);
98                   
99                    log_printf(TRACE,RegisterFile,FUNCTION,"  * [%d] <- %.8x",static_cast<uint32_t>(address),static_cast<uint32_t>(data));
100                   
101
102#ifdef DEBUG_TEST
103                if (address >= _param->_nb_word)
104                  throw ERRORMORPHEO(FUNCTION,toString(_("Address (%d) is invalid (size : %d).\n"),address,_param->_nb_word));
105#endif
106
107                    // Write in registerFile
108                    reg_DATA[address] = data;
109                  }
110// #ifdef STATISTICS
111//                 else
112//                   {
113//                     if (usage_is_set(_usage,USE_STATISTICS))
114//                       (*_stat_nb_read) ++;
115//                   }
116// #endif   
117              }
118          }
119
120       
121#ifdef STATISTICS
122        if (usage_is_set(_usage,USE_STATISTICS))
123          {
124            for (uint32_t i=0; i<_param->_nb_port_read; i++)
125              if ( PORT_READ(in_READ_VAL [i]) == 1)
126                {
127                  stat_nb_read ++;
128                  // (*_stat_nb_read) ++;
129                }
130
131            if (_param->_nb_port_read>0)
132            (*_stat_port_read      ) += stat_nb_read;
133            if (_param->_nb_port_write>0)
134            (*_stat_port_write     ) += stat_nb_write;
135            if (_param->_nb_port_read_write>0)
136            (*_stat_port_read_write) += stat_nb_read_write;
137          }
138#endif   
139      }
140
141#if defined(DEBUG_RegisterFile_Monolithic) and DEBUG_RegisterFile_Monolithic and (DEBUG >= DEBUG_TRACE)
142# if 1
143    {
144      log_printf(TRACE,RegisterFile,FUNCTION,"  * Dump RegisterFile");
145
146      uint32_t limit = 4;
147     
148      for (uint32_t i=0; i<_param->_nb_word; i+=limit)
149        {
150          std::string str = "";
151         
152          for (uint32_t j=0; j<limit; j++)
153            {
154              uint32_t index = i+j;
155              if (index >= _param->_nb_word)
156                break;
157              else
158                str+=toString("[%.4d] %.8x ",index,reg_DATA[index]);
159            }
160
161          log_printf(TRACE,RegisterFile,FUNCTION,"  %s",str.c_str());
162        }
163    }
164# endif
165#endif
166
167#if defined(STATISTICS) or defined(VHDL_TESTBENCH)
168    end_cycle();
169#endif
170
171    log_end(RegisterFile_Monolithic,FUNCTION);
172  };
173
174}; // end namespace registerfile_monolithic
175}; // end namespace registerfile
176}; // end namespace generic
177}; // end namespace behavioural         
178}; // end namespace morpheo             
179#endif
Note: See TracBrowser for help on using the repository browser.