1 | #ifdef SYSTEMC |
---|
2 | /* |
---|
3 | * $Id: Icache_Access_genMealy_rsp.cpp 132 2009-07-11 16:39:35Z rosiere $ |
---|
4 | * |
---|
5 | * [ Description ] |
---|
6 | * |
---|
7 | */ |
---|
8 | |
---|
9 | #include "Behavioural/Core/Icache_Access/include/Icache_Access.h" |
---|
10 | |
---|
11 | namespace morpheo { |
---|
12 | namespace behavioural { |
---|
13 | namespace core { |
---|
14 | namespace icache_access { |
---|
15 | |
---|
16 | |
---|
17 | #undef FUNCTION |
---|
18 | #define FUNCTION "Icache_Access::genMealy_rsp" |
---|
19 | void Icache_Access::genMealy_rsp (void) |
---|
20 | { |
---|
21 | log_begin(Icache_Access,FUNCTION); |
---|
22 | log_function(Icache_Access,FUNCTION,_name.c_str()); |
---|
23 | |
---|
24 | Tcontrol_t context_rsp_val [_param->_nb_front_end][_param->_max_nb_context]; |
---|
25 | for (uint32_t i=0; i<_param->_nb_front_end; ++i) |
---|
26 | for (uint32_t j=0; j<_param->_nb_context[i]; ++j) |
---|
27 | context_rsp_val [i][j] = 0; |
---|
28 | |
---|
29 | if (PORT_READ(in_NRESET)) |
---|
30 | { |
---|
31 | for (uint32_t i=0; i<_param->_nb_icache_port; ++i) |
---|
32 | { |
---|
33 | log_printf(TRACE,Icache_Access,FUNCTION," * ICACHE_RSP [%d]",i); |
---|
34 | |
---|
35 | Tcontrol_t val = PORT_READ(in_ICACHE_RSP_VAL [i]); |
---|
36 | Tcontrol_t ack; |
---|
37 | |
---|
38 | Tcontext_t thread_id = (_param->_have_port_icache_thread_id)?PORT_READ(in_ICACHE_RSP_THREAD_ID [i]):0; |
---|
39 | |
---|
40 | log_printf(TRACE,Icache_Access,FUNCTION," * val : %d",val); |
---|
41 | log_printf(TRACE,Icache_Access,FUNCTION," * thread_id : %d",thread_id); |
---|
42 | |
---|
43 | #ifdef DEBUG_TEST |
---|
44 | if (thread_id > _param->_nb_thread) |
---|
45 | throw ERRORMORPHEO(FUNCTION,_("invalid thread_id.\n")); |
---|
46 | #endif |
---|
47 | |
---|
48 | if (val) |
---|
49 | { |
---|
50 | Tcontext_t front_end_id = _param->_translate_thread_to_context [thread_id]; |
---|
51 | Tcontext_t context_id = _param->_translate_thread_to_front_end[thread_id]; |
---|
52 | |
---|
53 | log_printf(TRACE,Icache_Access,FUNCTION," * front_end_id : %d",front_end_id); |
---|
54 | log_printf(TRACE,Icache_Access,FUNCTION," * context_id : %d",context_id ); |
---|
55 | |
---|
56 | // log_printf(TRACE,Icache_Access,FUNCTION,"thread_id : %d",thread_id); |
---|
57 | // log_printf(TRACE,Icache_Access,FUNCTION,"front_end_id : %d",front_end_id); |
---|
58 | // log_printf(TRACE,Icache_Access,FUNCTION,"context_id : %d",context_id); |
---|
59 | |
---|
60 | #ifdef DEBUG_TEST |
---|
61 | if (front_end_id > _param->_nb_front_end) |
---|
62 | throw ERRORMORPHEO(FUNCTION,_("invalid front_end_id.\n")); |
---|
63 | |
---|
64 | if (context_id > _param->_nb_context[front_end_id]) |
---|
65 | throw ERRORMORPHEO(FUNCTION,_("invalid context_id.\n")); |
---|
66 | |
---|
67 | if (_param->_table_routing [front_end_id][context_id] != i) |
---|
68 | throw ERRORMORPHEO(FUNCTION,_("invalid route.\n")); |
---|
69 | #endif |
---|
70 | |
---|
71 | ack = PORT_READ(in_CONTEXT_RSP_ACK [front_end_id][context_id]); |
---|
72 | |
---|
73 | log_printf(TRACE,Icache_Access,FUNCTION," * context_rsp_ack: %d",ack); |
---|
74 | |
---|
75 | context_rsp_val [front_end_id][context_id] = 1; |
---|
76 | // if (_param->_have_port_icache_packet_id) |
---|
77 | if (_param->_have_port_packet_id [front_end_id][context_id]) |
---|
78 | PORT_WRITE(out_CONTEXT_RSP_PACKET_ID [front_end_id][context_id], PORT_READ(in_ICACHE_RSP_PACKET_ID [i])); |
---|
79 | PORT_WRITE(out_CONTEXT_RSP_ERROR [front_end_id][context_id], PORT_READ(in_ICACHE_RSP_ERROR [i])); |
---|
80 | |
---|
81 | for (uint32_t j=0; j<_param->_nb_instruction [front_end_id][context_id]; ++j) |
---|
82 | PORT_WRITE(out_CONTEXT_RSP_INSTRUCTION [front_end_id][context_id][j], PORT_READ(in_ICACHE_RSP_INSTRUCTION [i][j])); |
---|
83 | } |
---|
84 | else |
---|
85 | ack = 0; |
---|
86 | |
---|
87 | PORT_WRITE(out_ICACHE_RSP_ACK [i],ack); |
---|
88 | } |
---|
89 | |
---|
90 | } |
---|
91 | else |
---|
92 | for (uint32_t i=0; i<_param->_nb_icache_port; ++i) |
---|
93 | PORT_WRITE(out_ICACHE_RSP_ACK [i],0); |
---|
94 | |
---|
95 | for (uint32_t i=0; i<_param->_nb_front_end; ++i) |
---|
96 | for (uint32_t j=0; j<_param->_nb_context[i]; ++j) |
---|
97 | { |
---|
98 | log_printf(TRACE,Icache_Access,FUNCTION," * CONTEXT_RSP_VAL [%d][%d] : %d",i,j,context_rsp_val [i][j]); |
---|
99 | |
---|
100 | PORT_WRITE(out_CONTEXT_RSP_VAL [i][j], context_rsp_val [i][j]); |
---|
101 | } |
---|
102 | |
---|
103 | log_end(Icache_Access,FUNCTION); |
---|
104 | }; |
---|
105 | |
---|
106 | }; // end namespace icache_access |
---|
107 | }; // end namespace core |
---|
108 | |
---|
109 | }; // end namespace behavioural |
---|
110 | }; // end namespace morpheo |
---|
111 | #endif |
---|