source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/RegisterFile/RegisterFile_Multi_Banked/SelfTest/src/test.cpp @ 145

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

1) add test with SPECINT2K
2) new config of Selftest
3) modif RAT to support multiple depth_save ... but not finish (need fix Update Prediction Table)
4) add Function_pointer but need fix

  • Property svn:keywords set to Id
File size: 7.4 KB
Line 
1/*
2 * $Id: test.cpp 145 2010-10-13 18:15:51Z rosiere $
3 *
4 * [ Description ]
5 *
6 * Test
7 */
8
9#define NB_ITERATION  1
10#define CYCLE_MAX     (10240*NB_ITERATION)
11
12#include "Behavioural/Generic/RegisterFile/RegisterFile_Multi_Banked/SelfTest/include/test.h"
13#include "Common/include/Test.h"
14
15void test (string name,
16           morpheo::behavioural::generic::registerfile::registerfile_multi_banked::Parameters * _param)
17{
18  cout << "<" << name << "> : Simulation SystemC" << endl;
19
20
21#ifdef STATISTICS
22  morpheo::behavioural::Parameters_Statistics * _param_stat = new morpheo::behavioural::Parameters_Statistics(5,50);
23#endif
24
25  _model.set_model(MODEL_SYSTEMC,true);
26
27  Tusage_t _usage = USE_ALL;
28
29//   _usage = usage_unset(_usage,USE_SYSTEMC              );
30//   _usage = usage_unset(_usage,USE_VHDL                 );
31//   _usage = usage_unset(_usage,USE_VHDL_TESTBENCH       );
32//   _usage = usage_unset(_usage,USE_VHDL_TESTBENCH_ASSERT);
33//   _usage = usage_unset(_usage,USE_POSITION             );
34//    _usage = usage_unset(_usage,USE_STATISTICS           );
35//   _usage = usage_unset(_usage,USE_INFORMATION          );
36
37  RegisterFile_Multi_Banked * _RegisterFile_Multi_Banked = new RegisterFile_Multi_Banked
38    (name.c_str(),
39#ifdef STATISTICS
40     _param_stat,
41#endif
42     _param,
43     _usage);
44
45#if 0 
46// #ifdef SYSTEMC
47
48  /*********************************************************************
49   * Déclarations des signaux
50   *********************************************************************/
51  sc_clock                               * CLOCK;
52  sc_signal<Tcontrol_t>                  * NRESET;
53
54  sc_signal<Tcontrol_t>                    READ_VAL      [_param->_nb_port_read];
55  sc_signal<Tcontrol_t>                    READ_ACK      [_param->_nb_port_read];
56  sc_signal<Taddress_t>                    READ_ADDRESS  [_param->_nb_port_read];
57  sc_signal<Tdata_t>                       READ_DATA     [_param->_nb_port_read];
58
59  sc_signal<Tcontrol_t>                    WRITE_VAL     [_param->_nb_port_write];
60  sc_signal<Tcontrol_t>                    WRITE_ACK     [_param->_nb_port_write];
61  sc_signal<Taddress_t>                    WRITE_ADDRESS [_param->_nb_port_write];
62  sc_signal<Tdata_t>                       WRITE_DATA    [_param->_nb_port_write];
63
64  string rename;
65
66  CLOCK                                  = new sc_clock ("clock", 1.0, 0.5);
67  NRESET                                 = new sc_signal<Tcontrol_t> ("NRESET");
68 
69  /********************************************************
70   * Instanciation
71   ********************************************************/
72 
73  cout << "<" << name << "> Instanciation of _RegisterFile_Multi_Banked" << endl;
74 
75  (*(_RegisterFile_Multi_Banked->in_CLOCK))        (*(CLOCK));
76  (*(_RegisterFile_Multi_Banked->in_NRESET))       (*(NRESET));
77
78  for (uint32_t i=0; i<_param->_nb_port_read; i++)
79    {
80      (*(_RegisterFile_Multi_Banked-> in_READ_VAL      [i]))        (READ_VAL      [i]);
81      (*(_RegisterFile_Multi_Banked->out_READ_ACK      [i]))        (READ_ACK      [i]);
82      if (_param->_have_port_address==true)
83      (*(_RegisterFile_Multi_Banked-> in_READ_ADDRESS  [i]))        (READ_ADDRESS  [i]);
84      (*(_RegisterFile_Multi_Banked->out_READ_DATA     [i]))        (READ_DATA     [i]);
85    }
86
87  for (uint32_t i=0; i<_param->_nb_port_write; i++)
88    {
89      (*(_RegisterFile_Multi_Banked-> in_WRITE_VAL     [i]))        (WRITE_VAL     [i]);
90      (*(_RegisterFile_Multi_Banked->out_WRITE_ACK     [i]))        (WRITE_ACK     [i]);
91      if (_param->_have_port_address==true)
92      (*(_RegisterFile_Multi_Banked-> in_WRITE_ADDRESS [i]))        (WRITE_ADDRESS [i]);
93      (*(_RegisterFile_Multi_Banked-> in_WRITE_DATA    [i]))        (WRITE_DATA    [i]);
94    }
95
96  cout << "<" << name << "> Start Simulation ............" << endl;
97  Time * _time = new Time();
98
99  /********************************************************
100   * Simulation - Begin
101   ********************************************************/
102  const uint32_t nb_request    = _param->_nb_word;
103  // random init
104  const uint32_t grain         = 0;
105  //const uint32_t grain = static_cast<uint32_t>(time(NULL));
106 
107  srand(grain);
108
109  // Initialisation
110
111  SC_START(0);
112 
113  for (uint32_t i=0; i<_param->_nb_port_write; i++)
114    WRITE_VAL [i] .write (0);
115
116  for (uint32_t i=0; i<_param->_nb_port_read; i++)
117    READ_VAL  [i] .write (0);
118
119  NRESET->write(0);
120
121  SC_START(5);
122
123  NRESET->write(1);
124
125  for (uint32_t nb_iteration=0; nb_iteration < NB_ITERATION; nb_iteration ++)
126    {
127      cout << "<" << name << "> 1) Write the RegisterFile (no read)" << endl;
128
129      Taddress_t nb_val            = 0;
130      Taddress_t nb_ack            = 0;
131     
132      Tdata_t    tab_data    [_param->_nb_word];
133      Taddress_t tab_address [nb_request      ];
134 
135      for (uint32_t i=0; i<_param->_nb_word; i++)
136        tab_data    [i]= rand()%(1<<(_param->_size_word-1));
137      for (uint32_t i=0; i<nb_request; i++)
138        tab_address [i]= rand()%(1<<(_param->_size_address));
139
140      while (nb_ack < nb_request)
141        {
142          cout << "cycle : " << static_cast<uint32_t> (simulation_cycle()) << endl;
143
144          for (uint32_t num_port=0; num_port < _param->_nb_port_write; num_port ++)
145            {
146              if ((nb_val            < nb_request) and
147                  (WRITE_VAL [num_port].read() == 0))
148                {
149                  cout << "(" << num_port << ") [" << tab_address[nb_val] << "] <= " << tab_data[tab_address[nb_val]] << endl;
150                 
151                  WRITE_VAL     [num_port] .write(1);
152                  WRITE_DATA    [num_port] .write(tab_data[tab_address[nb_val]]);
153                  WRITE_ADDRESS [num_port] .write(tab_address[nb_val]);
154
155                  nb_val ++;
156
157                  // Address can be not a multiple of nb_port_write
158                  if (nb_val >= nb_request)
159                    break;
160                }
161            }
162         
163          SC_START(1);
164
165          // reset write_val port
166          for (uint32_t num_port=0; num_port < _param->_nb_port_write; num_port ++)
167            {
168              if ((WRITE_ACK [num_port].read() == 1) and
169                  (WRITE_VAL [num_port].read() == 1))
170                {
171                  WRITE_VAL  [num_port] .write(0);
172                  nb_ack ++;
173                }
174            }
175
176          SC_START(0);
177        }
178     
179
180      {
181        cout << "<" << name << "> 2) Read the RegisterFile (no write)" << endl;
182       
183        nb_val = 0;
184        nb_ack = 0;
185        Tdata_t read_address [_param->_nb_port_read];
186       
187        while (nb_ack < nb_request)
188          {
189            cout << "cycle : " << static_cast<uint32_t> (simulation_cycle()) << endl;
190           
191            for (uint32_t num_port=0; num_port < _param->_nb_port_read; num_port ++)
192              {
193                if ((nb_val < nb_request) and
194                    (READ_VAL [num_port].read() == 0))
195                  {
196                    read_address [num_port] = tab_address[nb_val];
197                    READ_VAL     [num_port].write(1);
198                    READ_ADDRESS [num_port].write(read_address [num_port]);
199                   
200                    nb_val ++;
201                   
202                    if (nb_val >= nb_request)
203                      break;
204                  }
205              }
206             
207            SC_START(1);
208           
209            // reset write_val port
210            for (uint32_t num_port=0; num_port < _param->_nb_port_read; num_port ++)
211              {
212                if ((READ_ACK [num_port].read() == 1) and
213                    (READ_VAL [num_port].read() == 1))
214                  {
215                    READ_VAL  [num_port] .write(0);
216                   
217                    cout << "(" << num_port << ") [" << read_address [num_port] << "] => " << READ_DATA [num_port].read() << endl;
218                   
219                    TEST(Tdata_t,READ_DATA [num_port].read(), tab_data[read_address [num_port]]);
220                    nb_ack ++;
221                  }
222              }
223           
224            SC_START(0);
225          }
226      }
227    }
228 
229  /********************************************************
230   * Simulation - End
231   ********************************************************/
232
233  delete _time;
234  cout << "<" << name << "> ............ Stop Simulation" << endl;
235
236  delete CLOCK;
237  delete NRESET;
238#endif
239  TEST_OK("End of Simulation");
240
241  delete _RegisterFile_Multi_Banked;
242}
Note: See TracBrowser for help on using the repository browser.