1 | #ifdef SYSTEMC |
---|
2 | /* |
---|
3 | * $Id: Decod_queue_transition.cpp 82 2008-05-01 16:48:45Z 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 | |
---|
26 | if (PORT_READ(in_NRESET) == 0) |
---|
27 | { |
---|
28 | reg_QUEUE->clear(); |
---|
29 | |
---|
30 | for (uint32_t i=0; i<_param->_nb_context; i++) |
---|
31 | reg_NB_INST [i]=0; |
---|
32 | } |
---|
33 | else |
---|
34 | { |
---|
35 | //-------------------------------------------------------------------- |
---|
36 | //-----[ DECOD_IN ]--------------------------------------------------- |
---|
37 | //-------------------------------------------------------------------- |
---|
38 | for (uint32_t i=0; i<_param->_nb_inst_decod; i++) |
---|
39 | { |
---|
40 | decod_queue_entry_t * entry = NULL; |
---|
41 | if (PORT_READ(in_DECOD_IN_VAL [i]) and internal_DECOD_IN_ACK[i]) |
---|
42 | { |
---|
43 | log_printf(TRACE,Decod_queue,FUNCTION,_("DECOD_IN [%d]"),i); |
---|
44 | |
---|
45 | if (entry == NULL) |
---|
46 | entry = new decod_queue_entry_t (_param->_nb_inst_decod); |
---|
47 | |
---|
48 | Tcontext_t context = (_param->_have_port_context_id)?PORT_READ(in_DECOD_IN_CONTEXT_ID [i]):0; |
---|
49 | |
---|
50 | log_printf(TRACE,Decod_queue,FUNCTION,_(" * context : %d"),context); |
---|
51 | |
---|
52 | entry->_val [i] = 1; |
---|
53 | entry->_context_id [i] = context; |
---|
54 | entry->_depth [i] = (_param->_have_port_depth)?PORT_READ(in_DECOD_IN_DEPTH [i]):0; |
---|
55 | entry->_type [i] = PORT_READ(in_DECOD_IN_TYPE [i]); |
---|
56 | entry->_operation [i] = PORT_READ(in_DECOD_IN_OPERATION [i]); |
---|
57 | entry->_is_delay_slot [i] = PORT_READ(in_DECOD_IN_IS_DELAY_SLOT [i]); |
---|
58 | entry->_address [i] = PORT_READ(in_DECOD_IN_ADDRESS [i]); |
---|
59 | entry->_has_immediat [i] = PORT_READ(in_DECOD_IN_HAS_IMMEDIAT [i]); |
---|
60 | entry->_immediat [i] = PORT_READ(in_DECOD_IN_IMMEDIAT [i]); |
---|
61 | entry->_read_ra [i] = PORT_READ(in_DECOD_IN_READ_RA [i]); |
---|
62 | entry->_num_reg_ra [i] = PORT_READ(in_DECOD_IN_NUM_REG_RA [i]); |
---|
63 | entry->_read_rb [i] = PORT_READ(in_DECOD_IN_READ_RB [i]); |
---|
64 | entry->_num_reg_rb [i] = PORT_READ(in_DECOD_IN_NUM_REG_RB [i]); |
---|
65 | entry->_read_rc [i] = PORT_READ(in_DECOD_IN_READ_RC [i]); |
---|
66 | entry->_num_reg_rc [i] = PORT_READ(in_DECOD_IN_NUM_REG_RC [i]); |
---|
67 | entry->_write_rd [i] = PORT_READ(in_DECOD_IN_WRITE_RD [i]); |
---|
68 | entry->_num_reg_rd [i] = PORT_READ(in_DECOD_IN_NUM_REG_RD [i]); |
---|
69 | entry->_write_re [i] = PORT_READ(in_DECOD_IN_WRITE_RE [i]); |
---|
70 | entry->_num_reg_re [i] = PORT_READ(in_DECOD_IN_NUM_REG_RE [i]); |
---|
71 | entry->_exception_use [i] = PORT_READ(in_DECOD_IN_EXCEPTION_USE [i]); |
---|
72 | |
---|
73 | reg_NB_INST [context] ++; |
---|
74 | reg_QUEUE->push_back(entry); |
---|
75 | |
---|
76 | log_printf(TRACE,Decod_queue,FUNCTION,_(" * nb_inst : %d"),reg_NB_INST [context]); |
---|
77 | log_printf(TRACE,Decod_queue,FUNCTION,_(" * PUSH queue")); |
---|
78 | |
---|
79 | } |
---|
80 | } |
---|
81 | |
---|
82 | //-------------------------------------------------------------------- |
---|
83 | //-----[ DECOD_OUT ]-------------------------------------------------- |
---|
84 | //-------------------------------------------------------------------- |
---|
85 | if (not reg_QUEUE->empty()) |
---|
86 | { |
---|
87 | bool find = false; |
---|
88 | |
---|
89 | for (uint32_t i=0; i<_param->_nb_inst_decod; i++) |
---|
90 | { |
---|
91 | // Test transaction : if ok then invalid slot |
---|
92 | if (internal_DECOD_OUT_VAL [i] and internal_DECOD_OUT_ACK[i]) |
---|
93 | { |
---|
94 | log_printf(TRACE,Decod_queue,FUNCTION,_("DECOD_OUT [%d]"),i); |
---|
95 | |
---|
96 | reg_QUEUE->front()->_val [i] = 0; |
---|
97 | |
---|
98 | Tcontext_t context = reg_QUEUE->front()->_context_id [i]; |
---|
99 | log_printf(TRACE,Decod_queue,FUNCTION,_(" * context : %d"),context); |
---|
100 | |
---|
101 | reg_NB_INST [context] --; |
---|
102 | log_printf(TRACE,Decod_queue,FUNCTION,_(" * nb_inst : %d"),reg_NB_INST [context]); |
---|
103 | } |
---|
104 | // Test if slot is (again) valid, if yes, then have less one instruction in the entry |
---|
105 | find |= reg_QUEUE->front()->_val [i]; |
---|
106 | } |
---|
107 | |
---|
108 | // test if can free the entry |
---|
109 | if (not find) // no valid instruction in current slot |
---|
110 | { |
---|
111 | log_printf(TRACE,Decod_queue,FUNCTION,_(" * POP queue")); |
---|
112 | |
---|
113 | // can pop the slot |
---|
114 | delete reg_QUEUE->front(); |
---|
115 | reg_QUEUE->pop_front(); |
---|
116 | } |
---|
117 | } |
---|
118 | } |
---|
119 | |
---|
120 | #ifdef STATISTICS |
---|
121 | for (uint32_t i=0; i<_param->_nb_context; i++) |
---|
122 | *(_stat_nb_inst [i]) += reg_NB_INST [i]; |
---|
123 | #endif |
---|
124 | |
---|
125 | #if defined(STATISTICS) or defined(VHDL_TESTBENCH) |
---|
126 | end_cycle (); |
---|
127 | #endif |
---|
128 | |
---|
129 | log_end(Decod_queue,FUNCTION); |
---|
130 | }; |
---|
131 | |
---|
132 | }; // end namespace decod_queue |
---|
133 | }; // end namespace decod_unit |
---|
134 | }; // end namespace front_end |
---|
135 | }; // end namespace multi_front_end |
---|
136 | }; // end namespace core |
---|
137 | |
---|
138 | }; // end namespace behavioural |
---|
139 | }; // end namespace morpheo |
---|
140 | #endif |
---|