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