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

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

Add :

  • Execute_loop (must be test systemC)
  • Prediction
    • Direction : predifined scheme
    • Branch Target Buffer
  • iFetch_unit
    • ifetch_queue
    • pc management
  • Decod_unit
    • coming soon : support for custom operation
  • Rename_unit
    • RAT
    • Free_list
    • Dependence RAW check
    • Load store unit pointer
  • New Environnement (hierarchy_memory will remove in a next version)


Modif :

  • Manage Custom Operation
  • All component in execute_loop to use the new statistics management

Not Finish :

  • Return Address Stack
  • Environnement
File size: 4.5 KB
Line 
1/*
2 * $Id$
3 *
4 * [ Description ]
5 *
6 * Test
7 */
8
9#include "Behavioural/Generic/Victim/SelfTest/include/test.h"
10#include "Common/include/Test.h"
11#include "Behavioural/include/Allocation.h"
12
13#define NB_ITERATION  10
14#define CYCLE_MAX     (128*NB_ITERATION)
15
16#define LABEL(str...)                                                   \
17  {                                                                     \
18    msg (_("{%d} "),static_cast<uint32_t>(sc_simulation_time()));       \
19    msg (str);                                                          \
20    msg (_("\n"));                                                      \
21  } while(0)
22
23#define SC_START(cycle_offset)                                                       \
24  do                                                                                 \
25    {                                                                                \
26      /*cout << "SC_START (begin)" << endl;*/                                        \
27                                                                                     \
28      uint32_t cycle_current = static_cast<uint32_t>(sc_simulation_time());          \
29      if (cycle_offset != 0)                                                         \
30        {                                                                            \
31          cout << "##########[ cycle "<< cycle_current+cycle_offset << " ]" << endl; \
32        }                                                                            \
33                                                                                     \
34      if (cycle_current > CYCLE_MAX)                                                 \
35        {                                                                            \
36          TEST_KO("Maximal cycles Reached");                                         \
37        }                                                                            \
38                                                                                     \
39      sc_start(cycle_offset);                                                        \
40                                                                                     \
41      /*cout << "SC_START (end  )" << endl;*/                                        \
42    } while(0)
43
44void test (string name,
45           morpheo::behavioural::generic::victim::Parameters * _param)
46{
47  msg(_("<%s> : Simulation SystemC.\n"),name.c_str());
48
49#ifdef STATISTICS
50  morpheo::behavioural::Parameters_Statistics * _parameters_statistics = new morpheo::behavioural::Parameters_Statistics (5,50);
51#endif
52
53  Victim * _Victim = new Victim (name.c_str(),
54#ifdef STATISTICS
55                                             _parameters_statistics,
56#endif
57                                             _param);
58 
59#ifdef SYSTEMC
60  /*********************************************************************
61   * Déclarations des signaux
62   *********************************************************************/
63  string rename;
64
65  sc_clock              *  in_CLOCK  = new sc_clock ("clock", 1.0, 0.5);         
66  sc_signal<Tcontrol_t> *  in_NRESET = new sc_signal<Tcontrol_t> ("NRESET");
67
68  ALLOC1_SC_SIGNAL( in_ACCESS_VAL    ," in_ACCESS_VAL    ",Tcontrol_t,_param->_nb_access);
69  ALLOC1_SC_SIGNAL(out_ACCESS_ACK    ,"out_ACCESS_ACK    ",Tcontrol_t,_param->_nb_access);
70  ALLOC1_SC_SIGNAL( in_ACCESS_ADDRESS," in_ACCESS_ADDRESS",Taddress_t,_param->_nb_access);
71  ALLOC1_SC_SIGNAL( in_ACCESS_HIT    ," in_ACCESS_HIT    ",Tcontrol_t,_param->_nb_access);
72  ALLOC1_SC_SIGNAL( in_ACCESS_ENTITY ," in_ACCESS_ENTITY ",Tentity_t ,_param->_nb_access);
73  ALLOC1_SC_SIGNAL(out_ACCESS_VICTIM ,"out_ACCESS_VICTIM ",Tentity_t ,_param->_nb_access);
74 
75  /********************************************************
76   * Instanciation
77   ********************************************************/
78 
79  msg(_("<%s> : Instanciation of _Victim.\n"),name.c_str());
80
81  (*(_Victim->in_CLOCK))        (*(in_CLOCK));
82  (*(_Victim->in_NRESET))       (*(in_NRESET));
83
84  INSTANCE1_SC_SIGNAL(_Victim, in_ACCESS_VAL    ,_param->_nb_access);
85  INSTANCE1_SC_SIGNAL(_Victim,out_ACCESS_ACK    ,_param->_nb_access);
86  if (_param->_have_port_address)
87  INSTANCE1_SC_SIGNAL(_Victim, in_ACCESS_ADDRESS,_param->_nb_access);
88  INSTANCE1_SC_SIGNAL(_Victim, in_ACCESS_HIT    ,_param->_nb_access);
89  INSTANCE1_SC_SIGNAL(_Victim, in_ACCESS_ENTITY ,_param->_nb_access);
90  INSTANCE1_SC_SIGNAL(_Victim,out_ACCESS_VICTIM ,_param->_nb_access);
91
92  msg(_("<%s> : Start Simulation ............\n"),name.c_str());
93   
94  Time * _time = new Time();
95
96  /********************************************************
97   * Simulation - Begin
98   ********************************************************/
99
100  // Initialisation
101
102  const uint32_t seed = 0;
103//const uint32_t seed = static_cast<uint32_t>(time(NULL));
104
105  srand(seed);
106
107  SC_START(0);
108  LABEL("Initialisation");
109
110  LABEL("Reset");
111  in_NRESET->write(0);
112  SC_START(5);
113  in_NRESET->write(1); 
114
115  LABEL("Loop of Test");
116
117  for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++)
118    {
119      LABEL("Iteration %d",iteration);
120
121      SC_START(1);
122    }
123
124  /********************************************************
125   * Simulation - End
126   ********************************************************/
127
128  TEST_OK ("End of Simulation");
129  delete _time;
130
131  msg(_("<%s> : ............ Stop Simulation\n"),name.c_str());
132
133  delete _Victim;
134
135  delete in_CLOCK;
136  delete in_NRESET;
137
138  delete []  in_ACCESS_VAL    ;
139  delete [] out_ACCESS_ACK    ;
140  delete []  in_ACCESS_ADDRESS;
141  delete []  in_ACCESS_HIT    ;
142  delete []  in_ACCESS_ENTITY ;
143  delete [] out_ACCESS_VICTIM ;
144#endif
145
146#ifdef STATISTICS
147  delete _parameters_statistics;
148#endif
149}
Note: See TracBrowser for help on using the repository browser.