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

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

Almost complete design
with Test and test platform

  • Property svn:keywords set to Id
File size: 4.7 KB
Line 
1/*
2 * $Id: test.cpp 88 2008-12-10 18:31:39Z 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#ifdef STATISTICS
21  morpheo::behavioural::Parameters_Statistics * _param_stat = new morpheo::behavioural::Parameters_Statistics (5,50);
22#endif
23
24  Tusage_t _usage = USE_ALL;
25
26//   _usage = usage_unset(_usage,USE_SYSTEMC              );
27//   _usage = usage_unset(_usage,USE_VHDL                 );
28//   _usage = usage_unset(_usage,USE_VHDL_TESTBENCH       );
29//   _usage = usage_unset(_usage,USE_VHDL_TESTBENCH_ASSERT);
30//   _usage = usage_unset(_usage,USE_POSITION             );
31//   _usage = usage_unset(_usage,USE_STATISTICS           );
32//   _usage = usage_unset(_usage,USE_INFORMATION          );
33
34  Select_Priority_Fixed * _Select_Priority_Fixed = new Select_Priority_Fixed
35    (name.c_str(),
36#ifdef STATISTICS
37     _param_stat,
38#endif
39     _param,
40     _usage);
41 
42#ifdef SYSTEMC
43  /*********************************************************************
44   * Déclarations des signaux
45   *********************************************************************/
46  sc_clock                         * CLOCK ;
47  sc_signal<Tcontrol_t>            * NRESET;
48  sc_signal<Tcontrol_t>           ** VAL   ;
49  sc_signal<Tcontrol_t>           ** ACK   ;
50  sc_signal<Tentity_t >            * ENTITY;
51  sc_signal<Tcontrol_t>            * ENTITY_ACK;
52
53  string rename;
54
55  CLOCK        = new sc_clock ("clock", 1.0, 0.5);
56  NRESET       = new sc_signal<Tcontrol_t> ("NRESET");
57  VAL          = new sc_signal<Tcontrol_t> * [_param->_nb_entity];
58  ACK          = new sc_signal<Tcontrol_t> * [_param->_nb_entity];
59
60  for (uint32_t i=0; i<_param->_nb_entity; i++)
61    {
62      rename = "VAL_"+toString(i);
63      VAL [i] = new sc_signal<Tcontrol_t> (rename.c_str());
64      rename = "ACK_"+toString(i);
65      ACK [i] = new sc_signal<Tcontrol_t> (rename.c_str());
66    }
67 
68  ENTITY       = new sc_signal<Tentity_t>  ("entity");
69  ENTITY_ACK   = new sc_signal<Tcontrol_t> ("entity_ack");
70 
71  /********************************************************
72   * Instanciation
73   ********************************************************/
74 
75  cout << "<" << name << "> Instanciation of _Select_Priority_Fixed" << endl;
76 
77  (*(_Select_Priority_Fixed->in_CLOCK ))       (*(CLOCK ));
78  (*(_Select_Priority_Fixed->in_NRESET))       (*(NRESET));
79
80    for (uint32_t i=0; i<_param->_nb_entity; i++)
81      {
82        (*(_Select_Priority_Fixed-> in_VAL [i]))        (*(VAL [i]));
83        if (_param->_encoding_one_hot)
84        (*(_Select_Priority_Fixed->out_ACK [i]))        (*(ACK [i]));
85      }
86    if (_param->_encoding_compact)
87      {
88    (*(_Select_Priority_Fixed->out_ENTITY    ))        (*(ENTITY    ));
89    (*(_Select_Priority_Fixed->out_ENTITY_ACK))        (*(ENTITY_ACK));
90      }
91  /********************************************************
92   * Simulation - Begin
93   ********************************************************/
94
95  cout << "<" << name << "> Start Simulation ............" << endl;
96
97  if (_param->_nb_entity > (8*sizeof (Tentity_t)))
98    throw ErrorMorpheo("No Selftest with nb_entity higher at "+toString(8*sizeof (Tentity_t)));
99
100  // Initialisation
101  const uint32_t seed = 0;
102//const uint32_t seed = static_cast<uint32_t>(time(NULL));
103
104  srand(seed);
105
106  Tentity_t entity;
107 
108  sc_start(0);
109//cout << "{"+toString(static_cast<uint32_t>(sc_simulation_time()))+"} Initialisation" << endl;
110
111  cout << "{"+toString(static_cast<uint32_t>(sc_simulation_time()))+"} Loop of Test" << endl;
112
113  for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++)
114    {
115      entity    = 0;
116      bool find = false;
117     
118      for (uint32_t i=0; i<_param->_nb_entity; i++)
119        {
120          Tcontrol_t val = rand() % 2;
121
122          VAL [i]->write(val);
123         
124          if (not find and val)
125            {
126              find   = true;
127              entity = i;
128            }
129        }
130
131      sc_start(1);
132 
133      cout << "wait entity : " << entity << endl;
134   
135      entity = (find)?entity:0;
136
137      if (_param->_encoding_one_hot)
138        TEST(Tcontrol_t, ACK   [entity]->read(), find  );
139      if (_param->_encoding_compact)
140        {
141        TEST(Tentity_t , ENTITY        ->read(), entity); // burk
142        TEST(Tcontrol_t, ENTITY_ACK    ->read(), find  ); // burk
143        }
144    }
145
146  /********************************************************
147   * Simulation - End
148   ********************************************************/
149
150  cout << "<" << name << "> ............ Stop Simulation" << endl;
151
152  delete    CLOCK;
153  delete    NRESET;
154  delete [] VAL       ;
155  delete [] ACK       ;
156  delete    ENTITY    ;
157  delete    ENTITY_ACK;
158#endif
159
160  delete _Select_Priority_Fixed;
161}
Note: See TracBrowser for help on using the repository browser.