[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 ; |
---|
| 64 | public : morpheo::Tcontrol_t ** dcache_req_ack ; |
---|
| 65 | public : morpheo::Tcontrol_t ** dcache_rsp_val ; |
---|
[81] | 66 | |
---|
| 67 | // ===== [ Variables ]=================================================== |
---|
| 68 | private : const sc_module_name name; |
---|
| 69 | private : Parameters * param; |
---|
| 70 | |
---|
[88] | 71 | private : char ** read_iram; |
---|
| 72 | private : char ** read_dram; |
---|
| 73 | private : char * write_dram; |
---|
[81] | 74 | |
---|
[88] | 75 | private : bool * context_stop; // to determine which context have send the signal stop (a same thread can send many signal) |
---|
| 76 | private : uint32_t nb_context_stop; // stop the simulation when all context have send the stop signal |
---|
| 77 | |
---|
| 78 | |
---|
[81] | 79 | // ===== [ Components ]================================================== |
---|
| 80 | private : cache ::Cache * component_cache; |
---|
| 81 | private : tty ::TTY ** component_tty; |
---|
| 82 | private : ramlock::RamLock ** component_ramlock; |
---|
| 83 | private : sim2os ::Sim2OS * component_sim2os; |
---|
| 84 | private : data ::Data * component_data; |
---|
| 85 | private : queue ::Sort_Queue<irsp_t*> ** component_buffer_irsp; |
---|
| 86 | private : queue ::Sort_Queue<drsp_t*> ** component_buffer_drsp; |
---|
| 87 | |
---|
| 88 | // ===== [ Methods ]===================================================== |
---|
| 89 | |
---|
| 90 | SC_HAS_PROCESS (Environment); |
---|
| 91 | |
---|
| 92 | public : Environment (sc_module_name name, Parameters * param); |
---|
| 93 | public : ~Environment (void); |
---|
| 94 | |
---|
[88] | 95 | public : bool init (std::string section, const char * filename, const char ** list_section); |
---|
| 96 | public : void reset (void); |
---|
| 97 | public : void stop (uint32_t num_context); |
---|
| 98 | public : bool simulation_end (void); |
---|
[81] | 99 | |
---|
[88] | 100 | public : void transition (void); |
---|
| 101 | public : void genMoore (void); |
---|
[81] | 102 | |
---|
| 103 | public : friend std::ostream& operator<< (std::ostream& output, Environment &x); |
---|
| 104 | |
---|
| 105 | |
---|
| 106 | private : |
---|
| 107 | template <class T> |
---|
| 108 | void itoa (T src, char *& dest, uint32_t size) |
---|
| 109 | { |
---|
| 110 | _cout(ENVIRONMENT,"<itoa> : size : %d, ",size); |
---|
[117] | 111 | __cout(ENVIRONMENT,"src : %.8x ",static_cast<uint32_t>(src)); |
---|
| 112 | __cout(ENVIRONMENT,"dest : "); |
---|
[81] | 113 | |
---|
| 114 | for (uint32_t i=0; i<size; i++) |
---|
| 115 | { |
---|
| 116 | uint32_t j = i; |
---|
| 117 | dest [j] = (src & 0xFF); |
---|
| 118 | src >>= 8; // shift byte |
---|
| 119 | |
---|
[117] | 120 | __cout(ENVIRONMENT,"%.2x",0xff&static_cast<uint32_t>(dest [j])); |
---|
[81] | 121 | |
---|
| 122 | } |
---|
[117] | 123 | __cout(ENVIRONMENT,".\n"); |
---|
[81] | 124 | } |
---|
| 125 | |
---|
| 126 | private : |
---|
| 127 | template <class T> |
---|
| 128 | void atoi (char * src, T& dest, uint32_t size) |
---|
| 129 | { |
---|
| 130 | dest = 0; |
---|
[117] | 131 | |
---|
[81] | 132 | _cout(ENVIRONMENT,"<atoi> : size : %d, ",size); |
---|
[117] | 133 | __cout(ENVIRONMENT,"src : "); |
---|
[81] | 134 | |
---|
| 135 | for (uint32_t i=0; i<size; i++) |
---|
| 136 | { |
---|
| 137 | uint32_t j=(size)-(i)-1; |
---|
| 138 | dest <<= 8; // shift byte |
---|
| 139 | dest |= (static_cast<T>(src [j]) & 0xFF); |
---|
| 140 | |
---|
[117] | 141 | __cout(ENVIRONMENT,"%.2x",0xff&static_cast<uint32_t>(src [j])); |
---|
[81] | 142 | } |
---|
[117] | 143 | __cout(ENVIRONMENT," dest : %.8x\n",static_cast<uint32_t>(dest)); |
---|
[81] | 144 | } |
---|
| 145 | }; |
---|
| 146 | }; |
---|
| 147 | |
---|
| 148 | #endif |
---|