[81] | 1 | #ifndef ENVIRONMENT_H |
---|
| 2 | #define ENVIRONMENT_H |
---|
| 3 | |
---|
[117] | 4 | #include "../Common/include/Debug.h" |
---|
[81] | 5 | #include "../Cache/include/Cache.h" |
---|
| 6 | #include "../Data/include/Data.h" |
---|
| 7 | #include "../Endianness/include/Endianness.h" |
---|
| 8 | #include "../Queue/include/Sort_Queue.h" |
---|
| 9 | #include "../RamLock/include/RamLock.h" |
---|
| 10 | #include "../Sim2OS/include/Sim2OS.h" |
---|
| 11 | #include "../TTY/include/TTY.h" |
---|
| 12 | #include "../../processor/Morpheo/Common/include/Max.h" |
---|
| 13 | |
---|
| 14 | #include "Types.h" |
---|
| 15 | #include "Environment_Parameters.h" |
---|
| 16 | #include "Respons.h" |
---|
| 17 | #include "Cache_Access.h" |
---|
| 18 | |
---|
| 19 | #include <systemc.h> |
---|
| 20 | |
---|
| 21 | namespace environment { |
---|
| 22 | |
---|
[88] | 23 | typedef Respons<morpheo::Ticache_context_t, morpheo::Ticache_packet_t,morpheo::Ticache_error_t> irsp_t; |
---|
| 24 | typedef Respons<morpheo::Tdcache_context_t, morpheo::Tdcache_packet_t,morpheo::Tdcache_error_t> drsp_t; |
---|
[81] | 25 | |
---|
| 26 | class Environment : public sc_module |
---|
| 27 | { |
---|
| 28 | // ===== [ Ports ]======================================================= |
---|
| 29 | public : sc_in_clk * CLOCK ; |
---|
| 30 | public : sc_in<bool> * NRESET ; |
---|
| 31 | |
---|
[88] | 32 | public : sc_in <morpheo::Tcontrol_t > *** ICACHE_REQ_VAL ;//[nb_entity][icache_dedicated_nb_port] |
---|
| 33 | public : sc_out<morpheo::Tcontrol_t > *** ICACHE_REQ_ACK ;//[nb_entity][icache_dedicated_nb_port] |
---|
| 34 | public : sc_in <morpheo::Ticache_context_t > *** ICACHE_REQ_CONTEXT_ID ;//[nb_entity][icache_dedicated_nb_port] |
---|
| 35 | public : sc_in <morpheo::Ticache_packet_t > *** ICACHE_REQ_PACKET_ID ;//[nb_entity][icache_dedicated_nb_port] |
---|
| 36 | public : sc_in <morpheo::Ticache_address_t > *** ICACHE_REQ_ADDRESS ;//[nb_entity][icache_dedicated_nb_port] |
---|
| 37 | public : sc_in <morpheo::Ticache_type_t > *** ICACHE_REQ_TYPE ;//[nb_entity][icache_dedicated_nb_port] |
---|
[81] | 38 | |
---|
[88] | 39 | public : sc_out<morpheo::Tcontrol_t > *** ICACHE_RSP_VAL ;//[nb_entity][icache_dedicated_nb_port] |
---|
| 40 | public : sc_in <morpheo::Tcontrol_t > *** ICACHE_RSP_ACK ;//[nb_entity][icache_dedicated_nb_port] |
---|
| 41 | public : sc_out<morpheo::Ticache_context_t > *** ICACHE_RSP_CONTEXT_ID ;//[nb_entity][icache_dedicated_nb_port] |
---|
| 42 | public : sc_out<morpheo::Ticache_packet_t > *** ICACHE_RSP_PACKET_ID ;//[nb_entity][icache_dedicated_nb_port] |
---|
| 43 | public : sc_out<morpheo::Ticache_instruction_t> **** ICACHE_RSP_INSTRUCTION;//[nb_entity][icache_dedicated_nb_port][iaccess_nb_instruction] |
---|
| 44 | public : sc_out<morpheo::Ticache_error_t > *** ICACHE_RSP_ERROR ;//[nb_entity][icache_dedicated_nb_port] |
---|
[81] | 45 | |
---|
[88] | 46 | public : sc_in <morpheo::Tcontrol_t > *** DCACHE_REQ_VAL ;//[nb_entity][dcache_dedicated_nb_port] |
---|
| 47 | public : sc_out<morpheo::Tcontrol_t > *** DCACHE_REQ_ACK ;//[nb_entity][dcache_dedicated_nb_port] |
---|
| 48 | public : sc_in <morpheo::Tdcache_context_t > *** DCACHE_REQ_CONTEXT_ID ;//[nb_entity][dcache_dedicated_nb_port] |
---|
| 49 | public : sc_in <morpheo::Tdcache_packet_t > *** DCACHE_REQ_PACKET_ID ;//[nb_entity][dcache_dedicated_nb_port] |
---|
| 50 | public : sc_in <morpheo::Tdcache_address_t > *** DCACHE_REQ_ADDRESS ;//[nb_entity][dcache_dedicated_nb_port] |
---|
| 51 | public : sc_in <morpheo::Tdcache_type_t > *** DCACHE_REQ_TYPE ;//[nb_entity][dcache_dedicated_nb_port] |
---|
| 52 | public : sc_in <morpheo::Tdcache_data_t > *** DCACHE_REQ_WDATA ;//[nb_entity][dcache_dedicated_nb_port] |
---|
[81] | 53 | |
---|
[88] | 54 | public : sc_out<morpheo::Tcontrol_t > *** DCACHE_RSP_VAL ;//[nb_entity][dcache_dedicated_nb_port] |
---|
| 55 | public : sc_in <morpheo::Tcontrol_t > *** DCACHE_RSP_ACK ;//[nb_entity][dcache_dedicated_nb_port] |
---|
| 56 | public : sc_out<morpheo::Tdcache_context_t > *** DCACHE_RSP_CONTEXT_ID ;//[nb_entity][dcache_dedicated_nb_port] |
---|
| 57 | public : sc_out<morpheo::Tdcache_packet_t > *** DCACHE_RSP_PACKET_ID ;//[nb_entity][dcache_dedicated_nb_port] |
---|
| 58 | public : sc_out<morpheo::Tdcache_data_t > *** DCACHE_RSP_RDATA ;//[nb_entity][dcache_dedicated_nb_port] |
---|
| 59 | public : sc_out<morpheo::Tdcache_error_t > *** DCACHE_RSP_ERROR ;//[nb_entity][dcache_dedicated_nb_port] |
---|
[81] | 60 | |
---|
| 61 | // ===== [ Internal ]==================================================== |
---|
[88] | 62 | public : morpheo::Tcontrol_t ** icache_req_ack ; |
---|
| 63 | public : morpheo::Tcontrol_t ** icache_rsp_val ; |
---|
[128] | 64 | public : uint32_t ** icache_rsp_num ; |
---|
[88] | 65 | public : morpheo::Tcontrol_t ** dcache_req_ack ; |
---|
| 66 | public : morpheo::Tcontrol_t ** dcache_rsp_val ; |
---|
[128] | 67 | public : uint32_t ** dcache_rsp_num ; |
---|
[81] | 68 | |
---|
| 69 | // ===== [ Variables ]=================================================== |
---|
| 70 | private : const sc_module_name name; |
---|
| 71 | private : Parameters * param; |
---|
| 72 | |
---|
[88] | 73 | private : char ** read_iram; |
---|
| 74 | private : char ** read_dram; |
---|
| 75 | private : char * write_dram; |
---|
[81] | 76 | |
---|
[88] | 77 | private : bool * context_stop; // to determine which context have send the signal stop (a same thread can send many signal) |
---|
| 78 | private : uint32_t nb_context_stop; // stop the simulation when all context have send the stop signal |
---|
| 79 | |
---|
| 80 | |
---|
[81] | 81 | // ===== [ Components ]================================================== |
---|
| 82 | private : cache ::Cache * component_cache; |
---|
| 83 | private : tty ::TTY ** component_tty; |
---|
| 84 | private : ramlock::RamLock ** component_ramlock; |
---|
| 85 | private : sim2os ::Sim2OS * component_sim2os; |
---|
| 86 | private : data ::Data * component_data; |
---|
| 87 | private : queue ::Sort_Queue<irsp_t*> ** component_buffer_irsp; |
---|
| 88 | private : queue ::Sort_Queue<drsp_t*> ** component_buffer_drsp; |
---|
| 89 | |
---|
| 90 | // ===== [ Methods ]===================================================== |
---|
| 91 | |
---|
| 92 | SC_HAS_PROCESS (Environment); |
---|
| 93 | |
---|
| 94 | public : Environment (sc_module_name name, Parameters * param); |
---|
| 95 | public : ~Environment (void); |
---|
| 96 | |
---|
[88] | 97 | public : bool init (std::string section, const char * filename, const char ** list_section); |
---|
| 98 | public : void reset (void); |
---|
| 99 | public : void stop (uint32_t num_context); |
---|
| 100 | public : bool simulation_end (void); |
---|
[81] | 101 | |
---|
[88] | 102 | public : void transition (void); |
---|
| 103 | public : void genMoore (void); |
---|
[81] | 104 | |
---|
| 105 | public : friend std::ostream& operator<< (std::ostream& output, Environment &x); |
---|
| 106 | |
---|
| 107 | |
---|
| 108 | private : |
---|
| 109 | template <class T> |
---|
| 110 | void itoa (T src, char *& dest, uint32_t size) |
---|
| 111 | { |
---|
| 112 | _cout(ENVIRONMENT,"<itoa> : size : %d, ",size); |
---|
[117] | 113 | __cout(ENVIRONMENT,"src : %.8x ",static_cast<uint32_t>(src)); |
---|
| 114 | __cout(ENVIRONMENT,"dest : "); |
---|
[81] | 115 | |
---|
| 116 | for (uint32_t i=0; i<size; i++) |
---|
| 117 | { |
---|
| 118 | uint32_t j = i; |
---|
| 119 | dest [j] = (src & 0xFF); |
---|
| 120 | src >>= 8; // shift byte |
---|
| 121 | |
---|
[117] | 122 | __cout(ENVIRONMENT,"%.2x",0xff&static_cast<uint32_t>(dest [j])); |
---|
[81] | 123 | |
---|
| 124 | } |
---|
[117] | 125 | __cout(ENVIRONMENT,".\n"); |
---|
[81] | 126 | } |
---|
| 127 | |
---|
| 128 | private : |
---|
| 129 | template <class T> |
---|
| 130 | void atoi (char * src, T& dest, uint32_t size) |
---|
| 131 | { |
---|
| 132 | dest = 0; |
---|
[117] | 133 | |
---|
[81] | 134 | _cout(ENVIRONMENT,"<atoi> : size : %d, ",size); |
---|
[117] | 135 | __cout(ENVIRONMENT,"src : "); |
---|
[81] | 136 | |
---|
| 137 | for (uint32_t i=0; i<size; i++) |
---|
| 138 | { |
---|
| 139 | uint32_t j=(size)-(i)-1; |
---|
| 140 | dest <<= 8; // shift byte |
---|
| 141 | dest |= (static_cast<T>(src [j]) & 0xFF); |
---|
| 142 | |
---|
[117] | 143 | __cout(ENVIRONMENT,"%.2x",0xff&static_cast<uint32_t>(src [j])); |
---|
[81] | 144 | } |
---|
[117] | 145 | __cout(ENVIRONMENT," dest : %.8x\n",static_cast<uint32_t>(dest)); |
---|
[81] | 146 | } |
---|
| 147 | }; |
---|
| 148 | }; |
---|
| 149 | |
---|
| 150 | #endif |
---|