Please, help us to better know about our user community by answering the following short survey: https://forms.gle/wpyrxWi18ox9Z5ae9
AbstractCore.h
Go to the documentation of this file.
1 
8 #ifndef AbstractCore_h
9 #define AbstractCore_h
10 
15 //#include "Config.h"
16 //#include "scTypes.h"
17 
18 #include "scProcessor.h"
19 //#include "scGridPoint.h"
20 #include "scClusterBusMemorySlow.h"
21 using namespace sc_core;
22 using namespace sc_dt;
23 
24 typedef SC_GRIDPOINT_ID_TYPE SC_CORE_ID_TYPE;
25 typedef SC_GRIDPOINT_MASK_TYPE SC_CORE_MASK_TYPE;
26 
27 #ifdef MEASURE_PERFORMANCE
28  #define PERFORMANCE_COUNTINSTRUCTION CountInstruction();
29  #define PERFORMANCE_COUNTMETAINSTRUCTION CountMetaInstruction();
30  #define PERFORMANCE_ADDINSTRUCTIONTIME(t) mInstructionTime +=t;
31  #define PERFORMANCE_ADDMETAINSTRUCTIONTIME(t) mMetaInstructionTime +=t;
32  #define PERFORMANCE_ADDMEMORYTIME(t) mMemoryTime +=t;
33  #define PERFORMANCE_ADDFETCHTIME(t) mFetchTime +=t;
34  #define PERFORMANCE_ADDWAITTIME(t) mWaitTime +=t;
35 #else
36  #define PERFORMANCE_COUNTINSTRUCTION
37  #define PERFORMANCE_COUNTMETAINSTRUCTION
38  #define PERFORMANCE_ADDINSTRUCTIONTIME(t)
39  #define PERFORMANCE_ADDMETAINSTRUCTIONTIME(t)
40  #define PERFORMANCE_ADDMEMORYTIME(t)
41  #define PERFORMANCE_ADDFETCHTIME(t)
42  #define PERFORMANCE_ADDWAITTIME(t)
43 #endif // MEASURE_PERFORMANCE
44 
45 
46 
47 #define USE_DEBUG_DATA_TYPES
48 
49 #ifdef USE_DEBUG_DATA_TYPES
50 typedef int32_t SC_REGISTER_TYPE;
51 typedef int SC_COOPERATION_MODE_TYPE;
52 typedef int32_t SC_REGISTER_MASK_TYPE;
53 #else
54 typedef sc_dt::sc_uint<CORE_REGISTER_BITS> SC_REGISTER_TYPE;
55 typedef sc_dt::sc_uint<COOPERATION_MODE_WIDTH> SC_COOPERATION_MODE_TYPE;
56 typedef sc_dt::sc_uint<MAX_NUMBER_OF_REGFteregicISTERS> SC_REGISTER_MASK_TYPE;
57 #endif //USE_DEBUG_DATA_TYPES
58 
59 /*
60 // These includes and structure fields are needed until made processor-independent
61 #ifdef __cplusplus
62 extern "C" {
63 #endif
64 
65 #include "isaE.h"
66 #ifdef __cplusplus
67 }
68 #endif
69 */
70 
71 #if 0
72 /* Different QT operations */
77 typedef enum {
78  Q_TERM,
79  Q_WAIT, Q_IWAIT,
80  Q_ALLOC,
81  Q_CREATE, Q_CREATER, Q_CREATET, Q_CREATEF,
82  Q_CALL, Q_MUTEX,
83 
84  Q_HALT=0xE,
85  Q_INT, Q_ERR } qt_t;
86 #endif//0
87 
88 // Type for the one-hot bitmasks
89 //typedef int SC_CORE_MASK_TYPE;
90 typedef SC_GRIDPOINT_MASK_TYPE SC_CORE_MASK_TYPE;
91 typedef int SC_REGISTER_TYPE;
92 /*// Type for the core IS type
93 // The word type used by the SystemC model
94 //typedef int SC_ADDRESS_TYPE;
95 #else
96 // Type for the one-hot bitmasks
97 typedef sc_dt::sc_uint<CORE_MASK_WIDTH> SC_CORE_MASK_TYPE;
98 typedef sc_dt::sc_uint<CORE_REGISTER_BITS> SC_REGISTER_TYPE;
99 // Type for the core IS type
100 // The word type used by the SystemC model
101 typedef sc_dt::sc_uint<COOPERATION_MODE_WIDTH> SC_COOPERATION_MODE_TYPE;
102 typedef sc_dt::sc_uint<MEMORY_ADDRESS_WIDTH> SC_ADDRESS_TYPE;
103 typedef int SC_COOPERATION_MODE_TYPE;
104 #endif
105 */
106 //#include "scIGPCB.h"
107 //#include <queue>
108 //#include <vector>
109 //#include <iostream>
110 
111 using namespace sc_core; using namespace std;
112 
113 class AbstractProcessor;
143 {
144  friend AbstractProcessor;
145  public:
157  AbstractCore(sc_core::sc_module_name nm
158  ,AbstractProcessor* Proc
159  ,const GridPoint GP
160  ,bool StandAlone
161  );
162 
163 // friend class TestY86Core;
165  ~AbstractCore(void);
166  SC_HAS_PROCESS(AbstractCore); // We have the constructor in the .cpp file
168  Processor_Get(void);
170  void
171  Reset(void);
172  virtual bool
173  IsMorphingInstructionFetched(scHThread* H){ return true;}
174  bool
177  doExecuteInstruction(scHThread* H);
178  bool
179  doFetchInstruction(scHThread* H);
180  void
181  ResetForParent(scGridPoint* Parent);// override;
182  AbstractCore*
183  AllocateFor(AbstractCore* Parent);
184  AbstractCore*
185  PreAllocateFor(AbstractCore* Parent);
186  string
189  string
190  StringOfTime_Get(void){ return sc_time_to_nsec_Get(1, 6, sc_time_stamp());}
191 
192  AbstractCore*
193  Parent_Get(void) { return dynamic_cast<AbstractCore*>(scGridPoint::Parent_Get());}
194 
195  SC_WORD_TYPE
196  RegisterValue_Get(uint8_t R, bool Performance=true);
197  void
198  RegisterValue_Set(uint8_t R, SC_WORD_TYPE V, bool Performance=true);
199  struct{
200  sc_core::sc_event
201  EXECUTEMETA,
202  FETCH,
203  FETCHEXECUTED,
204  METAEXECUTED,
205  NEXT,
206  QALLOC,
207  QCALL,
208  QCALLEXECUTED,
209  QCREATE,
210  QCREATEEXECUTED,
211  QCREATEMETA,
212  QHALT,
213  QMUTEX,
214  QWAIT,
215  QWAITMETA,
216  QWAITEXECUTED,
217  QTERMEXECUTED,
218  QTERM;
219  }EVENT_CORE;
220 
221  virtual string
222  MetaInstructionName_Get(void){ return "";}
223  virtual string
224  RegisterContentStrings_Get(SC_REGISTER_MASK_TYPE M, bool AlsoCC){return "";}
225  void
226  HandleEndOfWaiting(void);
227  bool
228  doCanTerminate( SC_CORE_MASK_TYPE Address);
229  void
230  PrepareNextInstruction(void);
231 #ifdef MEASURE_PERFORMANCE
232  uint32_t
233  InstructionCount_Get(){return mInstructionCount;}
234  uint32_t
235  MetaInstructionCount_Get(){return mMetaInstructionCount;}
236  void CountInstruction(){mInstructionCount++;}
237  void CountMetaInstruction(){mMetaInstructionCount++;}
238  sc_core::sc_time
239  InstructionTime_Get() {return mInstructionTime;}
240  sc_core::sc_time
241  MetaInstructionTime_Get(){ return mMetaInstructionTime;}
242  sc_core::sc_time
243  MemoryTime_Get(){ return mMemoryTime;}
244  sc_core::sc_time
245  FetchTime_Get(){ return mFetchTime;}
246  sc_core::sc_time
247  WaitTime_Get() {return mWaitTime;}
248 #endif //MEASURE_PERFORMANCE
249 
250 protected:
251 // void
252 // doCreateQT(scIGPMessage* MyMessage);
253  void
254  doSkipQTCode(void){}
255  void
256  NEXT_thread(void);
257  void
258  EXECUTEMETA_thread(void);
259  void
260  FETCH_thread(void);
261 
262  void
263  QHALT_thread(void);
264  void
265  QTERM_thread(void);
266  void
267  QWAIT_thread(void);
268  void
269  QCREATE_thread(void);
270  void
271  QCREATEMETA_thread(void);
272  void
273  QWAITMETA_thread(void);
274  void
275  QALLOC_thread(void);
276  void
277  QCALL_thread(void);
278  void
279  QMUTEX_thread(void);
280  virtual AbstractCore*
281  doFindHostToProcess(SC_ADDRESS_TYPE Offs, SC_GRIDPOINT_MASK_TYPE Mask)
282  { return dynamic_cast<AbstractCore*>(scGridPoint::doFindHostToProcess(Offs, Mask));}
283 
284  void
285  doExecuteMetaInstruction();
286  void
287  HandleMetaInstruction(void);
288  void
289  HandleConventionalInstruction(void);
290  void
291  TerminateExecution(void);
292 
293  void
294  FinishPrefetching(void);
298  bool
299  doQTERM(void);
300  void
301  ReleasePreAllocatedCores(void);
302 
303  void
304  doKillQT(void);
305  uint64_t
306  readInstrMem(SC_WORD_TYPE addr);
307  void
308  writeInstrMem(SC_WORD_TYPE addr, uint32_t C);
309 #ifdef MAKE_PERFORMANCE_DIAGRAM
310  sc_time
311  msAllocationBegin;
312  sc_time
313  msMetaBegin;
314 
315  sc_time
316  AllocationBegin_Get(void) { return msAllocationBegin;} // Just to record the beginning of being allocated
317  void
318  AllocationBegin_Set(sc_time T) {msAllocationBegin = T;} // Just to record the beginning of being allocated
319 #endif //MAKE_PERFORMANCE_DIAGRAM
321  msMeta; // The metainstruction fetched by the core
322 
323 // msVectorMode
324 /* void /// Make the actual inspection; overwritten in subclasses
325  doInspect(vector<int32_t>& in, vector<int32_t>& out);*/
326 /*#ifdef MEASURE_PERFORMANCE
327 public:
328  sc_time
329  FetchTime_Get(){ return mFetchTime;}
330  sc_time
331  InstructionTime_Get(){ return mInstructionTime;}
332  sc_time
333  MetaInstructionTime_Get(){ return mMetaInstructionTime;}
334  sc_time
335  WaitTime_Get(){ return mFetchTime;}
336  void
337  AddFetchTime(sc_time T){mFetchTime += T;}
338  void
339  AddInstructionTime(sc_time T){mInstructionTime += T;}
340  void
341  AddMetaInstructionTime(sc_time T){mMetaInstructionTime += T;}
342  void
343  AddWaitTime(sc_time T){mFetchTime += T;}
344  uint32_t /// Return number of conventional instructions
345  InstructionCount_Get(){return mInstructionCount;}
346  uint32_t /// Returm number of metainstructions
347  MetaInstructionCount_Get(){return mMetaInstructionCount;}
348 #endif //MEASURE_PERFORMANCE
349  */
350 #ifdef MEASURE_PERFORMANCE
351 
352  uint32_t
353  mInstructionCount,
354  mMetaInstructionCount;
355  sc_time
356  mFetchTime,
357  mInstructionTime,
358  mMemoryTime,
359  mMetaInstructionTime,
360  mWaitTime;
361 #endif //MEASURE_PERFORMANCE
362 }; // of AbstractCore
365 #endif // AbstractCore_h
366 
AbstractCore::CoreText_Get
string CoreText_Get(void)
Return the string form of the core address.
Definition: AbstractCore.h:187
GridPoint
This class handles the topological information for the modules. Provides a lot of math-only utility f...
Definition: GridPoint.h:33
MetaEvent_Transfer_Type
Instruction-execution related variables.
Definition: scGridEnumTypes.h:60
scHThread
The scHThread class.
Definition: scHThread.h:138
scProcessor.h
Function prototypes for the topology of electronic modules, placed on a die. It adds sc facilities – ...
scGridPoint
This class implements the autonomous grid point functionality: it is a communicating GridPoint....
Definition: scGridPoint.h:127
scGridPoint::StringOfClusterAddress_Get
string StringOfClusterAddress_Get(void)
AbstractCore::Parent_Get
AbstractCore * Parent_Get(void)
< Return the parent of the core
Definition: AbstractCore.h:193
AbstractProcessor
The AbstractProcessor class.
Definition: AbstractProcessor.h:35
scClusterBusMemorySlow.h
The fast ("Register") type memory.
AbstractCore
The abstract base class (i.e. must not be instantiated) of concrete processors, implementing their ge...
Definition: AbstractCore.h:142
AbstractCore::StringOfTime_Get
string StringOfTime_Get(void)
Return the time of the message.
Definition: AbstractCore.h:190