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

Last change on this file since 145 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
RevLine 
[2]1#ifdef SYSTEMC
2/*
3 * $Id: RegisterFile_Monolithic_transition.cpp 138 2010-05-12 17:34:01Z rosiere $
4 *
5 * [ Description ]
6 *
7 */
8
[15]9#include "Behavioural/Generic/RegisterFile/RegisterFile_Monolithic/include/RegisterFile_Monolithic.h"
[2]10
11namespace morpheo                    {
12namespace behavioural                {
13namespace generic                    {
14namespace registerfile               {
[15]15namespace registerfile_monolithic    {
[106]16
17#undef  FUNCTION
18#define FUNCTION "RegisterFile_Monolithic::transition"
[15]19  void RegisterFile_Monolithic::transition (void)
[2]20  {
[106]21    log_begin(RegisterFile_Monolithic,FUNCTION);
22    log_function(RegisterFile_Monolithic,FUNCTION,_name.c_str());
[2]23
[128]24    if (PORT_READ(in_NRESET) == 0)
[2]25      {
[128]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          }
[2]36      }
[101]37    else
[55]38      {
[138]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
[101]44        for (uint32_t i=0; i<_param->_nb_port_write; i++)
45          {
[128]46            log_printf(TRACE,RegisterFile,FUNCTION,"  * WRITE [%d] : %d",i,PORT_READ(in_WRITE_VAL[i]));
47
[101]48            // Have a write?
49            if ( PORT_READ(in_WRITE_VAL[i]) == true)
50              {
[55]51#ifdef STATISTICS
[138]52                stat_nb_write++;
53#endif
[128]54
[138]55// #ifdef STATISTICS
56//                 if (usage_is_set(_usage,USE_STATISTICS))
57//                   (*_stat_nb_write) ++;
58// #endif   
59
[101]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]);
[128]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);
[101]66               
[106]67                log_printf(TRACE,RegisterFile,FUNCTION,"  * [%d] <- %.8x",static_cast<uint32_t>(address),static_cast<uint32_t>(data));
[128]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
[101]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          {
[128]80            log_printf(TRACE,RegisterFile,FUNCTION,"  * READ_WRITE [%d] : %d",i,PORT_READ(in_READ_WRITE_VAL[i]));
81
[101]82            // Have a read_write?
83            if (PORT_READ(in_READ_WRITE_VAL[i]) == true)
84              {
[138]85#ifdef STATISTICS
86                stat_nb_read_write++;
87#endif
88
[101]89                if (PORT_READ(in_READ_WRITE_RW [i]) == RW_WRITE)
90                  {
[138]91// #ifdef STATISTICS
92//                     if (usage_is_set(_usage,USE_STATISTICS))
93//                       (*_stat_nb_write) ++;
94// #endif   
[101]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                   
[106]99                    log_printf(TRACE,RegisterFile,FUNCTION,"  * [%d] <- %.8x",static_cast<uint32_t>(address),static_cast<uint32_t>(data));
[101]100                   
[128]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
[101]107                    // Write in registerFile
108                    reg_DATA[address] = data;
109                  }
[138]110// #ifdef STATISTICS
111//                 else
112//                   {
113//                     if (usage_is_set(_usage,USE_STATISTICS))
114//                       (*_stat_nb_read) ++;
115//                   }
116// #endif   
[101]117              }
118          }
[55]119
[138]120       
[2]121#ifdef STATISTICS
[138]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          }
[2]138#endif   
[138]139      }
[2]140
[106]141#if defined(DEBUG_RegisterFile_Monolithic) and DEBUG_RegisterFile_Monolithic and (DEBUG >= DEBUG_TRACE)
[131]142# if 1
[106]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    }
[131]164# endif
[106]165#endif
166
[75]167#if defined(STATISTICS) or defined(VHDL_TESTBENCH)
[71]168    end_cycle();
[75]169#endif
[106]170
171    log_end(RegisterFile_Monolithic,FUNCTION);
[2]172  };
173
[15]174}; // end namespace registerfile_monolithic
[2]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.