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

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

1) Stat_list : fix retire old and new register bug
2) Stat_list : remove read_counter and valid flag, because validation of destination is in retire step (not in commit step)
3) Model : add class Model (cf Morpheo.sim)
4) Allocation : alloc_interface_begin and alloc_interface_end to delete temporary array.
5) Script : add distexe.sh
6) Add Comparator, Multiplier, Divider. But this component are not implemented
7) Software : add Dhrystone

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