source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Generic/Select/Select_Priority_Fixed/SelfTest/src/test.cpp @ 82

Last change on this file since 82 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.3 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 512
10#define CYCLE_MAX    (1024*NB_ITERATION)
11
12#include "Behavioural/Generic/Select/Select_Priority_Fixed/SelfTest/include/test.h"
13#include "Common/include/Test.h"
14
15void test (string name,
16           morpheo::behavioural::generic::select::select_priority_fixed::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  Select_Priority_Fixed * _Select_Priority_Fixed = new Select_Priority_Fixed
25    (name.c_str(),
26#ifdef STATISTICS
27     _param_stat,
28#endif
29     _param,
30     USE_ALL);
31 
32#ifdef SYSTEMC
33  /*********************************************************************
34   * Déclarations des signaux
35   *********************************************************************/
36  sc_clock                         * CLOCK ;
37  sc_signal<Tcontrol_t>            * NRESET;
38  sc_signal<Tcontrol_t>           ** VAL   ;
39  sc_signal<Tcontrol_t>           ** ACK   ;
40  sc_signal<Tentity_t >            * ENTITY;
41  sc_signal<Tcontrol_t>            * ENTITY_ACK;
42
43  string rename;
44
45  CLOCK        = new sc_clock ("clock", 1.0, 0.5);
46  NRESET       = new sc_signal<Tcontrol_t> ("NRESET");
47  VAL          = new sc_signal<Tcontrol_t> * [_param->_nb_entity];
48  ACK          = new sc_signal<Tcontrol_t> * [_param->_nb_entity];
49
50  for (uint32_t i=0; i<_param->_nb_entity; i++)
51    {
52      rename = "VAL_"+toString(i);
53      VAL [i] = new sc_signal<Tcontrol_t> (rename.c_str());
54      rename = "ACK_"+toString(i);
55      ACK [i] = new sc_signal<Tcontrol_t> (rename.c_str());
56    }
57 
58  ENTITY       = new sc_signal<Tentity_t>  ("entity");
59  ENTITY_ACK   = new sc_signal<Tcontrol_t> ("entity_ack");
60 
61  /********************************************************
62   * Instanciation
63   ********************************************************/
64 
65  cout << "<" << name << "> Instanciation of _Select_Priority_Fixed" << endl;
66 
67  (*(_Select_Priority_Fixed->in_CLOCK ))       (*(CLOCK ));
68  (*(_Select_Priority_Fixed->in_NRESET))       (*(NRESET));
69
70    for (uint32_t i=0; i<_param->_nb_entity; i++)
71      {
72        (*(_Select_Priority_Fixed-> in_VAL [i]))        (*(VAL [i]));
73        if (_param->_encoding_one_hot)
74        (*(_Select_Priority_Fixed->out_ACK [i]))        (*(ACK [i]));
75      }
76    if (_param->_encoding_compact)
77      {
78    (*(_Select_Priority_Fixed->out_ENTITY    ))        (*(ENTITY    ));
79    (*(_Select_Priority_Fixed->out_ENTITY_ACK))        (*(ENTITY_ACK));
80      }
81  /********************************************************
82   * Simulation - Begin
83   ********************************************************/
84
85  cout << "<" << name << "> Start Simulation ............" << endl;
86
87  if (_param->_nb_entity > (8*sizeof (Tentity_t)))
88    throw ErrorMorpheo("No Selftest with nb_entity higher at "+toString(8*sizeof (Tentity_t)));
89
90  // Initialisation
91  const uint32_t seed = 0;
92//const uint32_t seed = static_cast<uint32_t>(time(NULL));
93
94  srand(seed);
95
96  Tentity_t entity;
97 
98  sc_start(0);
99//cout << "{"+toString(static_cast<uint32_t>(sc_simulation_time()))+"} Initialisation" << endl;
100
101  cout << "{"+toString(static_cast<uint32_t>(sc_simulation_time()))+"} Loop of Test" << endl;
102
103  for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++)
104    {
105      entity    = 0;
106      bool find = false;
107     
108      for (uint32_t i=0; i<_param->_nb_entity; i++)
109        {
110          Tcontrol_t val = rand() % 2;
111
112          VAL [i]->write(val);
113         
114          if (not find and val)
115            {
116              find   = true;
117              entity = i;
118            }
119        }
120
121      sc_start(1);
122 
123      cout << "wait entity : " << entity << endl;
124   
125      entity = (find)?entity:0;
126
127      if (_param->_encoding_one_hot)
128        TEST(Tcontrol_t, ACK   [entity]->read(), find  );
129      if (_param->_encoding_compact)
130        {
131        TEST(Tentity_t , ENTITY        ->read(), entity); // burk
132        TEST(Tcontrol_t, ENTITY_ACK    ->read(), find  ); // burk
133        }
134    }
135
136  /********************************************************
137   * Simulation - End
138   ********************************************************/
139
140  cout << "<" << name << "> ............ Stop Simulation" << endl;
141
142  delete    CLOCK;
143  delete    NRESET;
144  delete [] VAL       ;
145  delete [] ACK       ;
146  delete    ENTITY    ;
147  delete    ENTITY_ACK;
148#endif
149
150  delete _Select_Priority_Fixed;
151}
Note: See TracBrowser for help on using the repository browser.