source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_OOO_Engine/OOO_Engine/Commit_unit/src/Commit_unit_genMealy_insert.cpp @ 88

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

Almost complete design
with Test and test platform

  • Property svn:keywords set to Id
File size: 4.5 KB
Line 
1#ifdef SYSTEMC
2/*
3 * $Id: Commit_unit_genMealy_insert.cpp 88 2008-12-10 18:31:39Z rosiere $
4 *
5 * [ Description ]
6 *
7 */
8
9#include "Behavioural/Core/Multi_OOO_Engine/OOO_Engine/Commit_unit/include/Commit_unit.h"
10
11namespace morpheo                    {
12namespace behavioural {
13namespace core {
14namespace multi_ooo_engine {
15namespace ooo_engine {
16namespace commit_unit {
17
18
19#undef  FUNCTION
20#define FUNCTION "Commit_unit::genMealy_insert"
21  void Commit_unit::genMealy_insert (void)
22  {
23    log_begin(Commit_unit,FUNCTION);
24    log_function(Commit_unit,FUNCTION,_name.c_str());
25
26    Tcontrol_t bank_full         [_param->_nb_bank];
27    Tcontrol_t insert_ack        [_param->_nb_rename_unit][_param->_max_nb_inst_insert];
28#ifdef SYSTEMC_VHDL_COMPATIBILITY
29    Tpacket_t  insert_packet_id  [_param->_nb_rename_unit][_param->_max_nb_inst_insert];
30#endif
31    bool       can_rename_select [_param->_nb_rename_unit];
32   
33    // Initialisation
34    for (uint32_t i=0; i<_param->_nb_bank; i++)
35      {
36        internal_BANK_INSERT_VAL  [i] = false;
37        bank_full [i] = not (_rob[i].size() < _param->_size_bank); 
38      }
39    for (uint32_t i=0; i<_param->_nb_rename_unit; i++)
40      {
41        can_rename_select [i] = true;
42        for (uint32_t j=0; j<_param->_nb_inst_insert[i]; j++)
43          {
44            insert_ack       [i][j] = false;
45#ifdef SYSTEMC_VHDL_COMPATIBILITY
46            insert_packet_id [i][j] = false;
47#endif
48          }
49      }
50
51    // insert interface
52//     log_printf(TRACE,Commit_unit,FUNCTION,"  * reg_NUM_BANK_TAIL : %d",reg_NUM_BANK_TAIL);
53
54    std::list<generic::priority::select_t> * select_insert = _priority_insert ->select(); // same select for all insert
55    std::list<generic::priority::select_t>::iterator it=select_insert ->begin();
56 
57    for (uint32_t i=0; i<_param->_nb_bank; i++)
58      {
59        // compute the bank number (num_bank_tail is the older write slot)
60        uint32_t num_bank = (reg_NUM_BANK_TAIL+i)%_param->_nb_bank;
61
62//      log_printf(TRACE,Commit_unit,FUNCTION,"  * BANK : %d", num_bank);
63//      log_printf(TRACE,Commit_unit,FUNCTION,"    * val  : %d", internal_BANK_INSERT_VAL [num_bank]);
64//      log_printf(TRACE,Commit_unit,FUNCTION,"    * full : %d", bank_full [num_bank]);
65
66        while (it!=select_insert ->end())
67          {
68            uint32_t num_rename_unit = it->grp;
69            uint32_t num_inst_insert = it->elt;
70
71            it++;
72
73            log_printf(TRACE,Commit_unit,FUNCTION,"  * INSERT [%d][%d]", num_rename_unit,num_inst_insert);
74//          log_printf(TRACE,Commit_unit,FUNCTION,"    * INSERT_VAL        : %d", PORT_READ(in_INSERT_VAL [num_rename_unit][num_inst_insert]));
75            log_printf(TRACE,Commit_unit,FUNCTION,"    * can_rename_select : %d", can_rename_select [num_rename_unit]);
76
77            // Test if have instruction
78            //   -> rename_unit_glue test the in-order insert !!!!!
79            if (can_rename_select [num_rename_unit] // and
80//              PORT_READ(in_INSERT_VAL [num_rename_unit][num_inst_insert])
81                )
82              {
83                log_printf(TRACE,Commit_unit,FUNCTION,"      * have instruction");
84                log_printf(TRACE,Commit_unit,FUNCTION,"      * bank_full : %d",bank_full [num_bank]);
85
86                // test if bank is not busy (full or previous access)
87                if (not bank_full [num_bank])
88                  {
89                    // find
90                    insert_ack       [num_rename_unit][num_inst_insert] = true;
91
92                    Tpacket_t packet_id = ((num_bank << _param->_shift_num_bank) | reg_BANK_PTR [num_bank]);
93
94#ifdef SYSTEMC_VHDL_COMPATIBILITY
95                    insert_packet_id [num_rename_unit][num_inst_insert] = packet_id;
96#else
97                    if (_param->_have_port_rob_ptr  )
98                    PORT_WRITE(out_INSERT_PACKET_ID [num_rename_unit][num_inst_insert],packet_id);
99#endif
100                    internal_BANK_INSERT_VAL             [num_bank] = true;
101                    internal_BANK_INSERT_NUM_RENAME_UNIT [num_bank] = num_rename_unit;
102                    internal_BANK_INSERT_NUM_INST        [num_bank] = num_inst_insert;
103                   
104                    break;
105                  }
106              }
107               
108            // is a valid instruction, but it's not send at a bank
109            //  ... invalid this rename_unit (because, insert in_order)
110            can_rename_select [num_rename_unit] = false;
111          }
112      }
113   
114    for (uint32_t i=0; i<_param->_nb_rename_unit; i++)
115      for (uint32_t j=0; j<_param->_nb_inst_insert[i]; j++)
116        {
117          PORT_WRITE(out_INSERT_ACK       [i][j],insert_ack       [i][j]);
118          log_printf(TRACE,Commit_unit,FUNCTION,"  * INSERT [%d][%d] -> ack %d",i,j,insert_ack[i][j]);
119
120#ifdef SYSTEMC_VHDL_COMPATIBILITY
121          if (_param->_have_port_rob_ptr  )
122          PORT_WRITE(out_INSERT_PACKET_ID [i][j],insert_packet_id [i][j]);
123#endif
124        }
125   
126    log_end(Commit_unit,FUNCTION);
127  };
128
129}; // end namespace commit_unit
130}; // end namespace ooo_engine
131}; // end namespace multi_ooo_engine
132}; // end namespace core
133}; // end namespace behavioural
134}; // end namespace morpheo             
135#endif
Note: See TracBrowser for help on using the repository browser.