source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Queue/SelfTest/src/test.cpp @ 83

Last change on this file since 83 was 82, checked in by rosiere, 16 years ago
  • support locale (now must "just" translate)
  • update all component with new test format
  • update all component with usage
  • New component : decod queue and prediction_unit
  • Property svn:keywords set to Id
File size: 4.0 KB
Line 
1/*
2 * $Id: test.cpp 82 2008-05-01 16:48:45Z rosiere $
3 *
4 * [ Description ]
5 *
6 * Test
7 */
8
9#define NB_ITERATION  1
10#define CYCLE_MAX     (2048*NB_ITERATION)
11
12#include "Behavioural/Generic/Queue/SelfTest/include/test.h"
13#include "Common/include/Test.h"
14
15void test (string name,
16           morpheo::behavioural::generic::queue::Parameters * _param)
17{
18  cout << "<" << name << "> : Simulation SystemC" << endl;
19
20#ifdef STATISTICS
21  morpheo::behavioural::Parameters_Statistics * _parameters_statistics = new morpheo::behavioural::Parameters_Statistics (5,50);
22#endif
23
24  Queue * _Queue = new Queue
25    (name.c_str(),
26#ifdef STATISTICS
27     _parameters_statistics,
28#endif
29     _param,
30     USE_ALL);
31 
32#ifdef SYSTEMC
33  /*********************************************************************
34   * Déclarations des signaux
35   *********************************************************************/
36  string rename;
37
38  sc_clock              *  in_CLOCK  = new sc_clock ("clock", 1.0, 0.5);         
39  sc_signal<Tcontrol_t> *  in_NRESET = new sc_signal<Tcontrol_t> ("NRESET");
40  sc_signal<Tcontrol_t> *  in_INSERT_VAL  = new sc_signal<Tcontrol_t> ( "in_INSERT_VAL" );
41  sc_signal<Tcontrol_t> * out_INSERT_ACK  = new sc_signal<Tcontrol_t> ("out_INSERT_ACK" );
42  sc_signal<Tdata_t   > *  in_INSERT_DATA = new sc_signal<Tdata_t   > ( "in_INSERT_DATA");
43  sc_signal<Tcontrol_t> * out_RETIRE_VAL  = new sc_signal<Tcontrol_t> ("out_RETIRE_VAL" );
44  sc_signal<Tcontrol_t> *  in_RETIRE_ACK  = new sc_signal<Tcontrol_t> ( "in_RETIRE_ACK" );
45  sc_signal<Tdata_t   > * out_RETIRE_DATA = new sc_signal<Tdata_t   > ("out_RETIRE_DATA");
46 
47  /********************************************************
48   * Instanciation
49   ********************************************************/
50 
51  cout << "<" << name << "> Instanciation of _Queue" << endl;
52 
53  (*(_Queue->in_CLOCK))        (*(in_CLOCK));
54  (*(_Queue->in_NRESET))       (*(in_NRESET));
55
56  (*(_Queue-> in_INSERT_VAL )) (*( in_INSERT_VAL ));
57  (*(_Queue->out_INSERT_ACK )) (*(out_INSERT_ACK ));
58  (*(_Queue-> in_INSERT_DATA)) (*( in_INSERT_DATA));
59  (*(_Queue->out_RETIRE_VAL )) (*(out_RETIRE_VAL ));
60  (*(_Queue-> in_RETIRE_ACK )) (*( in_RETIRE_ACK ));
61  (*(_Queue->out_RETIRE_DATA)) (*(out_RETIRE_DATA));
62
63  cout << "<" << name << "> Start Simulation ............" << endl;
64  Time * _time = new Time();
65
66  /********************************************************
67   * Simulation - Begin
68   ********************************************************/
69
70  // Initialisation
71  const  int32_t percent_insert_transaction = 75;
72  const  int32_t percent_retire_transaction = 75;
73  const uint32_t nb_request = 3*_param->_size_queue;
74
75  const uint32_t seed = 0;
76//const uint32_t seed = static_cast<uint32_t>(time(NULL));
77
78  srand(seed);
79
80  SC_START(0);
81  LABEL("Initialisation");
82
83  in_INSERT_VAL -> write(0);
84  in_RETIRE_ACK -> write(0);
85
86  LABEL("Reset");
87  in_NRESET->write(0);
88  SC_START(5);
89  in_NRESET->write(1); 
90
91  LABEL("Loop of Test");
92
93  uint32_t data_in  = 0;
94  uint32_t data_out = 0;
95
96  for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++)
97    {
98      LABEL("Iteration %d",iteration);
99
100      while (data_out <= nb_request)
101        {
102          in_INSERT_VAL  -> write((rand()%100)<percent_insert_transaction);
103          in_INSERT_DATA -> write(data_in);
104          in_RETIRE_ACK  -> write((rand()%100)<percent_retire_transaction);
105
106          SC_START(0); // genMoore
107
108          if ( in_INSERT_VAL->read() and out_INSERT_ACK->read())
109            {
110              LABEL ("Transaction with interface : INSERT");
111              data_in ++;
112            }
113          if (out_RETIRE_VAL->read() and  in_RETIRE_ACK->read())
114            {
115              LABEL ("Transaction with interface : RETIRE");
116              TEST(Tdata_t, out_RETIRE_DATA->read(), data_out);
117              data_out++;
118            }
119
120          SC_START(1);
121        }
122    }
123
124  /********************************************************
125   * Simulation - End
126   ********************************************************/
127
128  TEST_OK ("End of Simulation");
129  delete _time;
130  cout << "<" << name << "> ............ Stop Simulation" << endl;
131
132  delete in_CLOCK;
133  delete in_NRESET;
134#endif
135
136  delete _Queue;
137#ifdef STATISTICS
138  delete _parameters_statistics;
139#endif
140}
Note: See TracBrowser for help on using the repository browser.