Please, help us to better know about our user community by answering the following short survey: https://forms.gle/wpyrxWi18ox9Z5ae9
scProcessor.h
Go to the documentation of this file.
1 
8  /* @author János Végh (jvegh)
9  * @bug No known bugs.
10  */
11 
12 #ifndef SCPROCESSOR_H
13 #define SCPROCESSOR_H
14 #include "Utils.h"
15 #include <map>
16 #include <QString>
17 #include "AbstractTopology.h"
18 
19 #include "scClusterBus.h" //#include "scGridPoint.h"
21 //#include "scBenchmarkingHead.h" // Contains conditional compiles
22 
23 //#include "scClusterBusArbiter.h"
26  class scClusterBusArbiter;
27  extern scClusterBusMemorySlow *MainMemory;
28 
29 typedef struct{
30  sc_in< sc_dt::sc_uint<MAX_GRIDPOINTS> >
31  Denied
32  ,Allocated
33  ,PreAllocated
34  ,Available
35  ;
36 } TopologySignalPort_t, *TopologySignalPort_Ptr;
37 
38 typedef struct{
39  sc_signal<sc_dt::sc_uint<MAX_GRIDPOINTS>>
40  Denied
41  ,Allocated
42  ,PreAllocated
43  ,Available
44  ;
45 } TopologySignal_t, *TopologySignal_Ptr;
46 
47 // The relation of the gridpoints to the topology
48 typedef struct{
49  SC_GRIDPOINT_MASK_TYPE
50  Denied
51  ,Allocated
52  ,PreAllocated
53  ,Available
54  // This one is not a signal, just stored with the signal masks
55  ,PreAllocatedForTopology
56  ;
57 } TopologyMask_t, *TopologyMask_Ptr;
58 
62 typedef enum { cpt_Head, cpt_Member, cpt_Neighbor, cpt_AnyCore} CorePreference_t;
63 // These preference modes can be selected when asking for a new core
67 typedef enum {
73  tpt_AnyThread} ThreadPreference_t;
74 
75 typedef pair<string,scGridPoint*> GridModuleItem;
76 
77 using namespace std;
78 // The modules can be the head of the cluster, a member of a cluster, or neither (stand-alone)
79 // These are the standard offsets of the neighbors in the order of
80 // the hexagonal Cluster Grid: Head, N, NE, SE, S, SW, NW
81 
82 // Here a two-dimensional topology is assumed
130 class scProcessor : public AbstractTopology, public sc_core::sc_module
131 {
132  //Port declarations
133  TopologySignalPort_t
134  msSignalPort[MAX_HTHREADS];
135  TopologySignal_t
136  msSignal[MAX_HTHREADS];
137  public:
139 // sc_in_clk
140 // clock; ///< This clock drives the bus
141  scClusterBus*
145  scClusterBusArbiter*
147  scClusterBus*
148  ClusterBus_Get(void){ return mClusterBus;}
149  scProcessor(sc_core::sc_module_name nm, vector<scGridPoint*> Specials, bool StandAlone);
150  SC_HAS_PROCESS(scProcessor); // Will be defined in separate file
151  ~scProcessor(void);
152  void RefreshGUI(scGridPoint & G);
153  void
154  Reset(void);
155 // void
156  // CheckIGPCBs();
157  scGridPoint*
158  ClusterHead_Get(int i)
159  { return dynamic_cast<scGridPoint*>(AbstractTopology::ClusterHead_Get(i)); }
161  {return dynamic_cast<scGridPoint *>(GP);}
162 
163  scGridPoint* ByIndex_Get(const int X, const int Y)
164  { return dynamic_cast<scGridPoint*>(AbstractTopology::ByIndex_Get(X, Y));}
165  scGridPoint* ByPosition_Get(const int X, const int Y)
166  { return dynamic_cast<scGridPoint*>(AbstractTopology::ByPosition_Get(X, Y));}
167  scGridPoint* ByClusterAddress_Get(ClusterAddress_t CA)
168  { return dynamic_cast<scGridPoint*>(AbstractTopology::ByClusterAddress_Get(CA));}
169  scGridPoint* ClusterHeadOfMember_Get(scGridPoint* GP)
170  { return dynamic_cast<scGridPoint*>(AbstractTopology::ClusterHeadOfMember_Get(GP));}
171  scGridPoint* ByClusterMember_Get(unsigned short int CN, ClusterNeighbor CM= cm_Head)
172  { return dynamic_cast<scGridPoint*>(AbstractTopology::ByClusterMember_Get(CN,CM));}
173  scGridPoint* ByID_Get(int N) // Get a gridpoint by its ID
174  { return dynamic_cast<scGridPoint*>(AbstractTopology::ByID_Get(N));}
175  scGridPoint* ByIDMask_Get(SC_GRIDPOINT_MASK_TYPE Mask)
176  { return ByID_Get(MaskToID(Mask));}
177  scGridPoint* ByClusterPointer_Get(scGridPoint* GP, ClusterNeighbor N)
178  { return dynamic_cast<scGridPoint*>(AbstractTopology::ByClusterPointer_Get(GP,N));}
179  // Simple accessor functions, PC related stuff
180  scHThread*
181  ByName_Get(string N);
184  /* SC_GRIDPOINT_MASK_TYPE
185  ChildrenMask_Get(SC_HTHREAD_ID_TYPE H=0)
186  { return msChildrenMask[H];}///< Return which cores are allocated for us
187  void
188  ChildrenMask_Set(SC_GRIDPOINT_MASK_TYPE M, SC_HTHREAD_ID_TYPE H=0)
189  { msChildrenMask[H] = M;}///< Set mask of our children
190  void
191  ChildrenMaskBit_Set(scGridPoint* C); ///< Set the mask bit of the allocated cores
192  void
193  ChildrenMaskBit_Clear(scGridPoint* C); ///< Clear the mask bit of the allocated cores
194 */ void Populate(vector<scGridPoint*>& Specials);
195  void ConnectIGPCBs(void);
196  void ConnectClusterHeadsToBus(scClusterBus* Bus);
197  SC_GRIDPOINT_MASK_TYPE
198  DeniedMask_Get(SC_HTHREAD_ID_TYPE H=0) { return msSignalMask[H].Denied;}
199  void
200  DeniedMaskBit_Set(scGridPoint* GP, bool P=true);
201  SC_GRIDPOINT_MASK_TYPE
202  AllocatedMask_Get(SC_HTHREAD_ID_TYPE H=0) { return msSignalMask[H].Allocated;}
203  void
204  AllocatedMask_Set(SC_GRIDPOINT_MASK_TYPE M, SC_HTHREAD_ID_TYPE H=0) {msSignalMask[H].Allocated = M;}
205  void
206  AllocatedMaskBit_Set(scGridPoint* GP, bool P=true);
207  SC_GRIDPOINT_MASK_TYPE
208  PreAllocatedMask_Get(SC_HTHREAD_ID_TYPE H=0) { return msSignalMask[H].PreAllocated;}
209  void
210  PreAllocatedMask_Set(SC_GRIDPOINT_MASK_TYPE M, SC_HTHREAD_ID_TYPE H=0) { msSignalMask[H].PreAllocated = M;}
211  void
212  PreAllocatedMaskBit_Set(scGridPoint* GP, bool P=true);
213  SC_GRIDPOINT_MASK_TYPE
214  AvailableMask_Get(SC_HTHREAD_ID_TYPE H=0)
215  { return ~UnavailableMask_Get(H);}
216  SC_GRIDPOINT_MASK_TYPE
217  UnavailableMask_Get(SC_HTHREAD_ID_TYPE H=0);
218  string
219  StringOfMessage_Get(scIGPMessage* M);
220  string
221  StringOfRegisters_Get(scIGPMessage* M);
222  string
223  StringOfCooperation_Get(scIGPMessage* M);
224  string
225  StringOfID_Get(scHThread* H);
226  string
227  StringOfNeural_Get(scIGPMessage* M);
228  string
229  StringOfMemory_Get(scIGPMessage* M);
230  string
231  StringOfSender_Get(scIGPMessage* M);
232  string
233  StringOfReceiver_Get(scIGPMessage* M);
234  string
235  StringOfTime_Get(void){ return sc_time_to_nsec_Get();}
236  string
237  RegisterName_Get(int Index);
238  virtual scGridPoint*
239  ChildAllocateFor(scGridPoint* Parent, CorePreference_t Pref = cpt_AnyCore);
240  virtual scHThread*
241  HThreadAllocateFor(scHThread* Parent, HThreadPreference_t Pref = hpt_Any);
242  scGridPoint*
243  ChildPreAllocateFor(scGridPoint* Parent, CorePreference_t Pref = cpt_AnyCore);
244  scGridPoint*
245  ChildFindFor(scGridPoint* Parent, CorePreference_t CPT);
246 
247  void
248  Child_Insert(scHThread* C);
249  void
250  Child_Remove(scHThread* C);
251  int
252  ChildCount_Get(void){return mChildren.size();}
253  int
254  Child_Find(scHThread* C);
255 
273  scHThread*
274  HThreadFindFor(scHThread* Parent, HThreadPreference_t HPT);
275 
286  virtual scGridPoint*
287  doQCREATE(scGridPoint* TheParent, scGridPoint* TheChild,
288  SC_GRIDPOINT_MASK_TYPE CloneMask,
289  SC_GRIDPOINT_MASK_TYPE BackLinkMask,
290  CorePreference_t CPT);
291  virtual scHThread*
292  doReboot(SC_ADDRESS_TYPE A){ return (scHThread*)NULL;}
293 
294 // scHThread*
295 // ByAliasName_Get(string N);
296  string
297  StringOfClusterAddress_Get(scGridPoint* GP)
298  {
299  assert(GP);
300  return GP->StringOfClusterAddress_Get();
301  }
302  struct{
303  sc_core::sc_event
304  START,
305  STOP,
306  SUSPEND,
307  RESUME,
308  HALT,
309  QTERM,
310  MasksChanged;
311  }EVENT_PROCESSOR;
312  TopologyMask_t
313  msSignalMask[MAX_HTHREADS];
314  string
315  PrologString_Get(void);
316  scProcessor* Processor_Get(void)
317  { return this;}
318  SC_GRIDPOINT_MASK_TYPE
319  PreAllocatedForProcMask_Get(SC_HTHREAD_ID_TYPE H=0){ return msMask[H].PreAllocatedForTopology;}
320  // Simple accessor functions, PC related stuff
321  void
322  PreAllocatedForProcMaskBit_Set(scGridPoint* C, bool V);
323  bool
324  IsSuspended(void){ return msSuspended;}
325  void
326  SuspendedBit_Set(bool b){msSuspended = b;}
327  bool
328  Halted_Get(void) { return msHalted;}
329  void
330  Halted_Set(bool B){ msHalted = B;}
331 // uint32_t // Just for testing
332 // DWord_Get(SC_ADDRESS_TYPE Address){ return MainMemory->DWord_Get(Address);}
333 
334  void
335  Initialize_method(void);
336  virtual void
337  Reboot(void);
338  int16_t
339  InstanceCount_Get(void) {return mInstanceCount % 50;}
340  string // Return the string ID of the thread
341  StringID_Get(scHThread* H);
342  scHThread*
343  HThreadByClusterAddress_Get(ClusterAddress_t CA)
344  { return ByClusterAddress_Get(CA)->HThread_Get(CA.HThread);}
346  bool
347  Alias_Add(string A, scHThread* HT)
348  { mAliases[A] = HT;
349  return false;}
351  bool
352  StringOfAliasName_Set(string A, scHThread *H);
357  void
358  HandleAliases(string FileName);
365  virtual void
366  ReadTheThreeLevels(QString MyGroup);
375  void
376  HandleAliasesPass(string FileName, bool Pass2);
377  void AliasesClear(void)
378  {mAliases.clear();}
379  protected:
380  void
381  SignalMaskBit_Set(SC_GRIDPOINT_MASK_TYPE &Signal, SC_GRIDPOINT_MASK_TYPE GPMask,
382  bool State, string S);
383  void
384  START_thread(void);
385  void
386  HALT_thread(void);
387  void
388  SUSPEND_thread(void);
389  void
390  RESUME_thread(void);
391  void
392  SetMasks_method(void);
393  void
394  QTERM_method(void);
395  std::map<string,scHThread*>
396  mAliases;
397  TopologyMask_t
398  msMask[MAX_HTHREADS];
399 // SC_GRIDPOINT_MASK_TYPE
400 // msChildrenMask[MAX_HTHREADS];
401  vector<scHThread*>
402  mChildren; // HThreads are allocated for directly to processor
403  bool
404  msSuspended;
405  bool
406  msHalted;
407  uint16_t
408  mInstanceCount; // How many time was instantiated immediate QT
409 };// of class scProcessor
410 
411 #endif // SCPROCESSOR_H
scProcessor::mClusterBus
scClusterBus * mClusterBus
The of processor inter-cluster bus-related signals.
Definition: scProcessor.h:142
AbstractTopology::ByID_Get
GridPoint * ByID_Get(const int N)
Get a gridpoint by its absolute sequence number and thread.
scProcessor::mClusterMemoryFast
scClusterBusMemoryFast * mClusterMemoryFast
A register-like memory.
Definition: scProcessor.h:144
AbstractTopology
Definition: AbstractTopology.h:52
AbstractTopology::ByPosition_Get
GridPoint * ByPosition_Get(int X, int Y)
Get a gridpoint by its topological position (NOT index!)
AbstractTopology::ByClusterPointer_Get
GridPoint * ByClusterPointer_Get(GridPoint *P, ClusterNeighbor CM=cm_Head)
Return the pointer corresponding to the in-cluster member CM of cluster.
AbstractTopology.h
Function prototypes for the topology of electronic module, placed on a die. It is just math,...
scIGPMessage
The scIGPMessage class.
Definition: scIGPMessage.h:97
tpt_Preallocated
@ tpt_Preallocated
In a core preallocated for the owner of the HThread.
Definition: scProcessor.h:69
scClusterBus.h
The header of the bus arbiter.
scHThread
The scHThread class.
Definition: scHThread.h:138
scProcessor
Implements a module-name alias facility (i.e., user-provided names. Given that the basic units is scH...
Definition: scProcessor.h:130
scClusterBusMemorySlow
The 'far' memory of the processor.
Definition: scClusterBusMemorySlow.h:125
scClusterBusMemoryFast
A register-type memory area per .
Definition: scClusterBusMemoryFast.h:34
AbstractTopology::ByClusterAddress_Get
GridPoint * ByClusterAddress_Get(ClusterAddress_t C)
Get a GridPoint pointer given by its ClusterAddress_t C, a specialized integer (network-like address)
HThreadPreference_t
HThreadPreference_t
Definition: scHThread.h:28
AbstractTopology::ClusterHead_Get
GridPoint * ClusterHead_Get(unsigned int N)
Return pointer to the cluster head of the Nth cluster.
Definition: AbstractTopology.h:186
ClusterNeighbor
ClusterNeighbor
The neighborship in the cluster: the members are referred to with their geographic direction.
Definition: Clustering.h:34
tpt_Another
@ tpt_Another
Surely in another core.
Definition: scProcessor.h:72
scGridPoint
This class implements the autonomous grid point functionality: it is a communicating GridPoint....
Definition: scGridPoint.h:127
ThreadPreference_t
ThreadPreference_t
Definition: scProcessor.h:67
scProcessor::ByIndex_Get
scGridPoint * ByIndex_Get(const int X, const int Y)
Get an scGridPoint by its indices.
Definition: scProcessor.h:163
ClusterAddress_t
A GridPoint can be addressed also by its cluster address of type ClusterAddress_t....
Definition: Clustering.h:58
tpt_Allocated
@ tpt_Allocated
In a core allocated for the owner of the HThread.
Definition: scProcessor.h:68
scGridPoint::StringOfClusterAddress_Get
string StringOfClusterAddress_Get(void)
scProcessor::mClusterBusArbiter
scClusterBusArbiter * mClusterBusArbiter
Arbiter of the inter-cluster bus.
Definition: scProcessor.h:146
AbstractTopology::ByClusterMember_Get
GridPoint * ByClusterMember_Get(unsigned short int CN, ClusterNeighbor CM=cm_Head, ClusterNeighbor CP=cm_Head)
AbstractTopology::ByIndex_Get
GridPoint * ByIndex_Get(const int X, const int Y)
Get a gridpoint defined by its indices (!NOT position)
tpt_Neighbor
@ tpt_Neighbor
In a direct accessible core.
Definition: scProcessor.h:71
scProcessor::ByPointer_Get
scGridPoint * ByPointer_Get(scGridPoint *GP)
Definition: scProcessor.h:160
cm_Head
@ cm_Head
The central gridpoint.
Definition: Clustering.h:35
tpt_Core
@ tpt_Core
In the same core as the owner of the HThread.
Definition: scProcessor.h:70
ClusterAddress_t::HThread
uint32_t HThread
The 'hardware thread' the module handles.
Definition: Clustering.h:59
CorePreference_t
CorePreference_t
Definition: scProcessor.h:62
AbstractTopology::ClusterHeadOfMember_Get
GridPoint * ClusterHeadOfMember_Get(GridPoint *GP)
Return the cluster head of GridPoint GP.
scProcessor::Alias_Add
bool Alias_Add(string A, scHThread *HT)
Definition: scProcessor.h:347