source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Core/Multi_Execute_loop/Execute_loop/Multi_Execute_unit/Execute_unit/Functionnal_unit/src/Functionnal_unit_allocation.cpp @ 118

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

1) Stat List : scan all queue to find free register
2) Write_queue : test "genMealy" add bypass [0]
3) Functionnal_unit : add const parameters to add or not the pipeline_in
4) Load Store Unit : if load make an exception, free nb_check
5) Debug, change test to add model

  • Property svn:keywords set to Id
File size: 14.9 KB
Line 
1/*
2 * $Id: Functionnal_unit_allocation.cpp 118 2009-05-20 22:01:32Z rosiere $
3 *
4 * [ Description ]
5 *
6 */
7
8#include "Behavioural/Core/Multi_Execute_loop/Execute_loop/Multi_Execute_unit/Execute_unit/Functionnal_unit/include/Functionnal_unit.h"
9#include "Behavioural/include/Allocation.h"
10
11namespace morpheo                    {
12namespace behavioural {
13namespace core {
14namespace multi_execute_loop {
15namespace execute_loop {
16namespace multi_execute_unit {
17namespace execute_unit {
18namespace functionnal_unit {
19
20#undef  FUNCTION
21#define FUNCTION "Functionnal_unit::allocation"
22  void Functionnal_unit::allocation (void)
23  {
24    log_printf(FUNC,Functionnal_unit,FUNCTION,"Begin");
25
26    _component   = new Component (_usage);
27
28    Entity * entity = _component->set_entity (_name       
29                                              ,"Functionnal_unit"
30#ifdef POSITION
31                                              ,COMBINATORY
32#endif
33                                              );
34
35    _interfaces = entity->set_interfaces();
36
37    // ~~~~~[ Interface : "" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
38
39    {
40      Interface * interface = _interfaces->set_interface(""
41#ifdef POSITION
42                                                         ,IN
43                                                         ,SOUTH,
44                                                         "Generalist interface"
45#endif
46                                                         );
47
48      in_CLOCK        = interface->set_signal_clk              ("clock" ,1, CLOCK_VHDL_YES);
49      in_NRESET       = interface->set_signal_in  <Tcontrol_t> ("nreset",1, RESET_VHDL_YES);
50    }
51    // ~~~~~[ Interface : "execute_in" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
52
53    {
54      ALLOC0_INTERFACE_BEGIN("execute_in",IN,WEST,"Input of Functionnal Unit");
55
56      ALLOC0_VALACK_IN ( in_EXECUTE_IN_VAL                   ,VAL);
57      ALLOC0_VALACK_OUT(out_EXECUTE_IN_ACK                   ,ACK);
58      ALLOC0_SIGNAL_IN ( in_EXECUTE_IN_CONTEXT_ID            ,"context_id"           ,Tcontext_t        , _param->_size_context_id   );
59      ALLOC0_SIGNAL_IN ( in_EXECUTE_IN_FRONT_END_ID          ,"front_end_id"         ,Tcontext_t        , _param->_size_front_end_id );
60      ALLOC0_SIGNAL_IN ( in_EXECUTE_IN_OOO_ENGINE_ID         ,"ooo_engine_id"        ,Tcontext_t        , _param->_size_ooo_engine_id);
61      ALLOC0_SIGNAL_IN ( in_EXECUTE_IN_PACKET_ID             ,"packet_id"            ,Tpacket_t         , _param->_size_rob_ptr    );
62      ALLOC0_SIGNAL_IN ( in_EXECUTE_IN_OPERATION             ,"operation"            ,Toperation_t      , _param->_size_operation    );
63      ALLOC0_SIGNAL_IN ( in_EXECUTE_IN_TYPE                  ,"type"                 ,Ttype_t           , _param->_size_type         );
64      ALLOC0_SIGNAL_IN ( in_EXECUTE_IN_STORE_QUEUE_PTR_WRITE ,"store_queue_ptr_write",Tlsq_ptr_t        ,_param->_size_store_queue_ptr);
65      ALLOC0_SIGNAL_IN ( in_EXECUTE_IN_LOAD_QUEUE_PTR_WRITE  ,"load_queue_ptr_write" ,Tlsq_ptr_t        ,_param->_size_load_queue_ptr);
66      ALLOC0_SIGNAL_IN ( in_EXECUTE_IN_HAS_IMMEDIAT          ,"has_immediat"         ,Tcontrol_t        , 1);
67      ALLOC0_SIGNAL_IN ( in_EXECUTE_IN_IMMEDIAT              ,"immediat"             ,Tgeneral_data_t   , _param->_size_general_data);
68      ALLOC0_SIGNAL_IN ( in_EXECUTE_IN_DATA_RA               ,"data_ra"              ,Tgeneral_data_t   , _param->_size_general_data);
69      ALLOC0_SIGNAL_IN ( in_EXECUTE_IN_DATA_RB               ,"data_rb"              ,Tgeneral_data_t   , _param->_size_general_data);
70      ALLOC0_SIGNAL_IN ( in_EXECUTE_IN_DATA_RC               ,"data_rc"              ,Tspecial_data_t   , _param->_size_special_data);
71      ALLOC0_SIGNAL_IN ( in_EXECUTE_IN_WRITE_RD              ,"write_rd"             ,Tcontrol_t        , 1);
72      ALLOC0_SIGNAL_IN ( in_EXECUTE_IN_NUM_REG_RD            ,"num_reg_rd"           ,Tgeneral_address_t, _param->_size_general_register);
73      ALLOC0_SIGNAL_IN ( in_EXECUTE_IN_WRITE_RE              ,"write_re"             ,Tcontrol_t        , 1);
74      ALLOC0_SIGNAL_IN ( in_EXECUTE_IN_NUM_REG_RE            ,"num_reg_re"           ,Tspecial_address_t, _param->_size_special_register);
75
76      ALLOC0_INTERFACE_END();
77     }
78    // ~~~~~[ Interface : "execute_out" ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~     
79     {
80       ALLOC0_INTERFACE_BEGIN("execute_out",IN,EAST,"Output of Functionnal Unit");
81
82       ALLOC0_VALACK_OUT(out_EXECUTE_OUT_VAL            ,VAL);
83       ALLOC0_VALACK_IN ( in_EXECUTE_OUT_ACK            ,ACK);
84       ALLOC0_SIGNAL_OUT(out_EXECUTE_OUT_CONTEXT_ID     ,"context_id"   ,Tcontext_t        ,_param->_size_context_id   );
85       ALLOC0_SIGNAL_OUT(out_EXECUTE_OUT_FRONT_END_ID   ,"front_end_id" ,Tcontext_t        ,_param->_size_front_end_id );
86       ALLOC0_SIGNAL_OUT(out_EXECUTE_OUT_OOO_ENGINE_ID  ,"ooo_engine_id",Tcontext_t        ,_param->_size_ooo_engine_id);
87       ALLOC0_SIGNAL_OUT(out_EXECUTE_OUT_PACKET_ID      ,"packet_id"    ,Tpacket_t         ,_param->_size_rob_ptr    );
88     //ALLOC0_SIGNAL_OUT(out_EXECUTE_OUT_OPERATION      ,"operation"    ,Toperation_t      ,_param->_size_operation    );
89     //ALLOC0_SIGNAL_OUT(out_EXECUTE_OUT_TYPE           ,"type"         ,Ttype_t           ,_param->_size_type         );
90       ALLOC0_SIGNAL_OUT(out_EXECUTE_OUT_WRITE_RD       ,"write_rd"     ,Tcontrol_t        ,1);
91       ALLOC0_SIGNAL_OUT(out_EXECUTE_OUT_NUM_REG_RD     ,"num_reg_rd"   ,Tgeneral_address_t,_param->_size_general_register);
92       ALLOC0_SIGNAL_OUT(out_EXECUTE_OUT_DATA_RD        ,"data_rd"      ,Tgeneral_data_t   ,_param->_size_general_data);
93       ALLOC0_SIGNAL_OUT(out_EXECUTE_OUT_WRITE_RE       ,"write_re"     ,Tcontrol_t        ,1);
94       ALLOC0_SIGNAL_OUT(out_EXECUTE_OUT_NUM_REG_RE     ,"num_reg_re"   ,Tspecial_address_t,_param->_size_special_register);
95       ALLOC0_SIGNAL_OUT(out_EXECUTE_OUT_DATA_RE        ,"data_re"      ,Tspecial_data_t   ,_param->_size_special_data);
96       ALLOC0_SIGNAL_OUT(out_EXECUTE_OUT_EXCEPTION      ,"exception"    ,Texception_t      ,_param->_size_exception);
97       ALLOC0_SIGNAL_OUT(out_EXECUTE_OUT_NO_SEQUENCE    ,"no_sequence"  ,Tcontrol_t        ,1);
98       ALLOC0_SIGNAL_OUT(out_EXECUTE_OUT_ADDRESS        ,"address"      ,Taddress_t        ,_param->_size_instruction_address);
99
100       ALLOC0_INTERFACE_END();
101     }
102
103     // ~~~~~[ Component ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
104     if (usage_is_set(_usage,USE_SYSTEMC))
105       {
106     if (_param->_have_pipeline_in)
107     _execute_operation_in  = new execute_operation_t;
108     _execute_operation_out = new execute_operation_t;
109     _execute_param         = new execute_param_t(_param->_size_general_data,
110                                                  _param->_timing);
111
112     _execute_register = new execute_register_t *** [_param->_nb_context];
113
114     for (uint32_t i=0; i<_param->_nb_context; i++)
115       {
116         _execute_register [i] = new execute_register_t ** [_param->_nb_front_end];
117         
118         for (uint32_t j=0; j<_param->_nb_front_end; j++)
119           {
120             _execute_register [i][j] = new execute_register_t * [_param->_nb_ooo_engine];
121             
122             for (uint32_t k=0; k<_param->_nb_ooo_engine; k++)
123               {
124//               uint32_t num_thread = get_num_thread(i,_param->_size_context_id,
125//                                                    j,_param->_size_front_end_id,
126//                                                    k,_param->_size_ooo_engine_id);
127
128                 _execute_register [i][j][k] = new execute_register_t;
129                 
130                 if (_param->_have_groupe_MAC)
131                   _execute_register[i][j][k]->implement_group(GROUP_MAC);
132
133                 for (uint32_t x=GROUP_CUSTOM_1; x<GROUP_CUSTOM_8; x++)
134                   if ((_param->_get_custom_information())._get_valid_group(x) == true)
135                     {
136                       uint32_t nb_reg = (_param->_get_custom_information())._get_nb_register(x);
137                       _execute_register[i][j][k]->implement_group(x,nb_reg);
138
139                       for (uint32_t y=0; y<nb_reg; y++)
140                         _execute_register[i][j][k]->_spr_access_mode->change_mode(x,y,(_param->_get_custom_information())._get_access_mode(x,y));
141                     }
142               }
143           }
144       }
145
146     _function_execute = new function_execute_t ** [_param->_nb_type];
147     
148     // Initialisation
149     for (uint32_t i=0; i<_param->_nb_type; i++)
150       {
151         _function_execute [i] = new function_execute_t * [_param->_nb_operation];
152         
153         for (uint32_t j=0; j<_param->_nb_operation; j++)
154           _function_execute [i][j] = &(operation_unimplemented);
155       }
156
157     if (_param->_timing[TYPE_ALU    ][OPERATION_ALU_L_ADD         ]._latence > 0)
158       _function_execute[TYPE_ALU    ][OPERATION_ALU_L_ADD         ] = &(operation_l_add     );
159     if (_param->_timing[TYPE_ALU    ][OPERATION_ALU_L_ADDC        ]._latence > 0) 
160       _function_execute[TYPE_ALU    ][OPERATION_ALU_L_ADDC        ] = &(operation_l_addc    );
161     if (_param->_timing[TYPE_ALU    ][OPERATION_ALU_L_SUB         ]._latence > 0) 
162       _function_execute[TYPE_ALU    ][OPERATION_ALU_L_SUB         ] = &(operation_l_sub     );
163     if (_param->_timing[TYPE_ALU    ][OPERATION_ALU_L_AND         ]._latence > 0) 
164       _function_execute[TYPE_ALU    ][OPERATION_ALU_L_AND         ] = &(operation_l_and     );
165     if (_param->_timing[TYPE_ALU    ][OPERATION_ALU_L_OR          ]._latence > 0) 
166       _function_execute[TYPE_ALU    ][OPERATION_ALU_L_OR          ] = &(operation_l_or      );
167     if (_param->_timing[TYPE_ALU    ][OPERATION_ALU_L_XOR         ]._latence > 0) 
168       _function_execute[TYPE_ALU    ][OPERATION_ALU_L_XOR         ] = &(operation_l_xor     );
169     if (_param->_timing[TYPE_SHIFT  ][OPERATION_SHIFT_L_SLL       ]._latence > 0) 
170       _function_execute[TYPE_SHIFT  ][OPERATION_SHIFT_L_SLL       ] = &(operation_l_sll     );
171     if (_param->_timing[TYPE_SHIFT  ][OPERATION_SHIFT_L_SRA       ]._latence > 0) 
172       _function_execute[TYPE_SHIFT  ][OPERATION_SHIFT_L_SRA       ] = &(operation_l_sra     );
173     if (_param->_timing[TYPE_SHIFT  ][OPERATION_SHIFT_L_SRL       ]._latence > 0) 
174       _function_execute[TYPE_SHIFT  ][OPERATION_SHIFT_L_SRL       ] = &(operation_l_srl     );
175     if (_param->_timing[TYPE_SHIFT  ][OPERATION_SHIFT_L_ROR       ]._latence > 0) 
176       _function_execute[TYPE_SHIFT  ][OPERATION_SHIFT_L_ROR       ] = &(operation_l_ror     );
177     if (_param->_timing[TYPE_MOVE   ][OPERATION_MOVE_L_MOVHI      ]._latence > 0) 
178       _function_execute[TYPE_MOVE   ][OPERATION_MOVE_L_MOVHI      ] = &(operation_l_movhi   );
179     if (_param->_timing[TYPE_MOVE   ][OPERATION_MOVE_L_CMOV       ]._latence > 0) 
180       _function_execute[TYPE_MOVE   ][OPERATION_MOVE_L_CMOV       ] = &(operation_l_cmov    ); 
181     if (_param->_timing[TYPE_TEST   ][OPERATION_TEST_L_SFGEU      ]._latence > 0) 
182       _function_execute[TYPE_TEST   ][OPERATION_TEST_L_SFGEU      ] = &(operation_l_sfgeu   );
183     if (_param->_timing[TYPE_TEST   ][OPERATION_TEST_L_SFGTU      ]._latence > 0) 
184       _function_execute[TYPE_TEST   ][OPERATION_TEST_L_SFGTU      ] = &(operation_l_sfgtu   );
185     if (_param->_timing[TYPE_TEST   ][OPERATION_TEST_L_SFLEU      ]._latence > 0) 
186       _function_execute[TYPE_TEST   ][OPERATION_TEST_L_SFLEU      ] = &(operation_l_sfleu   );
187     if (_param->_timing[TYPE_TEST   ][OPERATION_TEST_L_SFLTU      ]._latence > 0) 
188       _function_execute[TYPE_TEST   ][OPERATION_TEST_L_SFLTU      ] = &(operation_l_sfltu   );
189     if (_param->_timing[TYPE_TEST   ][OPERATION_TEST_L_SFGES      ]._latence > 0) 
190       _function_execute[TYPE_TEST   ][OPERATION_TEST_L_SFGES      ] = &(operation_l_sfges   );
191     if (_param->_timing[TYPE_TEST   ][OPERATION_TEST_L_SFGTS      ]._latence > 0) 
192       _function_execute[TYPE_TEST   ][OPERATION_TEST_L_SFGTS      ] = &(operation_l_sfgts   );
193     if (_param->_timing[TYPE_TEST   ][OPERATION_TEST_L_SFLES      ]._latence > 0) 
194       _function_execute[TYPE_TEST   ][OPERATION_TEST_L_SFLES      ] = &(operation_l_sfles   );
195     if (_param->_timing[TYPE_TEST   ][OPERATION_TEST_L_SFLTS      ]._latence > 0) 
196       _function_execute[TYPE_TEST   ][OPERATION_TEST_L_SFLTS      ] = &(operation_l_sflts   );
197     if (_param->_timing[TYPE_TEST   ][OPERATION_TEST_L_SFEQ       ]._latence > 0) 
198       _function_execute[TYPE_TEST   ][OPERATION_TEST_L_SFEQ       ] = &(operation_l_sfeq    );
199     if (_param->_timing[TYPE_TEST   ][OPERATION_TEST_L_SFNE       ]._latence > 0) 
200       _function_execute[TYPE_TEST   ][OPERATION_TEST_L_SFNE       ] = &(operation_l_sfne    );
201     if (_param->_timing[TYPE_MUL    ][OPERATION_MUL_L_MUL         ]._latence > 0) 
202       _function_execute[TYPE_MUL    ][OPERATION_MUL_L_MUL         ] = &(operation_l_mul     );
203     if (_param->_timing[TYPE_MUL    ][OPERATION_MUL_L_MULU        ]._latence > 0) 
204       _function_execute[TYPE_MUL    ][OPERATION_MUL_L_MULU        ] = &(operation_l_mulu    );
205     if (_param->_timing[TYPE_DIV    ][OPERATION_DIV_L_DIV         ]._latence > 0) 
206       _function_execute[TYPE_DIV    ][OPERATION_DIV_L_DIV         ] = &(operation_l_div     );
207     if (_param->_timing[TYPE_DIV    ][OPERATION_DIV_L_DIVU        ]._latence > 0) 
208       _function_execute[TYPE_DIV    ][OPERATION_DIV_L_DIVU        ] = &(operation_l_divu    );
209     if (_param->_timing[TYPE_EXTEND ][OPERATION_EXTEND_L_EXTEND_S ]._latence > 0) 
210       _function_execute[TYPE_EXTEND ][OPERATION_EXTEND_L_EXTEND_S ] = &(operation_l_extend_s);
211     if (_param->_timing[TYPE_EXTEND ][OPERATION_EXTEND_L_EXTEND_Z ]._latence > 0) 
212       _function_execute[TYPE_EXTEND ][OPERATION_EXTEND_L_EXTEND_Z ] = &(operation_l_extend_z);
213     if (_param->_timing[TYPE_FIND   ][OPERATION_FIND_L_FF1        ]._latence > 0) 
214       _function_execute[TYPE_FIND   ][OPERATION_FIND_L_FF1        ] = &(operation_l_ff1     ); 
215     if (_param->_timing[TYPE_FIND   ][OPERATION_FIND_L_FL1        ]._latence > 0) 
216       _function_execute[TYPE_FIND   ][OPERATION_FIND_L_FL1        ] = &(operation_l_fl1     ); 
217     if (_param->_timing[TYPE_SPECIAL][OPERATION_SPECIAL_L_MFSPR   ]._latence > 0) 
218       _function_execute[TYPE_SPECIAL][OPERATION_SPECIAL_L_MFSPR   ] = &(operation_l_mfspr   ); 
219     if (_param->_timing[TYPE_SPECIAL][OPERATION_SPECIAL_L_MTSPR   ]._latence > 0) 
220       _function_execute[TYPE_SPECIAL][OPERATION_SPECIAL_L_MTSPR   ] = &(operation_l_mtspr   ); 
221     if (_param->_timing[TYPE_SPECIAL][OPERATION_SPECIAL_L_MAC     ]._latence > 0) 
222       _function_execute[TYPE_SPECIAL][OPERATION_SPECIAL_L_MAC     ] = &(operation_l_mac     ); 
223     if (_param->_timing[TYPE_SPECIAL][OPERATION_SPECIAL_L_MACRC   ]._latence > 0) 
224       _function_execute[TYPE_SPECIAL][OPERATION_SPECIAL_L_MACRC   ] = &(operation_l_macrc   ); 
225     if (_param->_timing[TYPE_SPECIAL][OPERATION_SPECIAL_L_MSB     ]._latence > 0) 
226       _function_execute[TYPE_SPECIAL][OPERATION_SPECIAL_L_MSB     ] = &(operation_l_msb     ); 
227     if (_param->_timing[TYPE_BRANCH ][OPERATION_BRANCH_L_TEST_F   ]._latence > 0) 
228       _function_execute[TYPE_BRANCH ][OPERATION_BRANCH_L_TEST_F   ] = &(operation_l_test_f  );
229     if (_param->_timing[TYPE_BRANCH ][OPERATION_BRANCH_L_TEST_NF  ]._latence > 0) 
230       _function_execute[TYPE_BRANCH ][OPERATION_BRANCH_L_TEST_NF  ] = &(operation_l_test_nf );
231     if (_param->_timing[TYPE_BRANCH ][OPERATION_BRANCH_L_JALR     ]._latence > 0) 
232       _function_execute[TYPE_BRANCH ][OPERATION_BRANCH_L_JALR     ] = &(operation_l_jalr    );
233       }
234
235#ifdef POSITION
236     if (usage_is_set(_usage,USE_POSITION))
237       _component->generate_file();
238#endif
239
240    log_printf(FUNC,Functionnal_unit,FUNCTION,"End");
241  };
242
243}; // end namespace functionnal_unit
244}; // end namespace execute_unit
245}; // end namespace multi_execute_unit
246}; // end namespace execute_loop
247}; // end namespace multi_execute_loop
248}; // end namespace core
249
250}; // end namespace behavioural
251}; // end namespace morpheo             
Note: See TracBrowser for help on using the repository browser.