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

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