cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
SimAppData Class Reference

Class App Data. More...

#include <SimAppData.hpp>

Public Member Functions

 SimAppData (int datLen)
 
 SimAppData ()
 
void pushChunk (AxisApp appChunk)
 
AxisApp pullChunk ()
 
int length ()
 
int size ()
 
void clone (SimAppData &appDat)
 Clone an APP data. More...
 
void dump ()
 Dump this APP data as HEX and ASCII characters to screen. More...
 
bool writeAxisAppToFile (AxisApp &axisApp, ofstream &outFileStream)
 Dump an AxisApp chunk to a file. More...
 
bool writeToDatFile (ofstream &outFileStream)
 Dump this APP data as raw of AxisApp chunks into a file. More...
 

Detailed Description

Class App Data.

This class defines an APP data as a stream of 'AxisApp' data chunks. Such an APP data consists of a double-ended queue that is used to accumulate all these data chunks. For the 10GbE MAC, the TCP chunks are 64 bits wide.

Definition at line 53 of file SimAppData.hpp.

Constructor & Destructor Documentation

◆ SimAppData() [1/2]

SimAppData::SimAppData ( int  datLen)
inline

Definition at line 97 of file SimAppData.hpp.

97  {
98  this->myName = "SimAppData";
99  setLen(0);
100  if (datLen > 0 and datLen <= 65536) { // 64KB = 2^16)
101  int noBytes = datLen;
102  while(noBytes > 8) {
103  pushChunk(AxisApp(0x0000000000000000, 0xFF, 0));
104  noBytes -= 8;
105  }
106  pushChunk(AxisApp(0x0000000000000000, lenToLE_tKeep(noBytes), TLAST));
107  }
108  }
void pushChunk(AxisApp appChunk)
Definition: SimAppData.hpp:115
LE_tKeep lenToLE_tKeep(ap_uint< 4 > noValidBytes)
A function to set a number of '1' in an 8-bit field. It is used here to set the number of valid bytes...
Definition: nts_utils.cpp:307
AxisRaw AxisApp
Definition: nts.hpp:51
#define TLAST
Definition: AxisRaw.hpp:116
Here is the call graph for this function:

◆ SimAppData() [2/2]

SimAppData::SimAppData ( )
inline

Definition at line 109 of file SimAppData.hpp.

109  {
110  this->myName = "SimAppData";
111  this->len = 0;
112  }

Member Function Documentation

◆ clone()

void SimAppData::clone ( SimAppData appDat)
inline

Clone an APP data.

Parameters
[in]appDatA reference to the APP data to clone.

Definition at line 146 of file SimAppData.hpp.

146  {
147  AxisApp newAxisApp;
148  for (int i=0; i<appDat.appQ.size(); i++) {
149  newAxisApp = appDat.appQ[i];
150  this->appQ.push_back(newAxisApp);
151  }
152  this->setLen(appDat.getLen());
153  }

◆ dump()

void SimAppData::dump ( )
inline

Dump this APP data as HEX and ASCII characters to screen.

Definition at line 158 of file SimAppData.hpp.

158  {
159  string datStr;
160  for (int q=0; q < this->size(); q++) {
161  AxisApp axisData = this->appQ[q];
162  for (int b=7; b >= 0; b--) {
163  if (axisData.getTKeep().bit(b)) {
164  int hi = ((b*8) + 7);
165  int lo = ((b*8) + 0);
166  ap_uint<8> octet = axisData.getTData().range(hi, lo);
167  datStr += myUint8ToStrHex(octet);
168  }
169  }
170  }
171  bool endOfDat = false;
172  int i = 0;
173  int offset = 0;
174  char *ptr;
175  do {
176  string hexaStr;
177  string asciiStr;
178  for (int c=0; c < 16*2; c+=2) {
179  if (i < datStr.length()) {
180  hexaStr += datStr.substr(i, 2);
181  char ch = std::strtoul(datStr.substr(i, 2).c_str(), &ptr, 16);
182  if ((int)ch > 0x1F)
183  asciiStr += ch;
184  else
185  asciiStr += '.';
186 
187  }
188  else {
189  hexaStr += " ";
190  endOfDat = true;
191  }
192  hexaStr += " ";
193  i += 2;
194  }
195  printf("%4.4X %s %s \n", offset, hexaStr.c_str(), asciiStr.c_str());
196  offset += 16;
197  } while (not endOfDat);
198  }
tData getTData(int leHi=64 -1, int leLo=0) const
Definition: AxisRaw.hpp:191
tKeep getTKeep(int leHi=64/8-1, int leLo=0) const
Definition: AxisRaw.hpp:207
string myUint8ToStrHex(ap_uint< 8 > inputNumber)
Converts an UINT8 into a string of 2 HEX characters.
Here is the call graph for this function:

