1 | #ifdef SYSTEMC |
---|
2 | /* |
---|
3 | * $Id: Decod_queue_transition.cpp 101 2009-01-15 17:19:08Z rosiere $ |
---|
4 | * |
---|
5 | * [ Description ] |
---|
6 | * |
---|
7 | */ |
---|
8 | |
---|
9 | #include "Behavioural/Core/Multi_Front_end/Front_end/Decod_unit/Decod_queue/include/Decod_queue.h" |
---|
10 | |
---|
11 | namespace morpheo { |
---|
12 | namespace behavioural { |
---|
13 | namespace core { |
---|
14 | namespace multi_front_end { |
---|
15 | namespace front_end { |
---|
16 | namespace decod_unit { |
---|
17 | namespace decod_queue { |
---|
18 | |
---|
19 | |
---|
20 | #undef FUNCTION |
---|
21 | #define FUNCTION "Decod_queue::transition" |
---|
22 | void Decod_queue::transition (void) |
---|
23 | { |
---|
24 | log_begin(Decod_queue,FUNCTION); |
---|
25 | log_function(Decod_queue,FUNCTION,_name.c_str()); |
---|
26 | |
---|
27 | if (PORT_READ(in_NRESET) == 0) |
---|
28 | { |
---|
29 | reg_QUEUE->clear(); |
---|
30 | |
---|
31 | for (uint32_t i=0; i<_param->_nb_context; i++) |
---|
32 | reg_NB_INST [i]=0; |
---|
33 | } |
---|
34 | else |
---|
35 | { |
---|
36 | //-------------------------------------------------------------------- |
---|
37 | //-----[ DECOD_IN ]--------------------------------------------------- |
---|
38 | //-------------------------------------------------------------------- |
---|
39 | decod_queue_entry_t * entry = NULL; |
---|
40 | for (uint32_t i=0; i<_param->_nb_inst_decod; i++) |
---|
41 | { |
---|
42 | if (PORT_READ(in_DECOD_IN_VAL [i]) and internal_DECOD_IN_ACK[i]) |
---|
43 | { |
---|
44 | log_printf(TRACE,Decod_queue,FUNCTION,_(" * DECOD_IN [%d]"),i); |
---|
45 | |
---|
46 | if (entry == NULL) |
---|
47 | { |
---|
48 | // Once creation and insert in queue |
---|
49 | entry = new decod_queue_entry_t (_param->_nb_inst_decod); |
---|
50 | reg_QUEUE->push_back(entry); |
---|
51 | } |
---|
52 | |
---|
53 | Tcontext_t context = (_param->_have_port_context_id)?PORT_READ(in_DECOD_IN_CONTEXT_ID [i]):0; |
---|
54 | |
---|
55 | log_printf(TRACE,Decod_queue,FUNCTION,_(" * context : %d"),context); |
---|
56 | |
---|
57 | entry->_val [i] = 1; |
---|
58 | entry->_context_id [i] = context; |
---|
59 | entry->_depth [i] = (_param->_have_port_depth)?PORT_READ(in_DECOD_IN_DEPTH [i]):0; |
---|
60 | entry->_type [i] = PORT_READ(in_DECOD_IN_TYPE [i]); |
---|
61 | entry->_operation [i] = PORT_READ(in_DECOD_IN_OPERATION [i]); |
---|
62 | entry->_no_execute [i] = PORT_READ(in_DECOD_IN_NO_EXECUTE [i]); |
---|
63 | entry->_is_delay_slot [i] = PORT_READ(in_DECOD_IN_IS_DELAY_SLOT [i]); |
---|
64 | entry->_address [i] = PORT_READ(in_DECOD_IN_ADDRESS [i]); |
---|
65 | entry->_has_immediat [i] = PORT_READ(in_DECOD_IN_HAS_IMMEDIAT [i]); |
---|
66 | entry->_immediat [i] = PORT_READ(in_DECOD_IN_IMMEDIAT [i]); |
---|
67 | entry->_read_ra [i] = PORT_READ(in_DECOD_IN_READ_RA [i]); |
---|
68 | entry->_num_reg_ra [i] = PORT_READ(in_DECOD_IN_NUM_REG_RA [i]); |
---|
69 | entry->_read_rb [i] = PORT_READ(in_DECOD_IN_READ_RB [i]); |
---|
70 | entry->_num_reg_rb [i] = PORT_READ(in_DECOD_IN_NUM_REG_RB [i]); |
---|
71 | entry->_read_rc [i] = PORT_READ(in_DECOD_IN_READ_RC [i]); |
---|
72 | entry->_num_reg_rc [i] = PORT_READ(in_DECOD_IN_NUM_REG_RC [i]); |
---|
73 | entry->_write_rd [i] = PORT_READ(in_DECOD_IN_WRITE_RD [i]); |
---|
74 | entry->_num_reg_rd [i] = PORT_READ(in_DECOD_IN_NUM_REG_RD [i]); |
---|
75 | entry->_write_re [i] = PORT_READ(in_DECOD_IN_WRITE_RE [i]); |
---|
76 | entry->_num_reg_re [i] = PORT_READ(in_DECOD_IN_NUM_REG_RE [i]); |
---|
77 | entry->_exception_use [i] = PORT_READ(in_DECOD_IN_EXCEPTION_USE [i]); |
---|
78 | entry->_exception [i] = PORT_READ(in_DECOD_IN_EXCEPTION [i]); |
---|
79 | |
---|
80 | reg_NB_INST [context] ++; |
---|
81 | |
---|
82 | log_printf(TRACE,Decod_queue,FUNCTION,_(" * nb_inst : %d"),reg_NB_INST [context]); |
---|
83 | log_printf(TRACE,Decod_queue,FUNCTION,_(" * PUSH queue")); |
---|
84 | } |
---|
85 | } |
---|
86 | |
---|
87 | //-------------------------------------------------------------------- |
---|
88 | //-----[ DECOD_OUT ]-------------------------------------------------- |
---|
89 | //-------------------------------------------------------------------- |
---|
90 | if (not reg_QUEUE->empty()) |
---|
91 | { |
---|
92 | bool find = false; |
---|
93 | |
---|
94 | for (uint32_t i=0; i<_param->_nb_inst_decod; i++) |
---|
95 | { |
---|
96 | // Test transaction : if ok then invalid slot |
---|
97 | if (internal_DECOD_OUT_VAL [i] and internal_DECOD_OUT_ACK[i]) |
---|
98 | { |
---|
99 | log_printf(TRACE,Decod_queue,FUNCTION,_(" * DECOD_OUT [%d]"),i); |
---|
100 | |
---|
101 | reg_QUEUE->front()->_val [i] = 0; |
---|
102 | |
---|
103 | Tcontext_t context = reg_QUEUE->front()->_context_id [i]; |
---|
104 | log_printf(TRACE,Decod_queue,FUNCTION,_(" * context : %d"),context); |
---|
105 | |
---|
106 | reg_NB_INST [context] --; |
---|
107 | log_printf(TRACE,Decod_queue,FUNCTION,_(" * nb_inst : %d"),reg_NB_INST [context]); |
---|
108 | } |
---|
109 | // Test if slot is (again) valid, if yes, then have less one instruction in the entry |
---|
110 | find |= reg_QUEUE->front()->_val [i]; |
---|
111 | } |
---|
112 | |
---|
113 | // test if can free the entry |
---|
114 | if (not find) // no valid instruction in current slot |
---|
115 | { |
---|
116 | log_printf(TRACE,Decod_queue,FUNCTION,_(" * POP queue")); |
---|
117 | |
---|
118 | // can pop the slot |
---|
119 | delete reg_QUEUE->front(); |
---|
120 | reg_QUEUE->pop_front(); |
---|
121 | } |
---|
122 | } |
---|
123 | } |
---|
124 | |
---|
125 | #if defined(DEBUG) and defined(DEBUG_Decod_queue) and (DEBUG >= DEBUG_TRACE) |
---|
126 | log_printf(TRACE,Decod_queue,FUNCTION," * Dump decod_queue"); |
---|
127 | uint32_t x=0; |
---|
128 | for (std::list<decod_queue_entry_t*>::iterator it=reg_QUEUE->begin(); |
---|
129 | it!=reg_QUEUE->end(); |
---|
130 | it++) |
---|
131 | { |
---|
132 | log_printf(TRACE,Decod_queue,FUNCTION," * [%d] ",x); |
---|
133 | |
---|
134 | for (uint32_t i=0; i<_param->_nb_inst_decod; i++) |
---|
135 | { |
---|
136 | if ((*it)->_val [i]) |
---|
137 | log_printf(TRACE,Decod_queue,FUNCTION," * [%.4d] %.1d, %.3d %.2d, %.2d %.3d %.1d %.1d, 0x%.8x (0x%.8x), %.1d 0x%.8x, %.1d %.2d, %.1d %.2d, %.1d %.2d, %.1d %.2d, %.1d %.2d, %.1d %.2d" |
---|
138 | ,i |
---|
139 | ,(*it)->_val [i] |
---|
140 | ,(*it)->_context_id [i] |
---|
141 | ,(*it)->_depth [i] |
---|
142 | ,(*it)->_type [i] |
---|
143 | ,(*it)->_operation [i] |
---|
144 | ,(*it)->_no_execute [i] |
---|
145 | ,(*it)->_is_delay_slot [i] |
---|
146 | ,(*it)->_address [i] |
---|
147 | ,(*it)->_address [i]<<2 |
---|
148 | ,(*it)->_has_immediat [i] |
---|
149 | ,(*it)->_immediat [i] |
---|
150 | ,(*it)->_read_ra [i] |
---|
151 | ,(*it)->_num_reg_ra [i] |
---|
152 | ,(*it)->_read_rb [i] |
---|
153 | ,(*it)->_num_reg_rb [i] |
---|
154 | ,(*it)->_read_rc [i] |
---|
155 | ,(*it)->_num_reg_rc [i] |
---|
156 | ,(*it)->_write_rd [i] |
---|
157 | ,(*it)->_num_reg_rd [i] |
---|
158 | ,(*it)->_write_re [i] |
---|
159 | ,(*it)->_num_reg_re [i] |
---|
160 | ,(*it)->_exception_use [i] |
---|
161 | ,(*it)->_exception [i] |
---|
162 | ); |
---|
163 | else |
---|
164 | log_printf(TRACE,Decod_queue,FUNCTION," * [%d] %d" |
---|
165 | ,i |
---|
166 | ,(*it)->_val [i] |
---|
167 | ); |
---|
168 | |
---|
169 | } |
---|
170 | x++; |
---|
171 | } |
---|
172 | #endif |
---|
173 | |
---|
174 | #ifdef STATISTICS |
---|
175 | if (usage_is_set(_usage,USE_STATISTICS)) |
---|
176 | { |
---|
177 | *(_stat_use_queue) += reg_QUEUE->size(); |
---|
178 | for (uint32_t i=0; i<_param->_nb_context; i++) |
---|
179 | *(_stat_nb_inst [i]) += reg_NB_INST [i]; |
---|
180 | } |
---|
181 | #endif |
---|
182 | |
---|
183 | #if defined(STATISTICS) or defined(VHDL_TESTBENCH) |
---|
184 | end_cycle (); |
---|
185 | #endif |
---|
186 | |
---|
187 | log_end(Decod_queue,FUNCTION); |
---|
188 | }; |
---|
189 | |
---|
190 | }; // end namespace decod_queue |
---|
191 | }; // end namespace decod_unit |
---|
192 | }; // end namespace front_end |
---|
193 | }; // end namespace multi_front_end |
---|
194 | }; // end namespace core |
---|
195 | |
---|
196 | }; // end namespace behavioural |
---|
197 | }; // end namespace morpheo |
---|
198 | #endif |
---|