source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/RegisterFile/RegisterFile_Multi_Banked/src/RegisterFile_Multi_Banked_transition.cpp @ 137

Last change on this file since 137 was 137, checked in by rosiere, 14 years ago

Various modif (add test, and vhdl)

  • Property svn:keywords set to Id
File size: 3.3 KB
Line 
1#ifdef SYSTEMC
2//#if defined(STATISTICS) or defined(VHDL_TESTBENCH)
3/*
4 * $Id: RegisterFile_Multi_Banked_transition.cpp 137 2010-02-16 12:35:48Z rosiere $
5 *
6 * [ Description ]
7 *
8 */
9
10#include "Behavioural/Generic/RegisterFile/RegisterFile_Multi_Banked/include/RegisterFile_Multi_Banked.h"
11
12namespace morpheo                    {
13namespace behavioural {
14namespace generic {
15namespace registerfile {
16namespace registerfile_multi_banked {
17
18#undef  FUNCTION
19#define FUNCTION "RegisterFile_Multi_Banked::transition"
20  void RegisterFile_Multi_Banked::transition (void)
21  {
22    log_begin(RegisterFile_Multi_Banked,FUNCTION);
23    log_function(RegisterFile_Multi_Banked,FUNCTION,_name.c_str());
24   
25    // call function pointer
26//     (this->*function_transition) ();
27    if (PORT_READ(in_NRESET) == 0)
28      {
29        if (_param->_have_init_value)
30          {
31            for (uint32_t i=0; i<_param->_nb_bank; ++i)
32              for (uint32_t j=0; j<_param->_nb_word; ++j)
33                reg_DATA[i][j] = fromString<Tdata_t>(_param->_init_value);
34          }
35        else
36          {
37            for (uint32_t i=0; i<_param->_nb_bank; ++i)
38              for (uint32_t j=0; j<_param->_nb_word; ++j)
39                reg_DATA[i][j] = 0;
40          }
41      }
42    else
43      {
44        for (uint32_t i=0; i<_param->_nb_port_write; i++)
45          {
46            if (internal_WRITE_VAL [i] == 1)
47              {
48                Tdata_t data = PORT_READ(in_WRITE_DATA   [i]);
49               
50                // Write in registerFile
51                reg_DATA[internal_WRITE_BANK[i]][internal_WRITE_NUM_REG[i]] = data;
52              }
53
54#ifdef STATISTICS
55            if (usage_is_set(_usage,USE_STATISTICS))
56              if (PORT_READ(in_WRITE_VAL [i]))
57                {
58                  if (internal_WRITE_VAL [i] == 1)
59                    (*_stat_nb_write) ++;
60                  else
61                    (*_stat_nb_conflict_on_write) ++;
62                }                 
63#endif   
64          }
65
66#ifdef STATISTICS
67        if (usage_is_set(_usage,USE_STATISTICS))
68          for (uint32_t i=0; i<_param->_nb_port_read; i++)
69            if (PORT_READ(in_READ_VAL [i]))
70              {
71                if (internal_READ_VAL [i] == 1)
72                  (*_stat_nb_read) ++;
73                else
74                  (*_stat_nb_conflict_on_read) ++;
75              }           
76#endif   
77
78      }
79
80#if defined(DEBUG_RegisterFile_Multi_Banked) and DEBUG_RegisterFile_Multi_Banked and (DEBUG >= DEBUG_TRACE)
81    if (0)
82    {
83      log_printf(TRACE,RegisterFile,FUNCTION,"  * Dump RegisterFile");
84
85      uint32_t limit = 4;
86     
87      for (uint32_t i=0; i<_param->_nb_bank; i++)
88        {
89         
90          log_printf(TRACE,RegisterFile,FUNCTION,"  Bank %d",i);
91
92          for (uint32_t j=0; j<_param->_nb_word_by_bank; j+=limit)
93            {
94              std::string str = "";
95             
96              for (uint32_t k=0; k<limit; k++)
97                {
98                  uint32_t index = j+k;
99                  if (index >= _param->_nb_word)
100                    break;
101                  else
102                    str+=toString("[%.4d] %.8x ",index,reg_DATA[i][index]);
103                }
104             
105              log_printf(TRACE,RegisterFile,FUNCTION,"  %s",str.c_str());
106            }
107        }
108    }
109#endif
110
111#if defined(STATISTICS) or defined(VHDL_TESTBENCH)
112    end_cycle();
113#endif
114
115    log_end(RegisterFile_Multi_Banked,FUNCTION);
116  };
117
118}; // end namespace registerfile_multi_banked
119}; // end namespace registerfile
120}; // end namespace generic
121
122}; // end namespace behavioural
123}; // end namespace morpheo             
124#endif
125//#endif
Note: See TracBrowser for help on using the repository browser.