[54] | 1 | #ifdef SYSTEMC |
---|
| 2 | //#if defined(STATISTICS) or defined(VHDL_TESTBENCH) |
---|
| 3 | /* |
---|
| 4 | * $Id$ |
---|
| 5 | * |
---|
| 6 | * [ Description ] |
---|
| 7 | * |
---|
| 8 | */ |
---|
| 9 | |
---|
| 10 | #include "Behavioural/Core/Multi_Execute_loop/Execute_loop/Multi_Read_unit/Read_unit/Read_queue/include/Read_queue.h" |
---|
| 11 | |
---|
| 12 | namespace morpheo { |
---|
| 13 | namespace behavioural { |
---|
| 14 | namespace core { |
---|
| 15 | namespace multi_execute_loop { |
---|
| 16 | namespace execute_loop { |
---|
| 17 | namespace multi_read_unit { |
---|
| 18 | namespace read_unit { |
---|
| 19 | namespace read_queue { |
---|
| 20 | |
---|
| 21 | |
---|
| 22 | #undef FUNCTION |
---|
| 23 | #define FUNCTION "Read_queue::transition" |
---|
| 24 | void Read_queue::transition (void) |
---|
| 25 | { |
---|
| 26 | log_printf(FUNC,Read_queue,FUNCTION,"Begin"); |
---|
| 27 | |
---|
| 28 | if (PORT_READ(in_NRESET) == 0) |
---|
| 29 | { |
---|
| 30 | // Flush queue |
---|
| 31 | // FIXME "queue reset" |
---|
| 32 | // > 1) flush one slot by cycle |
---|
| 33 | // > 2) flush all slot in one cycle |
---|
| 34 | |
---|
| 35 | while (_queue->empty() == false) |
---|
| 36 | _queue->pop(); |
---|
| 37 | } |
---|
| 38 | else |
---|
| 39 | { |
---|
| 40 | // cout << "Transition Begin : Print queue_head" << endl; |
---|
| 41 | // if (_queue->empty ()) |
---|
| 42 | // cout << "queue is empty !!!" << endl; |
---|
| 43 | // else |
---|
| 44 | // cout << (*_queue_head) << endl; |
---|
| 45 | |
---|
| 46 | log_printf(TRACE,Read_queue,FUNCTION,"Read_queue size (begin) : %d",_queue->size()); |
---|
| 47 | // Write to read_queue |
---|
| 48 | |
---|
[55] | 49 | bool not_full = not (_queue->size() == _param->_size_queue); |
---|
[54] | 50 | bool empty = _queue->empty(); |
---|
| 51 | bool nead_new_head = false; |
---|
| 52 | |
---|
| 53 | log_printf(TRACE,Read_queue,FUNCTION," * test transaction READ_QUEUE_IN : %d,%d",PORT_READ(in_READ_QUEUE_IN_VAL), not_full); |
---|
| 54 | if ((PORT_READ(in_READ_QUEUE_IN_VAL) == 1) and not_full) |
---|
| 55 | { |
---|
| 56 | Tread_queue_entry_t * entry = new Tread_queue_entry_t; |
---|
| 57 | |
---|
| 58 | entry->_context_id = PORT_READ(in_READ_QUEUE_IN_CONTEXT_ID ); |
---|
| 59 | entry->_packet_id = PORT_READ(in_READ_QUEUE_IN_PACKET_ID ); |
---|
| 60 | entry->_operation = PORT_READ(in_READ_QUEUE_IN_OPERATION ); |
---|
| 61 | entry->_type = PORT_READ(in_READ_QUEUE_IN_TYPE ); |
---|
| 62 | entry->_has_immediat = PORT_READ(in_READ_QUEUE_IN_HAS_IMMEDIAT); |
---|
| 63 | entry->_immediat = PORT_READ(in_READ_QUEUE_IN_IMMEDIAT ); |
---|
| 64 | entry->_read_ra = PORT_READ(in_READ_QUEUE_IN_READ_RA ); |
---|
| 65 | entry->_num_reg_ra = PORT_READ(in_READ_QUEUE_IN_NUM_REG_RA ); |
---|
| 66 | entry->_read_rb = PORT_READ(in_READ_QUEUE_IN_READ_RB ); |
---|
| 67 | entry->_num_reg_rb = PORT_READ(in_READ_QUEUE_IN_NUM_REG_RB ); |
---|
| 68 | entry->_read_rc = PORT_READ(in_READ_QUEUE_IN_READ_RC ); |
---|
| 69 | entry->_num_reg_rc = PORT_READ(in_READ_QUEUE_IN_NUM_REG_RC ); |
---|
| 70 | entry->_write_rd = PORT_READ(in_READ_QUEUE_IN_WRITE_RD ); |
---|
| 71 | entry->_num_reg_rd = PORT_READ(in_READ_QUEUE_IN_NUM_REG_RD ); |
---|
| 72 | entry->_write_re = PORT_READ(in_READ_QUEUE_IN_WRITE_RE ); |
---|
| 73 | entry->_num_reg_re = PORT_READ(in_READ_QUEUE_IN_NUM_REG_RE ); |
---|
| 74 | |
---|
| 75 | log_printf(TRACE,Read_queue,FUNCTION," * push (id : %d-%d)",entry->_context_id, entry->_packet_id); |
---|
| 76 | _queue->push(entry); |
---|
| 77 | |
---|
| 78 | |
---|
| 79 | // read next new head |
---|
| 80 | if (empty) |
---|
| 81 | { |
---|
| 82 | log_printf(TRACE,Read_queue,FUNCTION," * queue was empty"); |
---|
| 83 | nead_new_head = true; |
---|
| 84 | } |
---|
| 85 | } |
---|
| 86 | |
---|
| 87 | // Read from read_queue |
---|
| 88 | log_printf(TRACE,Read_queue,FUNCTION," * test transaction READ_QUEUE_OUT : %d,%d",internal_READ_QUEUE_OUT_VAL, PORT_READ(in_READ_QUEUE_OUT_ACK)); |
---|
| 89 | if (( internal_READ_QUEUE_OUT_VAL == 1) and |
---|
| 90 | (PORT_READ(in_READ_QUEUE_OUT_ACK) == 1)) |
---|
| 91 | { |
---|
| 92 | // Pop the entry |
---|
| 93 | log_printf(TRACE,Read_queue,FUNCTION," * pop (id : %d-%d)",_queue->front()->_context_id, _queue->front()->_packet_id); |
---|
| 94 | _queue->pop(); |
---|
| 95 | |
---|
| 96 | // read next new head |
---|
| 97 | if (_queue->empty() == false) |
---|
| 98 | { |
---|
| 99 | log_printf(TRACE,Read_queue,FUNCTION," * queue was not empty"); |
---|
| 100 | nead_new_head = true; |
---|
| 101 | } |
---|
| 102 | } |
---|
| 103 | else |
---|
| 104 | { |
---|
| 105 | // no transaction, update queue_head |
---|
| 106 | _queue_head->_read_ra_val = internal_READ_QUEUE_OUT_READ_RA_VAL ; |
---|
| 107 | _queue_head->_data_ra_val = internal_READ_QUEUE_OUT_DATA_RA_VAL ; |
---|
| 108 | _queue_head->_data_ra = internal_READ_QUEUE_OUT_DATA_RA ; |
---|
| 109 | |
---|
| 110 | _queue_head->_read_rb_val = internal_READ_QUEUE_OUT_READ_RB_VAL ; |
---|
| 111 | _queue_head->_data_rb_val = internal_READ_QUEUE_OUT_DATA_RB_VAL ; |
---|
| 112 | _queue_head->_data_rb = internal_READ_QUEUE_OUT_DATA_RB ; |
---|
| 113 | |
---|
| 114 | _queue_head->_read_rc_val = internal_READ_QUEUE_OUT_READ_RC_VAL ; |
---|
| 115 | _queue_head->_data_rc_val = internal_READ_QUEUE_OUT_DATA_RC_VAL ; |
---|
| 116 | _queue_head->_data_rc = internal_READ_QUEUE_OUT_DATA_RC ; |
---|
| 117 | } |
---|
| 118 | |
---|
| 119 | if (nead_new_head == true) |
---|
| 120 | { |
---|
| 121 | log_printf(TRACE,Read_queue,FUNCTION," * new head"); |
---|
| 122 | (*_queue_head) = (*_queue->front()); |
---|
| 123 | } |
---|
| 124 | |
---|
| 125 | // cout << "Transition End : Print queue_head" << endl; |
---|
| 126 | // if (_queue->empty ()) |
---|
| 127 | // cout << "queue is empty !!!" << endl; |
---|
| 128 | // else |
---|
| 129 | // cout << (*_queue_head) << endl; |
---|
| 130 | |
---|
| 131 | log_printf(TRACE,Read_queue,FUNCTION,"Read_queue size (end ) : %d",_queue->size()); |
---|
| 132 | } |
---|
| 133 | |
---|
| 134 | #ifdef STATISTICS |
---|
| 135 | _stat->add(); |
---|
| 136 | #endif |
---|
| 137 | |
---|
| 138 | #ifdef VHDL_TESTBENCH |
---|
| 139 | vhdl_testbench_transition (); |
---|
| 140 | #endif |
---|
| 141 | |
---|
| 142 | log_printf(FUNC,Read_queue,FUNCTION,"End"); |
---|
| 143 | }; |
---|
| 144 | |
---|
| 145 | }; // end namespace read_queue |
---|
| 146 | }; // end namespace read_unit |
---|
| 147 | }; // end namespace multi_read_unit |
---|
| 148 | }; // end namespace execute_loop |
---|
| 149 | }; // end namespace multi_execute_loop |
---|
| 150 | }; // end namespace core |
---|
| 151 | |
---|
| 152 | }; // end namespace behavioural |
---|
| 153 | }; // end namespace morpheo |
---|
| 154 | #endif |
---|
| 155 | //#endif |
---|