Ignore:
Timestamp:
Dec 4, 2007, 2:31:54 PM (17 years ago)
Author:
rosiere
Message:

Modification en profondeur de Component-port_map.
Compilation ok pour Register_unit ... a tester (systemC et vhdl)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Execute_loop/Execute_loop/Multi_Execute_unit/Execute_unit/Load_store_unit/SelfTest/src/test.cpp

    r59 r62  
    1010#include "Behavioural/Core/Multi_Execute_loop/Execute_loop/Multi_Execute_unit/Execute_unit/Load_store_unit/SelfTest/include/test.h"
    1111#include "Common/include/Test.h"
     12#include "Common/include/BitManipulation.h"
    1213
    1314#define NB_ITERATION  1
     
    4344
    4445
     46//========================================================={MemoryRequest_t}
    4547class MemoryRequest_t
    4648{
     
    146148  return os << "<" << toString(x._cycle) << "> : "
    147149            << "{" << toString(static_cast<uint32_t>(x._packet_id)) << "}" << endl
    148             << "\t * " << toString(static_cast<uint32_t>(x._context_id)) << endl
    149             << "\t * " << toString(static_cast<uint32_t>(x._operation)) << " " << toString(static_cast<uint32_t>(x._type)) << " " << toString(static_cast<uint32_t>(x._write_spec_ko)) << endl
    150             << "\t * " << toString(static_cast<uint32_t>(x._store_queue_ptr_write)) << " " << toString(static_cast<uint32_t>(x._load_queue_ptr_write)) << endl
    151             << "\t * " << toString(static_cast<uint32_t>(x._immediat)) << " - " << toString(static_cast<uint32_t>(x._data_ra)) << " - " << toString(static_cast<uint32_t>(x._data_rb)) << endl
    152             << "\t * " << toString(static_cast<uint32_t>(x._write_rd)) << " " << toString(static_cast<uint32_t>(x._num_reg_rd)) << endl;
     150            << "\t * context_id                        : " << toString(static_cast<uint32_t>(x._context_id)) << endl
     151            << "\t * operation  / type / write_spec_ko : " << toString(static_cast<uint32_t>(x._operation)) << " " << toString(static_cast<uint32_t>(x._type)) << " " << toString(static_cast<uint32_t>(x._write_spec_ko)) << endl
     152            << "\t * ptr_write store/load              : " << toString(static_cast<uint32_t>(x._store_queue_ptr_write)) << " " << toString(static_cast<uint32_t>(x._load_queue_ptr_write)) << endl
     153            << "\t * immediat / data_ra / data_rb      : " << toString(static_cast<uint32_t>(x._immediat)) << " - " << toString(static_cast<uint32_t>(x._data_ra)) << " - " << toString(static_cast<uint32_t>(x._data_rb)) << endl
     154            << "\t * write_rd / num_reg_rd             : " << toString(static_cast<uint32_t>(x._write_rd)) << " " << toString(static_cast<uint32_t>(x._num_reg_rd)) << endl;
    153155}
    154156
     157//================================================================{Memory_t}
     158class Memory_t
     159{
     160private : const uint32_t    _nb_context;
     161private : const uint32_t    _nb_word   ;
     162private : const uint32_t    _size_data ;
     163private : const Tdcache_address_t _mask_addr ;
     164private : Tdcache_data_t ** _data;
     165 
     166public  : Memory_t (uint32_t nb_context,
     167                    uint32_t nb_word,
     168                    uint32_t size_data):
     169  _nb_context   (nb_context),
     170  _nb_word      (nb_word   ),
     171  _size_data    (size_data ),
     172  _mask_addr    (gen_mask<Tdcache_address_t>(static_cast<uint32_t>(log2(ceil(static_cast<double>(size_data))))))
     173  {
     174    _data = new Tdcache_data_t * [nb_context];
     175   
     176    for (uint32_t i=0; i<nb_context; i++)
     177      {
     178        _data [i] = new Tdcache_data_t [nb_word];
     179       
     180        for (uint32_t j=0; j<nb_word; j++)
     181          _data [i][j] = rand()%(size_data);
     182      }
     183  }
     184
     185public  : ~Memory_t (void)
     186  {
     187    delete [] _data;
     188  }
     189
     190public  : Tdcache_data_t access (uint32_t          context,
     191                                 Tdcache_address_t address,
     192                                 Tdcache_type_t    type,
     193                                 Tdcache_data_t    data)
     194  {
     195    return 0;
     196  }
     197
     198public  : Tdcache_data_t read (uint32_t          context,
     199                               Tdcache_address_t address,
     200                               Tdcache_type_t    type)
     201  {
     202    // Address's Read must be aligned
     203
     204    if ((address & _mask_addr) != 0)
     205      TEST_KO("<Memory_t::read> Address is not aligned");
     206
     207    if (context>_nb_context)
     208      TEST_KO("<Memory_t::read> nb context is too high");
     209
     210    if (address>_nb_word)
     211      TEST_KO("<Memory_t::read> address is too high");
     212   
     213    return _data [context][address];
     214  }
     215
     216public  : void write (uint32_t          context,
     217                      Tdcache_address_t address,
     218                      Tdcache_type_t    type,
     219                      Tdcache_data_t    data)
     220  {
     221    if (context>_nb_context)
     222      TEST_KO("<Memory_t::read> nb context is too high");
     223
     224    if (address>_nb_word)
     225      TEST_KO("<Memory_t::read> address is too high");
     226
     227    Tdcache_address_t LSB = address &  _mask;
     228    Tdcache_address_t MSB = address & ~_mask;
     229 
     230    Tdcache_data_t write_data = data;
     231    Tdcache_data_t read_data  = _data [context][MSB];
     232
     233    // exemple to size_data = 32b
     234    // LSB index_min
     235    // 0   0
     236    // 1   8
     237    // 2   16
     238    // 3   24
     239    uint32_t index_min = LSB<<3;
     240    uint32_t index_max = index_min;
     241    // index max, dependant of access's size
     242
     243    switch (type)
     244      {
     245
     246
     247      }
     248  }
     249};
     250
     251//===================================================================={test}
    155252void test (string name,
    156253           morpheo::behavioural::core::multi_execute_loop::execute_loop::multi_execute_unit::execute_unit::load_store_unit::Parameters * _param)
     
    252349  (*(_Load_store_unit-> in_MEMORY_IN_PACKET_ID            ))(*( in_MEMORY_IN_PACKET_ID            ));
    253350  (*(_Load_store_unit-> in_MEMORY_IN_OPERATION            ))(*( in_MEMORY_IN_OPERATION            ));
    254   (*(_Load_store_unit-> in_MEMORY_IN_TYPE                 ))(*( in_MEMORY_IN_TYPE                 ));
    255351  (*(_Load_store_unit-> in_MEMORY_IN_STORE_QUEUE_PTR_WRITE))(*( in_MEMORY_IN_STORE_QUEUE_PTR_WRITE));
    256352  (*(_Load_store_unit-> in_MEMORY_IN_LOAD_QUEUE_PTR_WRITE ))(*( in_MEMORY_IN_LOAD_QUEUE_PTR_WRITE ));
     
    269365  (*(_Load_store_unit->out_MEMORY_OUT_CONTEXT_ID ))(*(out_MEMORY_OUT_CONTEXT_ID ));
    270366  (*(_Load_store_unit->out_MEMORY_OUT_PACKET_ID  ))(*(out_MEMORY_OUT_PACKET_ID  ));
    271   (*(_Load_store_unit->out_MEMORY_OUT_OPERATION  ))(*(out_MEMORY_OUT_OPERATION  ));
    272   (*(_Load_store_unit->out_MEMORY_OUT_TYPE       ))(*(out_MEMORY_OUT_TYPE       ));
    273367  (*(_Load_store_unit->out_MEMORY_OUT_WRITE_RD   ))(*(out_MEMORY_OUT_WRITE_RD   ));
    274368  (*(_Load_store_unit->out_MEMORY_OUT_NUM_REG_RD ))(*(out_MEMORY_OUT_NUM_REG_RD ));
     
    322416  const uint32_t     nb_word      = nb_request;
    323417
    324   const uint32_t     cst_max_cycle                  =   2;
    325 
    326   const int32_t      percent_transaction_memory_in  = 100;
     418//const int32_t      percent_transaction_memory_in  = 100;
    327419  const int32_t      percent_transaction_memory_out = 100;
    328420  const int32_t      percent_transaction_dcache     = 100;
     
    331423  const int32_t      percent_type_load              =   0;
    332424  const int32_t      percent_type_store             = 100;
    333   const int32_t      percent_miss_spec              = 100;
     425  const int32_t      percent_miss_spec              =   0;
    334426
    335427  if ((percent_type_load  +
     
    337429    TEST_KO("sum of percent_type > 100");
    338430
    339   const int32_t      seuil_type_load    = seuil_type_load;
    340   const int32_t      seuil_type_store   = seuil_type_store+percent_type_load;
     431  const int32_t      seuil_type_load    = percent_type_load;
     432  const int32_t      seuil_type_store   = percent_type_store+percent_type_load;
    341433
    342434  uint32_t           nb_request_memory_in ;
     
    347439  priority_queue<MemoryRequest_t> fifo_request;
    348440
     441  // emulation of cache
    349442  Tdcache_data_t     cache_data                [_param->_nb_context][nb_word];
    350443
     
    371464  for (uint32_t iteration=0; iteration<NB_ITERATION; iteration ++)
    372465    {
     466      LABEL("Iteration "+toString(iteration));
     467
     468      LABEL("Structure's initialisation");
     469
    373470      nb_request_memory_in  = 0;
    374471      nb_request_memory_out = 0;
    375472      nb_request_dcache     = 0;
    376473     
    377       LABEL("Iteration "+toString(iteration));
    378 
    379474      // Fill the request_queue
    380475     
     
    390485        load_queue_use  [i] = false;
    391486
    392       double             store_queue_cycle [_param->_size_store_queue];
    393       double             load_queue_cycle  [_param->_size_load_queue ];
    394487      double             current_cycle = sc_simulation_time();
    395 
    396       for (uint32_t i=0; i<_param->_size_store_queue; i++)
    397         store_queue_cycle [i] = current_cycle;
    398       for (uint32_t i=0; i<_param->_size_load_queue ; i++)
    399         load_queue_cycle  [i] = current_cycle;
    400 
     488      double             cycle_min     = current_cycle;
     489
     490      LABEL("Fifo request initialisation");
    401491      // Init fifo_request
    402492      for (uint32_t i=0; i<nb_request; i++)
    403493        {
    404           double             cycle                     = current_cycle+(rand()%(cst_max_cycle*nb_request));
     494          double             cycle;
    405495          Tcontext_t         context_id                = rand () % _param->_nb_context;
    406496          Tpacket_t          packet_id                 = i;
     
    411501          int32_t            percent = rand()%100;
    412502
    413           if (percent < seuil_type_load)
     503          uint32_t           size_queue;
     504         
     505          if (percent <= seuil_type_load)
    414506            {
    415               operation = OPERATION_MEMORY_LOAD_16_S;
    416               load_queue_ptr_write = (load_queue_ptr_write+1) % (_param->_size_load_queue);
    417             }
    418           else
    419             if (percent < seuil_type_store)
    420               {
    421                 operation = OPERATION_MEMORY_STORE_16;
    422                 store_queue_ptr_write = (store_queue_ptr_write+1) % (_param->_size_store_queue);
    423               }
    424             else
    425               {
    426                 operation = OPERATION_MEMORY_PREFETCH;
    427                 load_queue_ptr_write = (load_queue_ptr_write+1) % (_param->_size_load_queue);
    428               }
    429 
    430           // Valid nb cycle ?
    431           if (is_operation_memory_store(operation))
    432             {
    433               if (cycle <= store_queue_cycle[packet_id])
    434                 cycle = store_queue_cycle[packet_id]+1;
     507//            LABEL(" * LOAD");
     508              operation            = OPERATION_MEMORY_LOAD_16_S;
     509              size_queue           = _param->_size_load_queue;
     510              load_queue_ptr_write = (load_queue_ptr_write+1) % (size_queue);
    435511            }
    436512          else
    437513            {
    438               if (cycle <= load_queue_cycle[packet_id])
    439                 cycle = load_queue_cycle[packet_id]+1;
     514              if (percent <= seuil_type_store)
     515                {
     516//                LABEL(" * STORE");
     517                  operation             = OPERATION_MEMORY_STORE_16;
     518                  size_queue            = _param->_size_store_queue;
     519                  store_queue_ptr_write = (store_queue_ptr_write+1) % (size_queue);
     520                }
     521              else
     522                {
     523//                LABEL(" * OTHERS");
     524                  operation            = OPERATION_MEMORY_PREFETCH;
     525                  size_queue           = _param->_size_load_queue;
     526                  load_queue_ptr_write = (load_queue_ptr_write+1) % (size_queue);
     527                }
    440528            }
    441529
     530          cycle      = cycle_min;
     531          cycle_min ++;
     532
    442533          Ttype_t            type                  = TYPE_MEMORY;
    443 
    444           Tgeneral_data_t    address               = rand()%(1<<_param->_size_general_data);
    445           Tgeneral_data_t    offset                = rand()%(1<<_param->_size_general_data);
     534          Tgeneral_data_t    address               = rand()%(nb_word);
     535          Tgeneral_data_t    offset                = rand()%(nb_word);
    446536
    447537          percent = rand()%100;
     
    474564                                );
    475565
     566          cout << tab_request [i] << endl;
     567       
    476568          fifo_request.push(tab_request [i]);
    477          
     569
     570          double cycle_head = 0;
     571
    478572          if (is_operation_memory_store(operation))
    479573            {
    480               cycle = cycle+((rand()%(10))-4);
    481 
    482               if (cycle <= store_queue_cycle[packet_id])
    483                 cycle = store_queue_cycle[packet_id]+1;
    484                        
    485               fifo_request.push(MemoryRequest_t(cycle,
     574              cycle_head = cycle_min;
     575              cycle_min ++;
     576
     577              cout << "         * Write head : " << toString(cycle_head)
     578                   << endl
     579                   << endl;
     580             
     581              fifo_request.push(MemoryRequest_t(cycle_head,
    486582                                                context_id,
    487583                                                packet_id,
     
    497593                                                write_spec_ko));
    498594            }
    499 
    500           // update nb cycle ?
    501           if (is_operation_memory_store(operation))
    502             {
    503               store_queue_cycle[packet_id] = cycle;
    504             }
    505           else
    506             {
    507               load_queue_cycle [packet_id] = cycle;
    508             }
    509         }
    510            
     595        }
     596       
     597      LABEL("Simulation of this iteration ...");
     598   
    511599      while (nb_request_memory_out < nb_request)
    512600        {
     601          // ***** MEMORY_IN *****
     602
     603          // memory_in_val depends of three factors :
     604          //  1) request's fifo is not empty ?
     605          //  2) the slot destination is free ?
     606          //  3) The head of request's fifo can be issue : the number of cycle is more than current cycle
     607
    513608          bool can_execute = false;
    514609
     
    535630
    536631          in_MEMORY_OUT_ACK->write((rand()%100)<percent_transaction_memory_out);
    537          
     632
     633          // ***** DCACHE_REQ *****
     634          in_DCACHE_REQ_ACK->write((rand()%100)<percent_transaction_dcache);
     635
    538636          SC_START(0);
    539637 
     
    541639
    542640          LABEL("MEMORY_IN  : "+toString(in_MEMORY_IN_VAL ->read())+" - "+toString(out_MEMORY_IN_ACK ->read()));
     641          LABEL("  * fifo_request.empty                     : "+toString(fifo_request.empty()));
     642          LABEL("  * fifo_request.top.cycle                 : "+toString(fifo_request.top()._cycle));
     643          LABEL("  * fifo_request.top.store_queue_ptr_write : "+toString(static_cast<uint32_t>(fifo_request.top()._store_queue_ptr_write)));
     644          LABEL("  * fifo_request.top.load_queue_ptr_write  : "+toString(static_cast<uint32_t>(fifo_request.top()._load_queue_ptr_write)));
     645          LABEL("  * fifo_request.top.operation             : "+toString(static_cast<uint32_t>(fifo_request.top()._operation           )));
     646          LABEL("  * can_execute                            : "+toString(can_execute));
     647
    543648          if ( in_MEMORY_IN_VAL ->read() and out_MEMORY_IN_ACK ->read())
    544649            {
     
    562667          if (out_MEMORY_OUT_VAL->read() and  in_MEMORY_OUT_ACK->read())
    563668            {
    564               LABEL(" * Accepted MEMORY_OUT : " + toString(out_MEMORY_OUT_PACKET_ID->read()));
     669              LABEL(" * Accepted MEMORY_OUT : " + toString(static_cast<uint32_t>(out_MEMORY_OUT_PACKET_ID->read())));
    565670
    566671              if (is_operation_memory_store(tab_request[out_MEMORY_OUT_PACKET_ID->read()]._operation))
     
    571676              nb_request_memory_out ++;
    572677            }
     678
     679          LABEL("DCACHE_REQ : "+toString(out_DCACHE_REQ_VAL->read())+" - "+toString(in_DCACHE_REQ_ACK ->read()));
     680          if (out_DCACHE_REQ_VAL->read() and  in_DCACHE_REQ_ACK->read())
     681            {
     682              LABEL(" * Accepted DCACHE_REQ : " + toString(static_cast<uint32_t>(out_DCACHE_REQ_PACKET_ID->read())));
     683
     684              // test type : send or not a respons !
     685            }
     686
    573687        }
    574688    }
Note: See TracChangeset for help on using the changeset viewer.