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

Last change on this file since 71 was 71, checked in by rosiere, 16 years ago

Modification of Statisctics
Add a new systemC component : Load_Store_Queue (tested with one benchmark and one configuration). Store don't supported the Data Buss Error (Load is supported)

File size: 3.7 KB
Line 
1/*
2 * $Id$
3 *
4 * [ Description ]
5 *
6 * Test
7 */
8
9#define NB_ITERATION 1024
10
11#include "Behavioural/Generic/Counter/SelfTest/include/test.h"
12#include "Common/include/Test.h"
13
14void test (string name,
15           morpheo::behavioural::generic::counter::Parameters param)
16{
17  cout << "<" << name << "> : Simulation SystemC" << endl;
18
19  try 
20    {
21      cout << param.print(1);
22      param.test();
23    }
24  catch (morpheo::ErrorMorpheo & error)
25    {
26      cout << "<" << name << "> : " <<  error.what ();
27      return;
28    }
29  catch (...)
30    {
31      cerr << "<" << name << "> : This test must generate a error" << endl;
32      exit (EXIT_FAILURE);
33    }
34#ifdef STATISTICS
35  morpheo::behavioural::Parameters_Statistics * param_stat = new morpheo::behavioural::Parameters_Statistics (5,50);
36#endif
37
38  Counter * _Counter = new Counter (name.c_str(),
39#ifdef STATISTICS
40                                    param_stat,
41#endif
42                                    param);
43 
44#ifdef SYSTEMC
45  /*********************************************************************
46   * Déclarations des signaux
47   *********************************************************************/
48  sc_clock                                 CLOCK ("clock", 1.0, 0.5);
49  sc_signal<Tcontrol_t>                    RESET;
50  sc_signal<Tdata_t>                       DATA_IN  [param._nb_port];
51  sc_signal<Tcontrol_t>                    ADDSUB   [param._nb_port];
52  sc_signal<Tdata_t>                       DATA_OUT [param._nb_port];
53
54  /********************************************************
55   * Instanciation
56   ********************************************************/
57 
58  cout << "<" << name << "> Instanciation of _Counter" << endl;
59 
60  (*(_Counter->in_CLOCK))        (CLOCK);
61  (*(_Counter->in_NRESET))       (RESET);
62
63  for (uint32_t i=0; i<param._nb_port; i++)
64    {
65      (*(_Counter-> in_COUNTER_DATA  [i]))        (DATA_IN  [i]);
66      (*(_Counter-> in_COUNTER_ADDSUB[i]))        (ADDSUB   [i]);
67      (*(_Counter->out_COUNTER_DATA  [i]))        (DATA_OUT [i]);
68    }
69
70  /********************************************************
71   * Simulation - Begin
72   ********************************************************/
73
74  cout << "<" << name << "> Start Simulation ............" << endl;
75  // Initialisation
76
77  srand(0);
78  //srand(TIME(NULL));
79
80  Tdata_t    data_in  [param._nb_port];
81  Tdata_t    data_out [param._nb_port];
82  Tcontrol_t addsub   [param._nb_port];
83
84  sc_start(0);
85
86  RESET.write(1);
87
88  cout << "{"+toString(static_cast<uint32_t>(sc_simulation_time()))+"} Initialisation" << endl;
89
90  cout << "{"+toString(static_cast<uint32_t>(sc_simulation_time()))+"} Loop of Test" << endl;
91
92  for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++)
93    {
94      cout << "{" << static_cast<uint32_t>(sc_simulation_time()) << "} Itération " << iteration << endl;
95      for (uint32_t i=0; i<param._nb_port; i++)
96        {
97          Tdata_t data = rand()%param._data_max;
98          data_in  [i] = data;
99          addsub   [i] = (rand()%2)==1; 
100         
101          DATA_IN  [i].write(data      );
102          ADDSUB   [i].write(addsub [i]);
103
104          data_out [i] = (addsub[i]==1)?((data<param._data_max)?data+1:data):((data>0)?data-1:data);
105        }
106
107      sc_start(0);
108     
109      for (uint32_t i=0; i<param._nb_port; i++)
110        {
111          cout << hex
112               << "    [" << i << "] "
113               << data_in [i];
114
115          if (addsub[i] == 1)
116            cout << " ++";
117          else
118            cout << " --";
119
120          cout << " = " 
121               << DATA_OUT [i].read();
122
123          TEST(Tdata_t,DATA_OUT [i].read(),data_out [i]);
124           
125          cout << std::dec << endl;
126        }
127     
128      sc_start(1);
129    }
130
131  sc_start(1);
132
133  /********************************************************
134   * Simulation - End
135   ********************************************************/
136
137  cout << "<" << name << "> ............ Stop Simulation" << endl;
138
139#endif
140
141  delete _Counter;
142#ifdef STATISTICS
143  delete param_stat;
144#endif
145
146}
Note: See TracBrowser for help on using the repository browser.