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

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

1) add constant method
2) test with systemc 2.2.0

  • Property svn:keywords set to Id
File size: 4.8 KB
RevLine 
[2]1#ifdef SYSTEMC
2/*
3 * $Id: RegisterFile_Monolithic_transition.cpp 131 2009-07-08 18:40:08Z 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      {
[101]39        for (uint32_t i=0; i<_param->_nb_port_write; i++)
40          {
[128]41            log_printf(TRACE,RegisterFile,FUNCTION,"  * WRITE [%d] : %d",i,PORT_READ(in_WRITE_VAL[i]));
42
[101]43            // Have a write?
44            if ( PORT_READ(in_WRITE_VAL[i]) == true)
45              {
[55]46#ifdef STATISTICS
[101]47                if (usage_is_set(_usage,USE_STATISTICS))
[88]48                  (*_stat_nb_write) ++;
[55]49#endif   
[128]50
[101]51                Taddress_t address = (_param->_have_port_address)?PORT_READ(in_WRITE_ADDRESS[i]):0;
52                Tdata_t    data    = PORT_READ(in_WRITE_DATA   [i]);
[128]53
54                log_printf(TRACE,RegisterFile,FUNCTION,"    * address : %d",address);
55                log_printf(TRACE,RegisterFile,FUNCTION,"    * gloup");
56                log_printf(TRACE,RegisterFile,FUNCTION,"    * data    : %d",data);
[101]57               
[106]58                log_printf(TRACE,RegisterFile,FUNCTION,"  * [%d] <- %.8x",static_cast<uint32_t>(address),static_cast<uint32_t>(data));
[128]59
60#ifdef DEBUG_TEST
61                if (address >= _param->_nb_word)
62                  throw ERRORMORPHEO(FUNCTION,toString(_("Address (%d) is invalid (size : %d).\n"),address,_param->_nb_word));
63#endif
[101]64               
65                // Write in registerFile
66                reg_DATA[address] = data;
67              }
68          }
69        for (uint32_t i=0; i<_param->_nb_port_read_write; i++)
70          {
[128]71            log_printf(TRACE,RegisterFile,FUNCTION,"  * READ_WRITE [%d] : %d",i,PORT_READ(in_READ_WRITE_VAL[i]));
72
[101]73            // Have a read_write?
74            if (PORT_READ(in_READ_WRITE_VAL[i]) == true)
75              {
76                if (PORT_READ(in_READ_WRITE_RW [i]) == RW_WRITE)
77                  {
[71]78#ifdef STATISTICS
[101]79                    if (usage_is_set(_usage,USE_STATISTICS))
80                      (*_stat_nb_write) ++;
[71]81#endif   
[101]82                   
83                    Taddress_t address = (_param->_have_port_address)?PORT_READ(in_READ_WRITE_ADDRESS[i]):0;
84                    Tdata_t    data    = PORT_READ(in_READ_WRITE_WDATA  [i]);
85                   
[106]86                    log_printf(TRACE,RegisterFile,FUNCTION,"  * [%d] <- %.8x",static_cast<uint32_t>(address),static_cast<uint32_t>(data));
[101]87                   
[128]88
89#ifdef DEBUG_TEST
90                if (address >= _param->_nb_word)
91                  throw ERRORMORPHEO(FUNCTION,toString(_("Address (%d) is invalid (size : %d).\n"),address,_param->_nb_word));
92#endif
93
[101]94                    // Write in registerFile
95                    reg_DATA[address] = data;
96                  }
97#ifdef STATISTICS
98                else
99                  {
100                    if (usage_is_set(_usage,USE_STATISTICS))
101                      (*_stat_nb_read) ++;
102                  }
103#endif   
104              }
105          }
[55]106      }
107
[2]108#ifdef STATISTICS
[88]109    if (usage_is_set(_usage,USE_STATISTICS))
110      for (uint32_t i=0; i<_param->_nb_port_read; i++)
111        if ( PORT_READ(in_READ_VAL [i]) == 1)
112          (*_stat_nb_read) ++;
[2]113#endif   
114
[106]115#if defined(DEBUG_RegisterFile_Monolithic) and DEBUG_RegisterFile_Monolithic and (DEBUG >= DEBUG_TRACE)
[131]116# if 1
[106]117    {
118      log_printf(TRACE,RegisterFile,FUNCTION,"  * Dump RegisterFile");
119
120      uint32_t limit = 4;
121     
122      for (uint32_t i=0; i<_param->_nb_word; i+=limit)
123        {
124          std::string str = "";
125         
126          for (uint32_t j=0; j<limit; j++)
127            {
128              uint32_t index = i+j;
129              if (index >= _param->_nb_word)
130                break;
131              else
132                str+=toString("[%.4d] %.8x ",index,reg_DATA[index]);
133            }
134
135          log_printf(TRACE,RegisterFile,FUNCTION,"  %s",str.c_str());
136        }
137    }
[131]138# endif
[106]139#endif
140
[75]141#if defined(STATISTICS) or defined(VHDL_TESTBENCH)
[71]142    end_cycle();
[75]143#endif
[106]144
145    log_end(RegisterFile_Monolithic,FUNCTION);
[2]146  };
147
[15]148}; // end namespace registerfile_monolithic
[2]149}; // end namespace registerfile
150}; // end namespace generic
151}; // end namespace behavioural         
152}; // end namespace morpheo             
153#endif
Note: See TracBrowser for help on using the repository browser.