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

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

1) Add modelsim simulation systemC
2) Modelsim cosimulation systemC / VHDL is not finish !!!! (cf execute_queue and write_unit)
3) Add multi architecture
5) Add template for comparator, multiplier and divider
6) Change Message
Warning) Various test macro have change, many selftest can't compile

  • Property svn:keywords set to Id
File size: 1.8 KB
Line 
1/*
2 * $Id: top_test.cpp 113 2009-04-14 18:39:12Z rosiere $
3 *
4 * [ Description ]
5 *
6 * Test
7 */
8
9#include "Behavioural/Generic/Counter/SelfTest/include/top.h"
10
11void top::test (void)
12{
13#ifdef SYSTEMC
14  Time * _time = new Time();
15
16  /********************************************************
17   * Simulation - Begin
18   ********************************************************/
19
20  cout << "<" << name << "> Start Simulation ............" << endl;
21  // Initialisation
22
23  srand(0);
24  //srand(TIME(NULL));
25
26  Tdata_t    data_in  [param->_nb_port];
27  Tdata_t    data_out [param->_nb_port];
28  Tcontrol_t addsub   [param->_nb_port];
29
30  SC_CYCLE(0);
31
32  in_NRESET->write(1);
33
34  LABEL("Initialisation");
35
36  LABEL("Loop of Test");
37
38  for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++)
39    {
40      LABEL("Iteration %d",iteration);
41
42      for (uint32_t i=0; i<param->_nb_port; i++)
43        {
44          Tdata_t data = rand()%param->_data_max;
45          data_in  [i] = data;
46          addsub   [i] = (rand()%2)==1; 
47         
48          LABEL("in_COUNTER_DATA   [%d] = %d",i,data      );
49          LABEL("in_COUNTER_ADDSUB [%d] = %d"  ,i,addsub [i]);
50
51          in_COUNTER_DATA   [i]->write(data      );
52          in_COUNTER_ADDSUB [i]->write(addsub [i]);
53
54          data_out [i] = (addsub[i]==1)?((data<param->_data_max)?data+1:data):((data>0)?data-1:data);
55        }
56
57      SC_CYCLE(0);
58
59      for (uint32_t i=0; i<param->_nb_port; i++)
60        {
61          string op = (addsub[i] == 1)?"++":"--";
62          LABEL("0x%d %s = 0x%d",i,op.c_str(),out_COUNTER_DATA [i]->read());
63
64          TEST(Tdata_t,out_COUNTER_DATA [i]->read(),data_out [i]);
65        }
66     
67      SC_CYCLE(1);
68    }
69
70  SC_CYCLE(1);
71
72  /********************************************************
73   * Simulation - End
74   ********************************************************/
75
76  sc_stop();
77
78  delete _time;
79
80  cout << "<" << name << "> ............ Stop Simulation" << endl;
81#endif
82}
Note: See TracBrowser for help on using the repository browser.