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