Please, help us to better know about our user community by answering the following short survey: https://forms.gle/wpyrxWi18ox9Z5ae9
scIGPMessage_if.h
Go to the documentation of this file.
1 
5 /* @author János Végh (jvegh)
6  * @bug No known bugs.
7  */
8 
9 #ifndef scIGPMessage_if_h
10 #define scIGPMessage_if_h
11 
12 //#include <iomanip> // std::setfill, std::setw
13 //#include <systemc>
14 // "tlm.h"
15 //#include "tlm_utils/simple_initiator_socket.h"
16 //#include "scIGPCB.h" //#include "scIGPfifo.h"
17 //#include "GridPoint.h"
18 //#include "scIGPMessage.h"
19 #include "scClusterBusSlave_if.h"
20 #include "scClusterBusMaster_blocking.h"
21 #include "scLatchFIFO.h"
22 #include "scGPMessagefifo.h"
23 #include "scTimedFIFO.h"
24 #include "scHThread.h"
25 
26 // These macros are used for benchmarking
27 // The work storage variable are defined as member functions, at the end
28 // Reset is done in constructor; the sum is collected and may be read in destructor
29 // The work storage also usable in derived classes
30 /*#define MAKE_TIME_BENCHMARKING // uncomment to measure the time with benchmarking macros
31 #include "MacroTimeBenchmarking.h" // Must be after the define to have its effect
32 #define SC_MAKE_TIME_BENCHMARKING // uncomment to measure the time with benchmarking macros
33 #include "MacroScTimeBenchmarking.h" // Must be after the define to have its effect
34 */
35 
36 using namespace std;
37 using namespace sc_core;
38 using namespace sc_dt;
39 
40 class scProcessor;
41 class scIGPMessage;
42 class scClusterBus;
43 class scIGPCB;
44 extern string sc_time_to_nsec_Get(const int d, const int w, sc_time T);
45 extern string DebugRoute;
46 
47 #define DEBUG_CONTRIBUTE_STRING(D,S,M) \
48  DebugRoute.append(StringOfClusterAddress_Get() +"%" +string(S).append(M));
49 
50 // Define execution time measuring macros, per module
51 // Define this anyhow; if false no code is generated
52 
53 
54 using namespace sc_core; using namespace std;
55 
109 class scIGPMessage_if : // The IGPMessage related routines
111  public sc_core::sc_module
112 {
113 public:
114 /* sc_in_clk
115  clock;
116 */ scClusterBusMaster_blocking*
117  mMaster_if;
118 
119 // std::unique_ptr< scClusterBusMaster_blocking > bus_port;
120 // sc_port<scClusterBus_blocking_if*> bus_port;
121 
122  //Channel/Submodule* definitions
123  // TLM-2 socket, defaults to 32-bits wide, base protocol
124  // TLM-2 blocking transport method
125  //virtual
126 // void ICB_b_transport(const ClusterNeighbor Index, unsigned char* data, const int size );
127 public:
128  // Constructor declaration:
129  scIGPMessage_if(sc_core::sc_module_name nm // Just the systemC name
130  ,scProcessor* Proc // The processor we belong to
131  );
132  ~scIGPMessage_if();//{}
133  SC_HAS_PROCESS(scIGPMessage_if); // We have the constructor in the .cpp file
134  // Group dealing with identification
135  // The physical ID and the corresponding mask cannot be changed
136  uint16_t
137  BusPriority_Get(void){return mBusPriority;}
138  scProcessor*
139  Processor_Get(void) { return msProcessor;}
144  virtual string
145  StringOfClusterAddress_Get(void) = 0;
146  virtual string
147  StringOfMessage_Get(scIGPMessage* Message) = 0;
148  ClusterBusStatus
149  SendClusterMessage(scIGPMessage* M);
150  ClusterBusStatus
151  ReceiveClusterMessage(scIGPMessage* M);
152  protected:
153  void
154  Reset(void);
155  // process
156  void bus_action(void);
160  void
161  ReceiveMessage_thread(void);
166  void
167  ReceiveTimedMessage_thread(void);
168  virtual void // Must be implemented in scGridPoint and scClusterBusMemorySlow
169  RouteMessage(scIGPMessage* Message) = 0; // How to forward a message in the bottom layer
170 #if 0
171  SC_GRIDPOINT_ID_TYPE
172  ID_Get(void){ return msID;}
173  SC_GRIDPOINT_MASK_TYPE
174  IDMask_Get(void){ return msMask.ID;}
175  // Directly HW-related functionality
176  void
177  Reset(void);
178 
179  void
180  ResetForParent(scGridPoint* Parent);
181  bool
182  Deallocate(void);
186  void
187  ReceiveMessage_thread(void);
188  void
189  ReceiveTimedMessage_thread(void);
190  void
191  RouteMessage(scIGPMessage* Message);
192  void
193  SendDirectMessageTo(scGridPoint* Target, scIGPMessage* Message);
194  scGridPoint*
195  Parent_Get(void) { return msParent;}
196  void
197  Parent_Set(scGridPoint *P) { msParent = P;}
198  // Implement the inter-gridpoint direct and inter-cluster bus communication
199  scIGPCB*
200  IGPCB_Get(ClusterNeighbor index)
201  {
202  assert(!(index<cm_Head || index>=cm_Broadcast));
203  return msIGPCB[index];
204  }
205  scIGPCB*
206  msIGPCB[7]; // The Inter-scGridPoint facilities from (!) Head to NW
207  SC_WORD_TYPE
208  Register_Get(int R){ return HThread_Get()->Register_Get(R);}
209  // direct Slave Interface; mainly for testing without the bus
210  bool
211  direct_read(int *data, unsigned int address);
212  bool
213  direct_write(int *data, unsigned int address);
214  bool
215  direct_read(scIGPMessage* M);
216  bool
217  direct_write(scIGPMessage* M);
218 
219  // Slave Interface, through the bus
220  ClusterBusStatus
221  read(int *data, unsigned int address){return CLUSTER_BUS_OK;}
222  ClusterBusStatus
223  write(int *data, unsigned int address){return CLUSTER_BUS_OK;}
224  ClusterBusStatus
225  read(scIGPMessage* M);
226  ClusterBusStatus
227  write(scIGPMessage* M);
228  // process
229  void bus_action(void);
230  bool
231  struct{
232  sc_core::sc_event
233 // TIMEOUT // The required timeout is over
234 // ,
235  MakeFetch, FetchReady// These event signal the begin and end of the process
236  ,TransportedToIGPCB // No dedicated method, just wait after sending the message
237  ,SIGNAL_StateBit
238  ,Msg_Reg_Received // The core received a register-type message
239  ;
240  }EVENT_GRID; //< These events are handled at gridpoint level
242 // ,NEXT // The required action is carrried ot, may take the next one
243 
244  string
245  StringOfMemoryAddress_Get(void)
246  {
247  ostringstream oss;
248  oss << "0x" << hex << std::setfill('0') << std::setw((FMEMORY_ADDRESS_WIDTH+3)/4) << msMemoryAddress << dec;
249  return oss.str();
250  }
251  // Return a hexa word dscribing the status
252  string
253  StringOfMessage_Get(scIGPMessage* Message);
254 
255  string
256  StringOfStatus_Get(void)
257  {
258  ostringstream oss;
259  oss << "0x" << hex << std::setfill('0') << std::setw(4) << mStatus << dec;
260  return oss.str();
261  }
266  string
267  StringOfClusterAddress_Get(void);
272  void
273  SIGNAL_method(void);
274  void
275  doWriteSignals(void);
276  SC_GRIDPOINT_MASK_TYPE
277  PreAllocatedMask_Get(void);
278  bool
279  PreAllocatedMask_Set(SC_GRIDPOINT_MASK_TYPE Mask);
280  void
281  ProcessMessage(scIGPMessage* Message);
282 
283 
284  void
285  PreAllocatedMaskBit_Set(scGridPoint* C, bool V=true);
286  bool
287  IsPreAllocatedFor(scGridPoint* C);
288  // Bits directly handling signals
289  uint32_t readDataMem(uint32_t addr, int size);
290 // Performance *
291  scProcessor* Processor_Get(void) { return msProcessor;}
292  void
293  HandleSuspending(void);
294 
295  scHThread*
296  HThread_Get(void) { return mHThread;}
297  void
298  MemoryAddress_Set(SC_ADDRESS_TYPE MA) { msMemoryAddress = MA;}
299  SC_ADDRESS_TYPE
300  QTOffset_Get(SC_HTHREAD_ID_TYPE H)
301  { assert((H>=0)&(H<MAX_HTHREADS)); return mHThreads[H]->QTOffset_Get();}
302  string
303  StringOfQT_Get(SC_HTHREAD_ID_TYPE H)
304  { assert((H>=0)&(H<MAX_HTHREADS)); return mHThreads[H]->StringOfQT_Get();}
305 
306  scIGPMessage*
307  CreateRegisterMessageTo(scGridPoint* To, SC_GRIDPOINT_MASK_TYPE Mask);
317  scIGPMessage*
318  CreateQtCreateMessageTo(scGridPoint* To, SC_ADDRESS_TYPE PC, SC_GRIDPOINT_MASK_TYPE Mask, SC_GRIDPOINT_MASK_TYPE BackMask);
319  scIGPMessage*
320  CreateQtKillMessageTo(scGridPoint* To);
321  scIGPMessage*
322  CreateSpecialMessageTo(scGridPoint* To, int16_t Key, int8_t RegNo, int32_t R);
323  void
324  Status_Set(uint16_t S) {mStatus = S;}
325  uint16_t
326  Status_Get(void) { return mStatus;}
328  TimedFIFO;
330  GPMessagefifo;
331  void
332  ConnectToClusterBus(scClusterBus* ClusterBus); // Connect this gridpoint to the inter-cluster bus
333  ClusterBusStatus
334  SendClusterMessage(scIGPMessage* M);
335  ClusterBusStatus
336  ReceiveClusterMessage(scIGPMessage* M);
337  scIGPMessage*
338  CreateMemoryReadMessage(unsigned int Address, int Length);
339  scIGPMessage*
340  CreateMemoryWriteMessage(unsigned int Address, int Length);
341  int32_t
342  FlagWordLength_Get(void) {return 0;}
343  bool
344  doProcessMMessage(scIGPMessage* Message);
345  virtual bool
346  doProcessQMessage(scIGPMessage* Message);
347  bool
348  doProcessRMessage(scIGPMessage* Message);
349  scIGPMessage*
350  CreateMessageTo(scGridPoint* To, IGPMessageType Type, int Length);
351  SetupMessageAddressTo(scGridPoint* GP);
352 
353  SC_GRIDPOINT_ID_TYPE
354  msID;
357  SC_ADDRESS_TYPE
358  msMemoryAddress;
359 #endif //0
360  scProcessor*
362  uint16_t
363  mStatus; // This is a status bit of the gridpoint
364  uint16_t
366  bool
367  m_lock; // It the bus is to be locked
368 }; // of scIGPMessage_if
369 
370 #endif // scIGPMessage_if
371 
scLatchFIFO.h
Function prototypes for the EMPA simulator, LatchFIFO.
cm_Broadcast
@ cm_Broadcast
All cluster members (broadcast)
Definition: Clustering.h:42
scIGPMessage_if::mBusPriority
uint16_t mBusPriority
The bus priority when the scGridPoint is master.
Definition: scIGPMessage_if.h:365
scGPMessagefifo
Definition: scGPMessagefifo.h:43
scHThread.h
Hardware threads (HThreads) for scGridPoints.
scIGPMessage
The scIGPMessage class.
Definition: scIGPMessage.h:97
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
scIGPMessage_if::TimedFIFO
scTimedIGPMessage_fifo * TimedFIFO
This stores the timed message for this gridpoint.
Definition: scIGPMessage_if.h:141
scGPMessagefifo.h
This FIFO stores temporarily the messages from other gridpoints.
ClusterNeighbor
ClusterNeighbor
The neighborship in the cluster: the members are referred to with their geographic direction.
Definition: Clustering.h:34
scGridPoint
This class implements the autonomous grid point functionality: it is a communicating GridPoint....
Definition: scGridPoint.h:127
scTimedFIFO.h
Function prototypes for the.
scClusterBusSlave_if.h
The inter-cluster bus states.
scIGPMessage_if::GPMessagefifo
scGPMessagefifo * GPMessagefifo
This stores the messages for this gridpoint.
Definition: scIGPMessage_if.h:143
scIGPMessage_if::msProcessor
scProcessor * msProcessor
Just remember where we were born.
Definition: scIGPMessage_if.h:361
IGPMessageType
The basic message types of scIGPMessage messages.
scTimedIGPMessage_fifo
The FIFO stores messages ordered by their 'delayed delivery time'.
Definition: scTimedFIFO.h:58
scIGPMessage_if
This class communication interface for scIGPMessage communication for the autonous communication func...
Definition: scIGPMessage_if.h:109