Please, help us to better know about our user community by answering the following short survey: https://forms.gle/wpyrxWi18ox9Z5ae9
scGatesProcessor.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 SCGATESPROCESSOR_H
13 #define SCGATESPROCESSOR_H
14 #include "Utils.h"
15 #include <map>
16 #include "scProcessor.h"
17 
18 #include "scClusterBus.h" //#include "scGridPoint.h"
20 //#include "scBenchmarkingHead.h" // Contains conditional compiles
21 
22 //#include "scClusterBusArbiter.h"
23 /* class scClusterBusMemoryFast;
24  class scClusterBusMemorySlow;
25  class scClusterBusArbiter;*/
26 class scSimulator;
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 /// These GridPoints of the processor denied
51  ,Allocated /// These GridPoints of the processor are allocated by another one
52  ,PreAllocated /// These GridPoints of the processor are preallocated by another one
53  ,Available /// These GridPoints are available for work
54  // This one is not a signal, just stored with the signal masks
55  ,PreAllocatedForTopology /// These GridPoints are preallocated for the processor
56  ;
57 } TopologyMask_t, *TopologyMask_Ptr;
58 */
59 
63 //typedef enum { cpt_Head, cpt_Member, cpt_Neighbor, cpt_AnyCore} CorePreference_t;
64 // These preference modes can be selected when asking for a new core
68 /*typedef enum {
69  tpt_Allocated, //!< In a core allocated for the owner of the HThread
70  tpt_Preallocated, //!< In a core preallocated for the owner of the HThread
71  tpt_Core, //!< In the same core as the owner of the HThread
72  tpt_Neighbor, //!< In a direct accessible core
73  tpt_Another, ///< Surely in another core
74  tpt_AnyThread} ThreadPreference_t;
75 
76 typedef pair<string,scGridPoint*> GridModuleItem;
77 */
78 using namespace std;
79 // The modules can be the head of the cluster, a member of a cluster, or neither (stand-alone)
80 // These are the standard offsets of the neighbors in the order of
81 // the hexagonal Cluster Grid: Head, N, NE, SE, S, SW, NW
82 
83 // Here a two-dimensional topology is assumed
109 {
110  //Port declarations
111  TopologySignalPort_t
112  msSignalPort[MAX_HTHREADS];
113  TopologySignal_t
114  msSignal[MAX_HTHREADS];
115  public:
117 // sc_in_clk
118 // clock; ///< This clock drives the bus
119 /* scClusterBus*
120  mClusterBus; ///< The inter-cluster bus
121  scClusterBusMemoryFast*
122  mClusterMemoryFast; ///< A register-like memory
123  scClusterBusArbiter*
124  mClusterBusArbiter; ///< Arbiter of the inter-cluster bus
125  scClusterBus*
126  ClusterBus_Get(void){ return mClusterBus;}
127  */
128  scGatesProcessor(sc_core::sc_module_name nm, vector<scGridPoint*> Specials, bool StandAlone);
129  SC_HAS_PROCESS(scGatesProcessor); // Will be defined in separate file
130  ~scGatesProcessor(void);
131  TopologyMask_t
132  msSignalMask[MAX_HTHREADS];
133  struct{
134  sc_core::sc_event
135  START,
136  STOP,
137  MasksChanged;
138  }EVENT_PROCESSOR;
139  void
140 Initialize_method(void);
141  void Populate(vector<scGridPoint*>& Specials);
142  void
143 Reset(void);
144  void
145 Child_Insert(scGridPoint* C);
146  void
147 Child_Remove(scGridPoint* C);
148 #if 0
149  void RefreshGUI(scGridPoint & G);
150 // void
151  // CheckIGPCBs();
152  scGridPoint*
153  ClusterHead_Get(int i)
154  { return dynamic_cast<scGridPoint*>(AbstractTopology::ClusterHead_Get(i)); }
155  scGridPoint *ByPointer_Get(scGridPoint *GP)
156  {return dynamic_cast<scGridPoint *>(GP);}
157 
158  scGridPoint* ByIndex_Get(const int X, const int Y)
159  { return dynamic_cast<scGridPoint*>(AbstractTopology::ByIndex_Get(X, Y));}
160  scGridPoint* ByPosition_Get(const int X, const int Y)
161  { return dynamic_cast<scGridPoint*>(AbstractTopology::ByPosition_Get(X, Y));}
162  scGridPoint* ByClusterAddress_Get(ClusterAddress_t CA)
163  { return dynamic_cast<scGridPoint*>(AbstractTopology::ByClusterAddress_Get(CA));}
164  scGridPoint* ClusterHeadOfMember_Get(scGridPoint* GP)
165  { return dynamic_cast<scGridPoint*>(AbstractTopology::ClusterHeadOfMember_Get(GP));}
166  scGridPoint* ByClusterMember_Get(unsigned short int CN, ClusterNeighbor CM= cm_Head)
167  { return dynamic_cast<scGridPoint*>(AbstractTopology::ByClusterMember_Get(CN,CM));}
168  scGridPoint* ByID_Get(int N) // Get a gridpoint by its ID and H
169  { return dynamic_cast<scGridPoint*>(AbstractTopology::ByID_Get(N));}
170  scGridPoint* ByIDMask_Get(SC_GRIDPOINT_MASK_TYPE Mask)
171  { return ByID_Get(MaskToID(Mask));}
172  scGridPoint* ByClusterPointer_Get(scGridPoint* GP, ClusterNeighbor N)
173  { return dynamic_cast<scGridPoint*>(AbstractTopology::ByClusterPointer_Get(GP,N));}
174  // Simple accessor functions, PC related stuff
175  scHThread* ByName_Get(string N);
176 
177  /* SC_GRIDPOINT_MASK_TYPE
178  ChildrenMask_Get(SC_HTHREAD_ID_TYPE H=0)
179  { return msChildrenMask[H];}///< Return which cores are allocated for us
180  void
181  ChildrenMask_Set(SC_GRIDPOINT_MASK_TYPE M, SC_HTHREAD_ID_TYPE H=0)
182  { msChildrenMask[H] = M;}///< Set mask of our children
183  void
184  ChildrenMaskBit_Set(scGridPoint* C); ///< Set the mask bit of the allocated cores
185  void
186  ChildrenMaskBit_Clear(scGridPoint* C); ///< Clear the mask bit of the allocated cores
187 */ void ConnectIGPCBs(void);
188  void ConnectClusterHeadsToBus(scClusterBus* Bus);
189  SC_GRIDPOINT_MASK_TYPE
190  DeniedMask_Get(SC_HTHREAD_ID_TYPE H=0) { return msSignalMask[H].Denied;}
191  void
192  DeniedMaskBit_Set(scGridPoint* GP, bool P=true);
193  SC_GRIDPOINT_MASK_TYPE
194  AllocatedMask_Get(SC_HTHREAD_ID_TYPE H=0) { return msSignalMask[H].Allocated;}
195  void
196  AllocatedMask_Set(SC_GRIDPOINT_MASK_TYPE M, SC_HTHREAD_ID_TYPE H=0) {msSignalMask[H].Allocated = M;}
197  void
198  AllocatedMaskBit_Set(scGridPoint* GP, bool P=true);
199  SC_GRIDPOINT_MASK_TYPE
200  PreAllocatedMask_Get(SC_HTHREAD_ID_TYPE H=0) { return msSignalMask[H].PreAllocated;}
201  void
202  PreAllocatedMask_Set(SC_GRIDPOINT_MASK_TYPE M, SC_HTHREAD_ID_TYPE H=0) { msSignalMask[H].PreAllocated = M;}
203  void
204  PreAllocatedMaskBit_Set(scGridPoint* GP, bool P=true);
205  SC_GRIDPOINT_MASK_TYPE
206  AvailableMask_Get(SC_HTHREAD_ID_TYPE H=0)
207  { return ~UnavailableMask_Get(H);}
208  SC_GRIDPOINT_MASK_TYPE
209  UnavailableMask_Get(SC_HTHREAD_ID_TYPE H=0);
210  string
211  StringOfMessage_Get(scIGPMessage* M);
212  string
213  StringOfRegisters_Get(scIGPMessage* M);
214  string
215  StringOfCooperation_Get(scIGPMessage* M);
216  string
217  StringOfID_Get(scHThread* H);
218  string
219  StringOfNeural_Get(scIGPMessage* M);
220  string
221  StringOfMemory_Get(scIGPMessage* M);
222  string
223  StringOfSender_Get(scIGPMessage* M);
224  string
225  StringOfReceiver_Get(scIGPMessage* M);
226  string
227  StringOfTime_Get(void){ return sc_time_to_nsec_Get();}
228  string
229  RegisterName_Get(int Index);
230  virtual scGridPoint*
231  ChildAllocateFor(scGridPoint* Parent, CorePreference_t Pref = cpt_AnyCore);
232  virtual scHThread*
233  HThreadAllocateFor(scHThread* Parent, HThreadPreference_t Pref = hpt_Any);
234  scGridPoint*
235  ChildPreAllocateFor(scGridPoint* Parent, CorePreference_t Pref = cpt_AnyCore);
236  scGridPoint*
237  ChildFindFor(scGridPoint* Parent, CorePreference_t CPT);
238 
239  int
240  ChildCount_Get(void){return mChildren.size();}
241  int
242  Child_Find(scHThread* C);
243 
244  scHThread*
245  HThreadFindFor(scHThread* Parent, HThreadPreference_t HPT);
246 
257  virtual scGridPoint*
258  doQCREATE(scGridPoint* TheParent, scGridPoint* TheChild,
259  SC_GRIDPOINT_MASK_TYPE CloneMask,
260  SC_GRIDPOINT_MASK_TYPE BackLinkMask,
261  CorePreference_t CPT);
262  virtual scHThread*
263  doReboot(SC_ADDRESS_TYPE A){ return (scHThread*)NULL;}
264 
265  string
266  StringOfClusterAddress_Get(scGridPoint* GP)
267  {
268  assert(GP);
269  return GP->StringOfClusterAddress_Get();
270  }
271  string
272  PrologString_Get(void);
273  scProcessor* Processor_Get(void)
274  { return this;}
275  SC_GRIDPOINT_MASK_TYPE
276  PreAllocatedForProcMask_Get(SC_HTHREAD_ID_TYPE H=0){ return msMask[H].PreAllocatedForTopology;}
277  // Simple accessor functions, PC related stuff
278  void
279  PreAllocatedForProcMaskBit_Set(scGridPoint* C, bool V);
280  bool
281  IsSuspended(void){ return msSuspended;}
282  void
283  SuspendedBit_Set(bool b){msSuspended = b;}
284  bool
285  Halted_Get(void) { return msHalted;}
286  void
287  Halted_Set(bool B){ msHalted = B;}
288 // uint32_t // Just for testing
289 // DWord_Get(SC_ADDRESS_TYPE Address){ return MainMemory->DWord_Get(Address);}
290 
291  virtual void
292  Reboot(void);
293  int16_t
294  InstanceCount_Get(void) {return mInstanceCount % 50;}
295  string // Return the string ID of the thread
296  StringID_Get(scHThread* H);
297  void
298  Alias_Add(string A, scHThread* HT)
299  { m_GridHThreadMap[A] = HT;}
300  scHThread*
301  HThreadByClusterAddress_Get(ClusterAddress_t CA)
302  { return ByClusterAddress_Get(CA)->HThread_Get(CA.HThread);}
303  protected:
304  void
305  SignalMaskBit_Set(SC_GRIDPOINT_MASK_TYPE &Signal, SC_GRIDPOINT_MASK_TYPE GPMask,
306  bool State, string S, SC_HTHREAD_ID_TYPE H=0);
307  void
308  START_thread(void);
309  void
310  HALT_thread(void);
311  void
312  SUSPEND_thread(void);
313  void
314  RESUME_thread(void);
315  void
316  QTERM_method(void);
317  TopologyMask_t
318  msMask[MAX_HTHREADS];
319 // SC_GRIDPOINT_MASK_TYPE
320 // msChildrenMask[MAX_HTHREADS];
321  vector<scHThread*>
322  mChildren; // HThreads are allocated for directly to processor
323  bool
324  msSuspended;
325  bool
326  msHalted;
327  uint16_t
328  mInstanceCount; // How many time was instantiated immediate QT
329  std::map <string,scHThread*>
330  m_GridHThreadMap; // Contains an ordered by object name list of modules
331 #endif // 0
332  void
333  SetMasks_method(void);
334  vector<scGridPoint*>
335  mChildren; // HThreads are allocated for directly to processor
336 };// of class scGatesProcessor
337 
338 #endif // SCGATESPROCESSOR_H
scGatesProcessor
This is a processor class comprising communicating scGridPoint classes. Comprises and handles the scG...
Definition: scGatesProcessor.h:108
AbstractTopology::ByID_Get
GridPoint * ByID_Get(const int N)
Get a gridpoint by its absolute sequence number and thread.
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.
scIGPMessage
The scIGPMessage class.
Definition: scIGPMessage.h:97
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
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
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
ClusterAddress_t
A GridPoint can be addressed also by its cluster address of type ClusterAddress_t....
Definition: Clustering.h:58
scGridPoint::StringOfClusterAddress_Get
string StringOfClusterAddress_Get(void)
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)
cm_Head
@ cm_Head
The central gridpoint.
Definition: Clustering.h:35
ClusterAddress_t::HThread
uint32_t HThread
The 'hardware thread' the module handles.
Definition: Clustering.h:59
CorePreference_t
CorePreference_t
Definition: scProcessor.h:62
scSimulator
The anchestor of all ScQt-based simulators, using EMPA bus The simulator manipulates scGridPoints,...
Definition: scSimulator.h:29
AbstractTopology::ClusterHeadOfMember_Get
GridPoint * ClusterHeadOfMember_Get(GridPoint *GP)
Return the cluster head of GridPoint GP.