◆ length()

int SimAppData::length ( )
inline

Definition at line 133 of file SimAppData.hpp.

133  {
134  return this->len;
135  }
Here is the caller graph for this function:

◆ pullChunk()

AxisApp SimAppData::pullChunk ( )
inline

Definition at line 125 of file SimAppData.hpp.

125  {
126  AxisApp headingChunk = this->front();
127  this->pop_front();
128  setLen(getLen() - headingChunk.getLen());
129  return headingChunk;
130  }
int getLen() const
Definition: AxisRaw.hpp:411
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pushChunk()

void SimAppData::pushChunk ( AxisApp  appChunk)
inline

Definition at line 115 of file SimAppData.hpp.

115  {
116  if (this->size() > 0) {
117  // Always clear 'TLAST' bit of previous chunck
118  this->appQ[this->size()-1].setLE_TLast(0);
119  }
120  this->push_back(appChunk);
121  this->setLen(this->getLen() + appChunk.getLen());
122  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ size()

int SimAppData::size ( )
inline

Definition at line 138 of file SimAppData.hpp.

138  {
139  return this->appQ.size();
140  }
Here is the caller graph for this function:

◆ writeAxisAppToFile()

bool SimAppData::writeAxisAppToFile ( AxisApp axisApp,
ofstream &  outFileStream 
)
inline

Dump an AxisApp chunk to a file.

Parameters
[in]axisAppA pointer to the AxisApp chunk to write.
[in]outFileStreamA reference to the file stream to write.
Returns
true upon success, otherwise false.

Definition at line 206 of file SimAppData.hpp.

206  {
207  if (!outFileStream.is_open()) {
208  printError(myName, "File is not opened.\n");
209  return false;
210  }
211  outFileStream << std::uppercase;
212  outFileStream << hex << noshowbase << setfill('0') << setw(16) << axisApp.getLE_TData().to_uint64();
213  outFileStream << " ";
214  outFileStream << setw(1) << axisApp.getLE_TLast().to_int();
215  outFileStream << " ";
216  outFileStream << hex << noshowbase << setfill('0') << setw(2) << axisApp.getLE_TKeep().to_int() << "\n";
217  if (axisApp.getLE_TLast()) {
218  outFileStream << "\n";
219  }
220  return(true);
221  }
LE_tKeep getLE_TKeep(int leHi=64/8-1, int leLo=0) const
Definition: AxisRaw.hpp:264
LE_tData getLE_TData(int leHi=64 -1, int leLo=0) const
Definition: AxisRaw.hpp:260
LE_tLast getLE_TLast() const
Definition: AxisRaw.hpp:268
#define printError(callerName, format,...)
A macro to print an error message.
Definition: nts_utils.hpp:195
void uppercase(ap_uint< 32 > *pi_rank, ap_uint< 32 > *pi_size, stream< NetworkWord > &siSHL_This_Data, stream< NetworkWord > &soTHIS_Shl_Data, stream< NetworkMetaStream > &siNrc_meta, stream< NetworkMetaStream > &soNrc_meta, ap_uint< 32 > *po_rx_ports)
Main process of the Uppercase Application directives.
Definition: uppercase.cpp:335
Here is the call graph for this function:

◆ writeToDatFile()

bool SimAppData::writeToDatFile ( ofstream &  outFileStream)
inline

Dump this APP data as raw of AxisApp chunks into a file.

Parameters
[in]outFileStreamA reference to the file stream to write.
Returns
true upon success, otherwise false.

Definition at line 228 of file SimAppData.hpp.

228  {
229  for (int i=0; i < this->size(); i++) {
230  AxisApp axisApp = this->appQ[i];
231  if (not this->writeAxisAppToFile(axisApp, outFileStream)) {
232  return false;
233  }
234  }
235  return true;
236  }
bool writeAxisAppToFile(AxisApp &axisApp, ofstream &outFileStream)
Dump an AxisApp chunk to a file.
Definition: SimAppData.hpp:206
Here is the call graph for this function:

The documentation for this class was generated from the following file: