cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
test_tx_sar_table.cpp
Go to the documentation of this file.
1 
27 #include "tx_sar_table.hpp"
28 
29 
30 using namespace hls;
31 
32 struct readVerify
33 {
34  int id;
35  char fifo;
36  int exp;
37 };
38 
39 int main()
40 {
41  stream<txAppTxSarQuery> txAppReqFifo;
42  stream<txAppTxSarReply> txAppRspFifo;
43  stream<txAppTxSarPush> txAppPushFifo;
44  stream<txTxSarQuery> txReqFifo;
45  stream<txSarEntry> txRspFifo;
46  stream<rxTxSarQuery> rxQueryFifo;
47  stream<ap_uint<32> > rxRespFifo;
48 
49  txTxSarQuery txInData;
50  rxTxSarQuery rxInData;
51  sessionState outData;
52 
53  std::ifstream inputFile;
54  std::ofstream outputFile;
55 
56  /*inputFile.open("/home/dasidler/toe/hls/toe/tx_sar_table/in.dat");
57  if (!inputFile)
58  {
59  std::cout << "Error: could not open test input file." << std::endl;
60  return -1;
61  }*/
62  outputFile.open("/home/dasidler/toe/hls/toe/tx_sar_table/out.dat");
63  if (!outputFile)
64  {
65  std::cout << "Error: could not open test output file." << std::endl;
66  }
67 
68  std::string fifoTemp;
69  int sessionIDTemp;
70  char opTemp;
71  int valueTemp;
72  int exp_valueTemp;
73  int errCount = 0;
74 
75  std::vector<readVerify> reads;
76 
77  int count = 0;
78  while (count < 500)
79  {
80  if ((count % 10) == 0)
81  {
82  if (inputFile >> fifoTemp >> sessionIDTemp >> opTemp >> valueTemp >> exp_valueTemp)
83  {
84  if (fifoTemp == "TX")
85  {
86  txInData.sessionID = sessionIDTemp;
87  //txInData.recv_window = valueTemp;
88  txInData.lock = 1;
89  txInData.write = (opTemp == 'W');;
90  txReqFifo.write(txInData);
91  if (opTemp == 'R')
92  {
93  reads.push_back( (readVerify){sessionIDTemp, fifoTemp[0], exp_valueTemp});
94  }
95  }
96  else // RX
97  {
98  rxInData.sessionID = sessionIDTemp;
99  rxInData.recv_window = valueTemp;
100  rxInData.ackd = 0;
101  rxQueryFifo.write(rxInData);
102  /*if (opTemp == 'R')
103  {
104  reads.push_back((readVerify) {sessionIDTemp, fifoTemp[0], exp_valueTemp});
105  }*/
106  }
107  }
108  }
109  //tx_sar_table(txReqFifo, txRspFifo, txAppReqFifo, txAppRspFifo, rxQueryFifo);
110  tx_sar_table(rxQueryFifo, txAppReqFifo, txReqFifo, txAppPushFifo, rxRespFifo, txAppRspFifo, txRspFifo);
111  count++;
112  }
113 
114  std::vector<readVerify>::const_iterator it;
115  it = reads.begin();
116  bool readData = false;
117  txSarEntry response;
118  while (it != reads.end())
119  {
120  readData = false;
121  if (it->fifo == 'T')
122  {
123  if (!txRspFifo.empty())
124  {
125  txRspFifo.read(response);
126  readData = true;
127  }
128  }
129 
130  if (readData)
131  {
132  if (((int)response.recv_window) != it->exp)
133  {
134  outputFile << "Error at ID " << it->id << " on fifo ";
135  outputFile << it->fifo << " response value was " << response.recv_window << " instead of " << it->exp << std::endl;
136  errCount ++;
137  }
138  /*else
139  {
140  outputFile << "Success at ID " << it->id << " on fifo ";
141  outputFile << it->fifo << " response value was " << response.recv_window << " as expected." << std::endl;
142  }*/
143  it++;
144  }
145  }
146 
147  if (errCount == 0)
148  {
149  outputFile << "No errors coccured." << std::endl;
150  }
151  else
152  {
153  outputFile << errCount << " errors coccured." << std::endl;
154  }
155 }
void tx_sar_table(stream< RXeTxSarQuery > &siRXe_TxSarQry, stream< RXeTxSarReply > &soRXe_TxSarRep, stream< TXeTxSarQuery > &siTXe_TxSarQry, stream< TXeTxSarReply > &soTXe_TxSarRep, stream< TAiTxSarPush > &siTAi_PushCmd, stream< TStTxSarPush > &soTAi_PushCmd)
Tx Sar Table (TSt). Stores the data structures for managing the TCP Tx buffer and Tx sliding window.
int main()
: Tx Segmentation and re-assembly Table (TSt)