[78] | 1 | #ifdef SYSTEMC |
---|
| 2 | /* |
---|
| 3 | * $Id: Load_Store_pointer_unit_genMealy_insert.cpp 138 2010-05-12 17:34:01Z rosiere $ |
---|
| 4 | * |
---|
| 5 | * [ Description ] |
---|
| 6 | * |
---|
| 7 | */ |
---|
| 8 | |
---|
| 9 | #include "Behavioural/Core/Multi_OOO_Engine/OOO_Engine/Rename_unit/Load_Store_pointer_unit/include/Load_Store_pointer_unit.h" |
---|
| 10 | |
---|
| 11 | namespace morpheo { |
---|
| 12 | namespace behavioural { |
---|
| 13 | namespace core { |
---|
| 14 | namespace multi_ooo_engine { |
---|
| 15 | namespace ooo_engine { |
---|
| 16 | namespace rename_unit { |
---|
| 17 | namespace load_store_pointer_unit { |
---|
| 18 | |
---|
| 19 | |
---|
| 20 | #undef FUNCTION |
---|
| 21 | #define FUNCTION "Load_Store_pointer_unit::genMealy_insert" |
---|
| 22 | void Load_Store_pointer_unit::genMealy_insert (void) |
---|
| 23 | { |
---|
[110] | 24 | log_begin(Load_Store_pointer_unit,FUNCTION); |
---|
| 25 | log_function(Load_Store_pointer_unit,FUNCTION,_name.c_str()); |
---|
[78] | 26 | |
---|
[123] | 27 | if (PORT_READ(in_NRESET)) |
---|
| 28 | { |
---|
[110] | 29 | // TODO : limité à nb_inst_memory le nombre d'accès par lsq !!! |
---|
| 30 | |
---|
| 31 | uint32_t nb_use_lsq [_param->_nb_load_store_queue]; |
---|
| 32 | Tlsq_ptr_t STORE_QUEUE_PTR_WRITE [_param->_nb_load_store_queue]; |
---|
| 33 | bool STORE_QUEUE_USE [_param->_nb_load_store_queue][_param->_max_size_store_queue]; |
---|
| 34 | Tlsq_ptr_t STORE_QUEUE_NB_USE [_param->_nb_load_store_queue]; |
---|
| 35 | Tlsq_ptr_t LOAD_QUEUE_PTR_WRITE [_param->_nb_load_store_queue]; |
---|
| 36 | bool LOAD_QUEUE_USE [_param->_nb_load_store_queue][_param->_max_size_load_queue]; |
---|
| 37 | |
---|
[78] | 38 | for (uint32_t i=0; i<_param->_nb_load_store_queue; i++) |
---|
[110] | 39 | { |
---|
| 40 | nb_use_lsq [i] = _param->_nb_inst_memory[i]; |
---|
[78] | 41 | |
---|
[110] | 42 | STORE_QUEUE_PTR_WRITE [i] = reg_STORE_QUEUE_PTR_WRITE [i]; |
---|
| 43 | STORE_QUEUE_NB_USE [i] = reg_STORE_QUEUE_NB_USE [i]; |
---|
| 44 | LOAD_QUEUE_PTR_WRITE [i] = reg_LOAD_QUEUE_PTR_WRITE [i]; |
---|
| 45 | |
---|
| 46 | for (uint32_t j=0; j<_param->_size_store_queue[i]; j++) |
---|
| 47 | STORE_QUEUE_USE [i][j] = reg_STORE_QUEUE_USE [i][j]; |
---|
| 48 | for (uint32_t j=0; j<_param->_size_load_queue[i]; j++) |
---|
| 49 | LOAD_QUEUE_USE [i][j] = reg_LOAD_QUEUE_USE [i][j]; |
---|
| 50 | } |
---|
| 51 | |
---|
[78] | 52 | for (uint32_t i=0; i<_param->_nb_inst_insert; i++) |
---|
| 53 | { |
---|
[110] | 54 | log_printf(TRACE,Load_Store_pointer_unit,FUNCTION," * INSERT [%d]",i); |
---|
| 55 | |
---|
[138] | 56 | Tcontrol_t ack = false; |
---|
| 57 | bool find = false; |
---|
[78] | 58 | |
---|
[138] | 59 | if (PORT_READ(in_INSERT_VAL [i]) == true) |
---|
| 60 | { |
---|
| 61 | Tcontext_t front_end_id = (_param->_have_port_front_end_id)?PORT_READ(in_INSERT_FRONT_END_ID [i]):0; |
---|
| 62 | Tcontext_t context_id = (_param->_have_port_context_id )?PORT_READ(in_INSERT_CONTEXT_ID [i]):0; |
---|
| 63 | uint32_t lsq = _param->_link_load_store_unit_with_thread[front_end_id][context_id]; |
---|
| 64 | |
---|
[110] | 65 | log_printf(TRACE,Load_Store_pointer_unit,FUNCTION," * front_end_id : %d",front_end_id); |
---|
| 66 | log_printf(TRACE,Load_Store_pointer_unit,FUNCTION," * context_id : %d",context_id ); |
---|
| 67 | log_printf(TRACE,Load_Store_pointer_unit,FUNCTION," * lsq : %d",lsq ); |
---|
[138] | 68 | |
---|
| 69 | PORT_WRITE(out_INSERT_STORE_QUEUE_PTR_WRITE [i], STORE_QUEUE_PTR_WRITE [lsq]); |
---|
| 70 | // PORT_WRITE(out_INSERT_STORE_QUEUE_PTR_READ [i], ((reg_STORE_QUEUE_PTR_READ [front_end_id][context_id]+1)%_param->_size_load_queue[lsq])); |
---|
| 71 | PORT_WRITE(out_INSERT_STORE_QUEUE_PTR_READ [i], reg_STORE_QUEUE_PTR_READ [front_end_id][context_id]); |
---|
| 72 | PORT_WRITE(out_INSERT_STORE_QUEUE_EMPTY [i], reg_STORE_QUEUE_EMPTY [front_end_id][context_id]); |
---|
| 73 | if (_param->_have_port_load_queue_ptr) |
---|
| 74 | PORT_WRITE(out_INSERT_LOAD_QUEUE_PTR_WRITE [i], LOAD_QUEUE_PTR_WRITE [lsq]); |
---|
[110] | 75 | |
---|
[138] | 76 | if (PORT_READ(in_INSERT_TYPE [i]) == TYPE_MEMORY) |
---|
| 77 | { |
---|
| 78 | log_printf(TRACE,Load_Store_pointer_unit,FUNCTION," * type is memory"); |
---|
| 79 | |
---|
| 80 | find = true; |
---|
[110] | 81 | |
---|
[138] | 82 | // Test if a previous instruction use the same lsq |
---|
| 83 | // Authorize once memory access by load store unit |
---|
| 84 | if (nb_use_lsq [lsq] > 0) |
---|
| 85 | { |
---|
| 86 | nb_use_lsq [lsq] --; |
---|
| 87 | |
---|
| 88 | uint32_t ptr; |
---|
| 89 | |
---|
| 90 | log_printf(TRACE,Load_Store_pointer_unit,FUNCTION," * sq_ptr_write : %d",STORE_QUEUE_PTR_WRITE [lsq]); |
---|
| 91 | log_printf(TRACE,Load_Store_pointer_unit,FUNCTION," * lq_ptr_write : %d",LOAD_QUEUE_PTR_WRITE [lsq]); |
---|
| 92 | |
---|
| 93 | // operation became of decod_stage. Also operation is != store_head_ok and store_head_ko |
---|
| 94 | if (is_operation_memory_store(PORT_READ(in_INSERT_OPERATION [i]))) |
---|
[110] | 95 | { |
---|
[138] | 96 | log_printf(TRACE,Load_Store_pointer_unit,FUNCTION," * USE_STORE_QUEUE"); |
---|
| 97 | |
---|
| 98 | internal_INSERT_OPERATION_USE [i] = OPERATION_USE_STORE_QUEUE; |
---|
| 99 | |
---|
| 100 | ptr = STORE_QUEUE_PTR_WRITE [lsq]; |
---|
| 101 | ack = not STORE_QUEUE_USE [lsq][ptr] and (static_cast<uint32_t>(STORE_QUEUE_NB_USE [lsq]+1) < _param->_size_store_queue[lsq]); |
---|
| 102 | |
---|
| 103 | if (ack) |
---|
| 104 | { |
---|
| 105 | STORE_QUEUE_PTR_WRITE [lsq] = (ptr+1)%_param->_size_store_queue[lsq]; |
---|
| 106 | STORE_QUEUE_NB_USE [lsq] ++; |
---|
| 107 | STORE_QUEUE_USE [lsq][ptr] = true; |
---|
| 108 | } |
---|
[110] | 109 | } |
---|
[138] | 110 | else |
---|
[110] | 111 | { |
---|
[138] | 112 | log_printf(TRACE,Load_Store_pointer_unit,FUNCTION," * USE_LOAD_QUEUE"); |
---|
| 113 | |
---|
| 114 | internal_INSERT_OPERATION_USE [i] = OPERATION_USE_LOAD_QUEUE; |
---|
| 115 | |
---|
| 116 | ptr = LOAD_QUEUE_PTR_WRITE [lsq]; |
---|
| 117 | ack = (not LOAD_QUEUE_USE [lsq][ptr]); |
---|
| 118 | |
---|
| 119 | if (ack) |
---|
| 120 | { |
---|
| 121 | LOAD_QUEUE_PTR_WRITE [lsq] = (ptr+1)%_param->_size_load_queue[lsq]; |
---|
| 122 | LOAD_QUEUE_USE [lsq][ptr] = true; |
---|
| 123 | } |
---|
[110] | 124 | } |
---|
[138] | 125 | |
---|
| 126 | log_printf(TRACE,Load_Store_pointer_unit,FUNCTION," * ptr : %d",ptr ); |
---|
| 127 | log_printf(TRACE,Load_Store_pointer_unit,FUNCTION," * ack : %d",ack ); |
---|
| 128 | |
---|
| 129 | internal_INSERT_LSQ [i] = lsq; |
---|
| 130 | internal_INSERT_PTR [i] = ptr; |
---|
| 131 | } |
---|
| 132 | } |
---|
| 133 | } |
---|
[110] | 134 | |
---|
[138] | 135 | if (not find) |
---|
| 136 | { |
---|
| 137 | ack = true; |
---|
| 138 | |
---|
| 139 | internal_INSERT_OPERATION_USE [i] = OPERATION_USE_NONE; |
---|
| 140 | } |
---|
[78] | 141 | |
---|
| 142 | |
---|
| 143 | // Write output |
---|
| 144 | internal_INSERT_ACK [i] = ack; |
---|
| 145 | } |
---|
[123] | 146 | } |
---|
| 147 | else |
---|
| 148 | { |
---|
| 149 | for (uint32_t i=0; i<_param->_nb_inst_insert; i++) |
---|
| 150 | internal_INSERT_ACK [i] = 0; |
---|
| 151 | } |
---|
| 152 | |
---|
| 153 | for (uint32_t i=0; i<_param->_nb_inst_insert; i++) |
---|
| 154 | PORT_WRITE(out_INSERT_ACK [i], internal_INSERT_ACK [i]); |
---|
| 155 | |
---|
[110] | 156 | log_end(Load_Store_pointer_unit,FUNCTION); |
---|
[78] | 157 | }; |
---|
| 158 | |
---|
| 159 | }; // end namespace load_store_pointer_unit |
---|
| 160 | }; // end namespace rename_unit |
---|
| 161 | }; // end namespace ooo_engine |
---|
| 162 | }; // end namespace multi_ooo_engine |
---|
| 163 | }; // end namespace core |
---|
| 164 | |
---|
| 165 | }; // end namespace behavioural |
---|
| 166 | }; // end namespace morpheo |
---|
| 167 | #endif |
---|