source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Execute_loop/Execute_loop/Multi_Write_unit/Write_unit/Execute_queue/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: 8.5 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/Core/Multi_Execute_loop/Execute_loop/Multi_Write_unit/Write_unit/Execute_queue/SelfTest/include/top.h"
10#include "Behavioural/include/Allocation.h"
11#include "Common/include/BitManipulation.h"
12
13  class entry_t
14  {
15  public  : Tcontext_t         _context_id   ;
16  public  : Tcontext_t         _front_end_id ;
17  public  : Tcontext_t         _ooo_engine_id;
18  public  : Tpacket_t          _packet_id    ;
19//public  : Toperation_t       _operation    ;
20//public  : Ttype_t            _type         ;
21  public  : Tspecial_data_t    _flags        ;
22  public  : Texception_t       _exception    ;
23  public  : Tcontrol_t         _no_sequence  ;
24  public  : Tgeneral_data_t    _address      ;
25  public  : Tgeneral_data_t    _data         ;
26   
27  public  : entry_t (Tcontext_t         context_id   ,
28                     Tcontext_t         front_end_id ,
29                     Tcontext_t         ooo_engine_id,
30                     Tpacket_t          packet_id    ,
31                     //Toperation_t       operation    ,
32                     //Ttype_t            type         ,
33                     Tspecial_data_t    flags        ,
34                     Texception_t       exception    ,
35                     Tcontrol_t         no_sequence  ,
36                     Tgeneral_data_t    address      ,
37                     Tgeneral_data_t    data         )
38    {
39      _context_id    = context_id   ;
40      _front_end_id  = front_end_id ;
41      _ooo_engine_id = ooo_engine_id;
42      _packet_id     = packet_id    ;
43    //_operation     = operation    ;
44    //_type          = type         ;
45      _flags         = flags        ;
46      _exception     = exception    ;
47      _no_sequence   = no_sequence  ;
48      _address       = address      ;
49      _data          = data         ;
50    };
51
52    friend std::ostream& operator<< (std::ostream& output_stream,
53                                     entry_t & x)
54    {
55      output_stream << " * _context_id    : " << toString(x._context_id   ) << std::endl
56                    << " * _front_end_id  : " << toString(x._front_end_id ) << std::endl
57                    << " * _ooo_engine_id : " << toString(x._ooo_engine_id) << std::endl
58                    << " * _packet_id     : " << toString(x._packet_id    ) << std::endl
59                  //<< " * _operation     : " << toString(x._operation    ) << std::endl
60                  //<< " * _type          : " << toString(x._type         ) << std::endl
61                    << " * _flags         : " << toString(x._flags        ) << std::endl
62                    << " * _exception     : " << toString(x._exception    ) << std::endl
63                    << " * _no_sequence   : " << toString(x._no_sequence  ) << std::endl
64                    << " * _address       : " << toString(x._address      ) << std::endl
65                    << " * _data          : " << toString(x._data         ) << std::endl;
66
67      return output_stream;
68    }
69  };
70
71void top::test (void)
72{
73#ifdef SYSTEMC
74  if (usage_is_set(_usage,USE_SYSTEMC))
75    {
76      msgInformation(_("<%s> : Start Simulation ............\n"),name.c_str());
77     
78      Time * _time = new Time();
79     
80      /********************************************************
81       * Simulation - Begin
82       ********************************************************/
83     
84  // Initialisation
85
86  const uint32_t seed = 0;
87//const uint32_t seed = static_cast<uint32_t>(time(NULL));
88
89  const  int32_t percent_transaction_execute_queue_in  = 75;
90  const  int32_t percent_transaction_execute_queue_out = 75;
91
92  entry_t *      request [_param->_nb_packet];
93
94  for (uint32_t i=0; i<_param->_nb_packet; ++i)
95    request[i] = NULL;
96
97  srand(seed);
98
99  SC_CYCLE(0);
100  LABEL("Initialisation");
101
102  LABEL("Reset");
103  in_NRESET->write(0);
104  SC_CYCLE(5);
105  in_NRESET->write(1); 
106
107  LABEL("Loop of Test");
108
109  for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++)
110    {
111      LABEL("Iteration %d",iteration);
112
113      for (uint32_t i=0; i<_param->_nb_packet; i++)
114        {
115          if (request[i] != NULL)
116            delete request [i];
117
118          request [i] = new entry_t (range<Tcontext_t        >(rand(),_param->_size_context_id      ),
119                                     range<Tcontext_t        >(rand(),_param->_size_front_end_id    ),
120                                     range<Tcontext_t        >(rand(),_param->_size_ooo_engine_id   ),
121                                     i,
122                                   //range<Toperation_t      >(rand(),_param->_size_operation       ),
123                                   //range<Ttype_t           >(rand(),_param->_size_type            ),
124                                     range<Tspecial_data_t   >(rand(),_param->_size_special_data    ),
125                                     range<Texception_t      >(rand(),_param->_size_exception       ),
126                                     range<Tcontrol_t        >(rand(),1                             ),
127                                     range<Tgeneral_data_t   >(rand(),_param->_size_general_data    ),
128                                     range<Tgeneral_data_t   >(rand(),_param->_size_general_data    ));
129        }
130
131      uint32_t nb_request_in  = 0;
132      uint32_t nb_request_out = 0;
133     
134      while (nb_request_out < _param->_nb_packet)
135      {
136        bool val = (((rand()%100)<percent_transaction_execute_queue_in) and
137                    (nb_request_in < _param->_nb_packet));
138       
139        in_EXECUTE_QUEUE_IN_VAL          ->write(val);
140        if (val)
141          {
142            in_EXECUTE_QUEUE_IN_CONTEXT_ID   ->write(request [nb_request_in]->_context_id   );
143            in_EXECUTE_QUEUE_IN_FRONT_END_ID ->write(request [nb_request_in]->_front_end_id );
144            in_EXECUTE_QUEUE_IN_OOO_ENGINE_ID->write(request [nb_request_in]->_ooo_engine_id);
145            in_EXECUTE_QUEUE_IN_PACKET_ID    ->write(request [nb_request_in]->_packet_id    );
146          //in_EXECUTE_QUEUE_IN_OPERATION    ->write(request [nb_request_in]->_operation    );
147          //in_EXECUTE_QUEUE_IN_TYPE         ->write(request [nb_request_in]->_type         );
148            in_EXECUTE_QUEUE_IN_FLAGS        ->write(request [nb_request_in]->_flags        );
149            in_EXECUTE_QUEUE_IN_EXCEPTION    ->write(request [nb_request_in]->_exception    );
150            in_EXECUTE_QUEUE_IN_NO_SEQUENCE  ->write(request [nb_request_in]->_no_sequence  );
151            in_EXECUTE_QUEUE_IN_ADDRESS      ->write(request [nb_request_in]->_address      );
152            in_EXECUTE_QUEUE_IN_DATA         ->write(request [nb_request_in]->_data         );
153          }
154        in_EXECUTE_QUEUE_OUT_ACK         ->write((rand()%100)<percent_transaction_execute_queue_out);
155           
156        SC_CYCLE(0);
157
158       
159        // ======================================================================
160        // ======================================================================
161        // ======================================================================
162        if ( in_EXECUTE_QUEUE_IN_VAL->read() and
163            out_EXECUTE_QUEUE_IN_ACK->read())
164          {
165            LABEL(" * Accepted EXECUTE_QUEUE_IN  [%d]",nb_request_in);
166//          std::cout << *request [nb_request_in] << std::endl;
167
168            nb_request_in ++;
169          }
170       
171        // ======================================================================
172        // ======================================================================
173        // ======================================================================
174        if (out_EXECUTE_QUEUE_OUT_VAL->read() and
175             in_EXECUTE_QUEUE_OUT_ACK->read())
176          {
177            Tcontext_t packet;
178            if (_param->_have_port_rob_ptr)
179              packet = out_EXECUTE_QUEUE_OUT_PACKET_ID->read();
180            else
181              packet = 0;
182
183            LABEL(" * Accepted EXECUTE_QUEUE_OUT [%d]",packet);
184//          std::cout << *request [packet] << std::endl;
185
186            if (_param->_have_port_context_id)
187            TEST(Tcontext_t     , out_EXECUTE_QUEUE_OUT_CONTEXT_ID   ->read(), request [packet]->_context_id   );
188            if (_param->_have_port_front_end_id)
189            TEST(Tcontext_t     , out_EXECUTE_QUEUE_OUT_FRONT_END_ID ->read(), request [packet]->_front_end_id );
190            if (_param->_have_port_ooo_engine_id)
191            TEST(Tcontext_t     , out_EXECUTE_QUEUE_OUT_OOO_ENGINE_ID->read(), request [packet]->_ooo_engine_id);
192          //TEST(Toperation_t   , out_EXECUTE_QUEUE_OUT_OPERATION    ->read(), request [packet]->_operation    );
193          //TEST(Ttype_t        , out_EXECUTE_QUEUE_OUT_TYPE         ->read(), request [packet]->_type         );
194            TEST(Tcontrol_t     , out_EXECUTE_QUEUE_OUT_FLAGS        ->read(), request [packet]->_flags        );
195            TEST(Texception_t   , out_EXECUTE_QUEUE_OUT_EXCEPTION    ->read(), request [packet]->_exception    );
196            TEST(Tcontrol_t     , out_EXECUTE_QUEUE_OUT_NO_SEQUENCE  ->read(), request [packet]->_no_sequence  );
197            TEST(Tgeneral_data_t, out_EXECUTE_QUEUE_OUT_ADDRESS      ->read(), request [packet]->_address      );
198            TEST(Tgeneral_data_t, out_EXECUTE_QUEUE_OUT_DATA         ->read(), request [packet]->_data         );
199
200            nb_request_out ++;
201          }
202
203        SC_CYCLE(1);
204      }
205    }
206
207  for (uint32_t i=0; i<_param->_nb_packet; i++)
208    if (request[i] != NULL)
209      delete request [i];
210 
211      /********************************************************
212       * Simulation - End
213       ********************************************************/
214     
215      TEST_OK ("");
216     
217      sc_stop();
218      delete _time;
219     
220      msgInformation(_("<%s> : ............ Stop Simulation\n"),name.c_str());
221    }
222#endif
223}
Note: See TracBrowser for help on using the repository browser.