cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
tcp_app_flash

This module implements a set of TCP-oriented tests and functions. More...

Collaboration diagram for tcp_app_flash:

Files

file  tcp_app_flash.cpp
 : TCP Application Flash (TAF)
 
file  tcp_app_flash.hpp
 : TCP Application Flash (TAF)
 
file  tcp_app_flash_top.cpp
 : Top level with I/O ports for TCP Application Flash (TAF)
 
file  tcp_app_flash_top.hpp
 : Top of TCP Application Flash (TAF)
 
file  simu_tcp_app_flash_env.cpp
 : Simulation environment for the TCP Application Flash (TAF).
 
file  simu_tcp_app_flash_env.hpp
 : Simulation environment for the TCP Application Flash (TAF).
 
file  test_tcp_app_flash.cpp
 : Testbench for TCP Application Flash (TAF).
 
file  test_tcp_app_flash.hpp
 : Testbench for TCP Application Flash.
 
file  test_tcp_app_flash.cpp
 : Testbench for TCP Application Flash (TAF).
 
file  test_tcp_app_flash.hpp
 : Testbench for TCP Application Flash.
 

Macros

#define THIS_NAME   "TAF"
 
#define TRACE_OFF   0x0000
 
#define TRACE_ESF   1 << 1
 
#define TRACE_RXP   1 << 2
 
#define TRACE_TXP   1 << 3
 
#define TRACE_ALL   0xFFFF
 
#define DEBUG_LEVEL   (TRACE_OFF)
 
#define ECHO_PATH_THRU_PORT   8803
 
#define THIS_NAME   "SIM"
 
#define TRACE_OFF   0x0000
 
#define TRACE_TSs   1 << 1
 
#define TRACE_TSr   1 << 2
 
#define TRACE_TAF   1 << 3
 
#define TRACE_MMIO   1 << 4
 
#define TRACE_ALL   0xFFFF
 
#define DEBUG_LEVEL   (TRACE_OFF)
 
#define MAX_SIM_CYCLES   500
 
#define TB_GRACE_TIME   1000
 
#define STARTUP_DELAY   25
 
#define VALID   true
 
#define UNVALID   false
 
#define DONE   true
 
#define NOT_YET_DONE   false
 
#define ENABLED   (ap_uint<1>)1
 
#define DISABLED   (ap_uint<1>)0
 
#define DEFAULT_SESS_ID   42
 
#define DEFAULT_DATAGRAM_LEN   32
 
#define DEFAULT_FPGA_IP4_ADDR   0x0A0CC801
 
#define DEFAULT_FPGA_LSN_PORT   0x2263
 
#define DEFAULT_FPGA_SND_PORT   0xA263
 
#define DEFAULT_HOST_IP4_ADDR   0x0A0CC832
 
#define DEFAULT_HOST_LSN_PORT   0x80
 
#define DEFAULT_HOST_SND_PORT   0x8080
 
#define THIS_NAME   "TB_TAF"
 
#define THIS_NAME   "TB_TAF_TOP"
 

Enumerations

enum  EchoCtrl {
  ECHO_PATH_THRU = 0 , ECHO_STORE_FWD = 1 , ECHO_OFF = 2 , ECHO_PATH_THRU = 0 ,
  ECHO_STORE_FWD = 1 , ECHO_OFF = 2 , ECHO_PATH_THRU = 0 , ECHO_STORE_FWD = 1 ,
  ECHO_OFF = 2 , ECHO_PATH_THRU = 0 , ECHO_STORE_FWD = 1 , ECHO_OFF = 2 ,
  ECHO_PATH_THRU = 0 , ECHO_STORE_FWD = 1 , ECHO_OFF = 2 , ECHO_PATH_THRU = 0 ,
  ECHO_STORE_FWD = 1 , ECHO_OFF = 2 , ECHO_PATH_THRU = 0 , ECHO_STORE_FWD = 1 ,
  ECHO_OFF = 2 , ECHO_STORE_FWD = 0 , ECHO_PATH_THRU = 1 , ECHO_CTRL_DISABLED = 0 ,
  ECHO_PATH_THRU = 1 , ECHO_STORE_FWD = 2 , ECHO_OFF = 3
}
 

Functions

void pTcpEchoStoreAndForward (stream< TcpAppData > &siRXp_Data, stream< TcpSessId > &siRXp_SessId, stream< TcpDatLen > &siRXp_DatLen, stream< TcpAppData > &soTXp_Data, stream< TcpSessId > &soTXp_SessId, stream< TcpDatLen > &soTXp_DatLen)
 Echo Store and Forward (ESf) More...
 
void pTcpTxPath (stream< TcpAppData > &siEPt_Data, stream< TcpSessId > &siEPt_SessId, stream< TcpDatLen > &siEPt_DatLen, stream< TcpAppData > &siESf_Data, stream< TcpSessId > &siESf_SessId, stream< TcpDatLen > &siESf_DatLen, stream< TcpAppData > &soTSIF_Data, stream< TcpSessId > &soTSIF_SessId, stream< TcpDatLen > &soTSIF_DatLen)
 Transmit Path - From THIS to TSIF. More...
 
void pTcpRxPath (stream< TcpAppData > &siTSIF_Data, stream< TcpSessId > &siTSIF_SessId, stream< TcpDatLen > &siTSIF_DatLen, stream< TcpAppData > &soEPt_Data, stream< TcpSessId > &soEPt_SessId, stream< TcpDatLen > &soEPt_DatLen, stream< TcpAppData > &soESf_Data, stream< TcpSessId > &soESf_SessId, stream< TcpDatLen > &soESf_DatLen)
 TCP Receive Path (RXp) - From SHELL->ROLE/TSIF to THIS. More...
 
void tcp_app_flash (stream< TcpAppData > &siTSIF_Data, stream< TcpSessId > &siTSIF_SessId, stream< TcpDatLen > &siTSIF_DataLen, stream< TcpAppData > &soTSIF_Data, stream< TcpSessId > &soTSIF_SessId, stream< TcpDatLen > &soTSIF_DatLen)
 Main process of the TCP Application Flash (TAF) More...
 
void tcp_app_flash_top (stream< TcpAppData > &siTSIF_Data, stream< TcpSessId > &siTSIF_SessId, stream< TcpDatLen > &siTSIF_DatLen, stream< TcpAppData > &soTSIF_Data, stream< TcpSessId > &soTSIF_SessId, stream< TcpDatLen > &soTSIF_DatLen)
 Top of TCP Application Flash (TAF) More...
 
void stepSim ()
 Increment the simulation counter. More...
 
void increaseSimTime (unsigned int cycles)
 Increase the simulation time of the testbench. More...
 
bool pTSIF_Recv (int &nrErr, stream< TcpAppData > &siTAF_Data, stream< TcpSessId > &siTAF_SessId, stream< TcpDatLen > &siTAF_DatLen, ofstream &rawFileStream, ofstream &tcpFileStream, int &nrSegments)
 Emulate the receiving part of the TSIF process. More...
 
bool pTSIF_Send (int &nrError, stream< TcpAppData > &soTAF_Data, stream< TcpSessId > &soTAF_SessId, stream< TcpDatLen > &soTAF_DatLen, ifstream &inpFileStream, ofstream &outGoldStream, int &nrSegments)
 Emulate the sending part of the TSIF process. More...
 
void pTSIF (int &nrErr, stream< TcpAppData > &soTAF_Data, stream< TcpSessId > &soTAF_SessId, stream< TcpDatLen > &soTAF_DatLen, stream< TcpAppData > &siTAF_Data, stream< TcpSessId > &siTAF_SessId, stream< TcpDatLen > &siTAF_DatLen)
 Emulate the behavior of TSIF. More...
 
int main (int argc, char *argv[])
 Main function for the test of the TCP Application Flash (TAF). More...
 

Variables

bool gTraceEvent
 
unsigned int gSimCycCnt
 
bool gTraceEvent
 
bool gFatalError
 
unsigned int gMaxSimCycles
 
unsigned int gSimCycCnt
 
unsigned int gMaxSimCycles
 
unsigned int gSimCycCnt = 0
 
bool gTraceEvent = false
 
bool gFatalError = false
 
unsigned int gMaxSimCycles = 500 + 1000
 
unsigned int gSimCycCnt
 
unsigned int gMaxSimCycles
 
unsigned int gSimCycCnt = 0
 
bool gTraceEvent = false
 
bool gFatalError = false
 
unsigned int gMaxSimCycles = 500 + 1000
 

Detailed Description

This module implements a set of TCP-oriented tests and functions.

cFp_HelloKale / Submodules

Macro Definition Documentation

◆ DEBUG_LEVEL [1/2]

#define DEBUG_LEVEL   (TRACE_OFF)

Definition at line 67 of file tcp_app_flash.cpp.

◆ DEBUG_LEVEL [2/2]

#define DEBUG_LEVEL   (TRACE_OFF)

Definition at line 68 of file simu_tcp_app_flash_env.cpp.

◆ DEFAULT_DATAGRAM_LEN

#define DEFAULT_DATAGRAM_LEN   32

Definition at line 56 of file simu_tcp_app_flash_env.hpp.

◆ DEFAULT_FPGA_IP4_ADDR

#define DEFAULT_FPGA_IP4_ADDR   0x0A0CC801

Definition at line 64 of file simu_tcp_app_flash_env.hpp.

◆ DEFAULT_FPGA_LSN_PORT

#define DEFAULT_FPGA_LSN_PORT   0x2263

Definition at line 65 of file simu_tcp_app_flash_env.hpp.

◆ DEFAULT_FPGA_SND_PORT

#define DEFAULT_FPGA_SND_PORT   0xA263

Definition at line 66 of file simu_tcp_app_flash_env.hpp.

◆ DEFAULT_HOST_IP4_ADDR

#define DEFAULT_HOST_IP4_ADDR   0x0A0CC832

Definition at line 67 of file simu_tcp_app_flash_env.hpp.

◆ DEFAULT_HOST_LSN_PORT

#define DEFAULT_HOST_LSN_PORT   0x80

Definition at line 68 of file simu_tcp_app_flash_env.hpp.

◆ DEFAULT_HOST_SND_PORT

#define DEFAULT_HOST_SND_PORT   0x8080

Definition at line 69 of file simu_tcp_app_flash_env.hpp.

◆ DEFAULT_SESS_ID

#define DEFAULT_SESS_ID   42

Definition at line 55 of file simu_tcp_app_flash_env.hpp.

◆ DISABLED

#define DISABLED   (ap_uint<1>)0

Definition at line 53 of file simu_tcp_app_flash_env.hpp.

◆ DONE

#define DONE   true

Definition at line 49 of file simu_tcp_app_flash_env.hpp.

◆ ECHO_PATH_THRU_PORT

#define ECHO_PATH_THRU_PORT   8803

Definition at line 73 of file tcp_app_flash.hpp.

◆ ENABLED

#define ENABLED   (ap_uint<1>)1

Definition at line 52 of file simu_tcp_app_flash_env.hpp.

◆ MAX_SIM_CYCLES

#define MAX_SIM_CYCLES   500

Definition at line 44 of file simu_tcp_app_flash_env.hpp.

◆ NOT_YET_DONE

#define NOT_YET_DONE   false

Definition at line 50 of file simu_tcp_app_flash_env.hpp.

◆ STARTUP_DELAY

#define STARTUP_DELAY   25

Definition at line 46 of file simu_tcp_app_flash_env.hpp.

◆ TB_GRACE_TIME

#define TB_GRACE_TIME   1000

Definition at line 45 of file simu_tcp_app_flash_env.hpp.

◆ THIS_NAME [1/4]

#define THIS_NAME   "TAF"

Definition at line 60 of file tcp_app_flash.cpp.

◆ THIS_NAME [2/4]

#define THIS_NAME   "SIM"

HELPERS FOR THE DEBUGGING TRACES .e.g: DEBUG_LEVEL = (TRACE_TSs | TRACE_TAF)

Definition at line 60 of file simu_tcp_app_flash_env.cpp.

◆ THIS_NAME [3/4]

#define THIS_NAME   "TB_TAF"

Definition at line 51 of file test_tcp_app_flash.cpp.

◆ THIS_NAME [4/4]

#define THIS_NAME   "TB_TAF_TOP"

Definition at line 51 of file test_tcp_app_flash_top.cpp.

◆ TRACE_ALL [1/2]

#define TRACE_ALL   0xFFFF

Definition at line 66 of file tcp_app_flash.cpp.

◆ TRACE_ALL [2/2]

#define TRACE_ALL   0xFFFF

Definition at line 67 of file simu_tcp_app_flash_env.cpp.

◆ TRACE_ESF

#define TRACE_ESF   1 << 1

Definition at line 63 of file tcp_app_flash.cpp.

◆ TRACE_MMIO

#define TRACE_MMIO   1 << 4

Definition at line 66 of file simu_tcp_app_flash_env.cpp.

◆ TRACE_OFF [1/2]

#define TRACE_OFF   0x0000

Definition at line 62 of file tcp_app_flash.cpp.

◆ TRACE_OFF [2/2]

#define TRACE_OFF   0x0000

Definition at line 62 of file simu_tcp_app_flash_env.cpp.

◆ TRACE_RXP

#define TRACE_RXP   1 << 2

Definition at line 64 of file tcp_app_flash.cpp.

◆ TRACE_TAF

#define TRACE_TAF   1 << 3

Definition at line 65 of file simu_tcp_app_flash_env.cpp.

◆ TRACE_TSr

#define TRACE_TSr   1 << 2

Definition at line 64 of file simu_tcp_app_flash_env.cpp.

◆ TRACE_TSs

#define TRACE_TSs   1 << 1

Definition at line 63 of file simu_tcp_app_flash_env.cpp.

◆ TRACE_TXP

#define TRACE_TXP   1 << 3

Definition at line 65 of file tcp_app_flash.cpp.

◆ UNVALID

#define UNVALID   false

Definition at line 48 of file simu_tcp_app_flash_env.hpp.

◆ VALID

#define VALID   true

Definition at line 47 of file simu_tcp_app_flash_env.hpp.

Enumeration Type Documentation

◆ EchoCtrl

enum EchoCtrl

IMPLEMENTATION DIRECTIVES

[TAF_USE_NON_FIFO_IO] This conditional compilation directive is used to enable/disable the implementation of non-FIFO-IOs interfaces on the current toplevel function. FYI, the use of non- FIFO-IOs generates the following warning message during the C synthesis: WARNING: [HLS 200-631] Ignoring ap_ctrl_none interface for tcp_shell_if_top due to tcp_shell_if with non-FIFO I/O.

Enumerator
ECHO_PATH_THRU 
ECHO_STORE_FWD 
ECHO_OFF 
ECHO_PATH_THRU 
ECHO_STORE_FWD 
ECHO_OFF 
ECHO_PATH_THRU 
ECHO_STORE_FWD 
ECHO_OFF 
ECHO_PATH_THRU 
ECHO_STORE_FWD 
ECHO_OFF 
ECHO_PATH_THRU 
ECHO_STORE_FWD 
ECHO_OFF 
ECHO_PATH_THRU 
ECHO_STORE_FWD 
ECHO_OFF 
ECHO_PATH_THRU 
ECHO_STORE_FWD 
ECHO_OFF 
ECHO_STORE_FWD 
ECHO_PATH_THRU 
ECHO_CTRL_DISABLED 
ECHO_PATH_THRU 
ECHO_STORE_FWD 
ECHO_OFF 

Definition at line 57 of file tcp_app_flash.hpp.

57  {
58  ECHO_STORE_FWD = 0,
59  ECHO_PATH_THRU = 1
60  //[NOT-USED] ECHO_OFF = 2
61 };
@ ECHO_STORE_FWD
@ ECHO_PATH_THRU

Function Documentation

◆ increaseSimTime()

void increaseSimTime ( unsigned int  cycles)

Increase the simulation time of the testbench.

Parameters
[in]Thenumber of cycles to increase.

Definition at line 89 of file simu_tcp_app_flash_env.cpp.

89  {
90  gMaxSimCycles += cycles;
91 }
unsigned int gMaxSimCycles
Definition: test_arp.hpp:69
Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char *  argv[] 
)

Main function for the test of the TCP Application Flash (TAF).

Main function for the test of the TCP Application Flash (TAF) TOP.

Definition at line 61 of file test_tcp_app_flash.cpp.

61  {
62 
63  //------------------------------------------------------
64  //-- TESTBENCH GLOBAL VARIABLES
65  //------------------------------------------------------
66  gSimCycCnt = 0; // Simulation cycle counter as a global variable
67 
68  //------------------------------------------------------
69  //-- DUT SIGNAL INTERFACES
70  //------------------------------------------------------
71  //-- MMIO/ Configuration Interfaces
72  #if defined TAF_USE_NON_FIFO_IO
73  ap_uint<2> sMMIO_TAF_EchoCtrl;
74  #endif
75  //[NOT_USED] CmdBit sMMIO_TAF_PostSegEn;
76  //[NOT_USED] CmdBit sMMIO_TAF_CaptSegEn;
77 
78  //------------------------------------------------------
79  //-- DUT STREAM INTERFACES
80  //------------------------------------------------------
81  //-- TSIF / TCP Data Interfaces
82  stream<TcpAppData> ssTSIF_TAF_Data ("ssTSIF_TAF_Data");
83  stream<TcpSessId> ssTSIF_TAF_SessId ("ssTSIF_TAF_SessId");
84  stream<TcpDatLen> ssTSIF_TAF_DatLen ("ssTSIF_TAF_DatLen");
85  stream<TcpAppData> ssTAF_TSIF_Data ("ssTAF_TSIF_Data");
86  stream<TcpSessId> ssTAF_TSIF_SessId ("ssTAF_TSIF_SessId");
87  stream<TcpDatLen> ssTAF_TSIF_DatLen ("ssTAF_TSIF_DatLen");
88 
89  //------------------------------------------------------
90  //-- TESTBENCH VARIABLES
91  //------------------------------------------------------
92  int nrErr = 0;
93  int segCnt = 0;
94 
95  printInfo(THIS_NAME, "############################################################################\n");
96  printInfo(THIS_NAME, "## TESTBENCH 'test_tcp_app_flash' STARTS HERE ##\n");
97  printInfo(THIS_NAME, "############################################################################\n");
98  printInfo(THIS_NAME, "This testbench will be executed with the following parameters: \n");
99  for (int i=1; i<argc; i++) {
100  printInfo(THIS_NAME, "\t==> Param[%d] = %s\n", (i-1), argv[i]);
101  }
102  printf("\n\n");
103 
104  //-----------------------------------------------------
105  //-- MAIN LOOP
106  //-----------------------------------------------------
107  do {
108  //-------------------------------------------------
109  //-- EMULATE TSIF
110  //-------------------------------------------------
111  pTSIF(
112  nrErr,
113  //-- MMIO / Configuration Interfaces
114  #if defined TAF_USE_NON_FIFO_IO
115  sMMIO_TAF_EchoCtrl,
116  #endif
117  //-- TAF / TCP Data Interfaces
118  ssTSIF_TAF_Data,
119  ssTSIF_TAF_SessId,
120  ssTSIF_TAF_DatLen,
121  //-- TAF / TCP Data Interface
122  ssTAF_TSIF_Data,
123  ssTAF_TSIF_SessId,
124  ssTAF_TSIF_DatLen);
125 
126  //-------------------------------------------------
127  //-- RUN DUT
128  //-------------------------------------------------
130  #if defined TAF_USE_NON_FIFO_IO
131  //-- MMIO / Configuration Interfaces
132  sMMIO_TAF_EchoCtrl,
133  #endif
134  //-- TSIF / TCP Rx Data Interface
135  ssTSIF_TAF_Data,
136  ssTSIF_TAF_SessId,
137  ssTSIF_TAF_DatLen,
138  //-- TSIF / TCP Tx Data Interface
139  ssTAF_TSIF_Data,
140  ssTAF_TSIF_SessId,
141  ssTAF_TSIF_DatLen);
142 
143  //------------------------------------------------------
144  //-- INCREMENT SIMULATION COUNTER
145  //------------------------------------------------------
146  stepSim();
147 
148  } while ( (gSimCycCnt < gMaxSimCycles) and
149  !gFatalError and
150  (nrErr < 10) );
151 
152  //---------------------------------------------------------------
153  //-- PRINT TESTBENCH STATUS
154  //---------------------------------------------------------------
155  printf("\n\n");
156  if (argc > 1) {
157  printInfo(THIS_NAME, "This testbench was executed with the following test-file: \n");
158  printInfo(THIS_NAME, "\t==> %s\n\n", argv[1]);
159  }
160 
161  if (nrErr) {
162  printError(THIS_NAME, "###########################################################\n");
163  printError(THIS_NAME, "#### TEST BENCH FAILED : TOTAL NUMBER OF ERROR(S) = %2d ####\n", nrErr);
164  printError(THIS_NAME, "###########################################################\n\n");
165 
166  printInfo(THIS_NAME, "FYI - You may want to check for \'ERROR\' and/or \'WARNING\' alarms in the LOG file...\n\n");
167  }
168  else {
169  printInfo(THIS_NAME, "#############################################################\n");
170  printInfo(THIS_NAME, "#### SUCCESSFUL END OF TEST ####\n");
171  printInfo(THIS_NAME, "#############################################################\n");
172  }
173 
174  return(nrErr);
175 
176 }
int segCnt
Definition: tb_nal.cpp:830
bool gFatalError
Definition: tb_nal.cpp:152
void stepSim()
Increment the simulation counter.
Definition: test_arp.cpp:54
#define printError(callerName, format,...)
A macro to print an error message.
Definition: nts_utils.hpp:195
#define printInfo(callerName, format,...)
A macro to print an information message.
Definition: nts_utils.hpp:169
unsigned int gSimCycCnt
Definition: tb_nal.cpp:150
#define THIS_NAME
void tcp_app_flash(stream< TcpAppData > &siTSIF_Data, stream< TcpSessId > &siTSIF_SessId, stream< TcpDatLen > &siTSIF_DataLen, stream< TcpAppData > &soTSIF_Data, stream< TcpSessId > &soTSIF_SessId, stream< TcpDatLen > &soTSIF_DatLen)
Main process of the TCP Application Flash (TAF)
void pTSIF(int &nrErr, stream< TcpAppData > &soTAF_Data, stream< TcpSessId > &soTAF_SessId, stream< TcpDatLen > &soTAF_DatLen, stream< TcpAppData > &siTAF_Data, stream< TcpSessId > &siTAF_SessId, stream< TcpDatLen > &siTAF_DatLen)
Emulate the behavior of TSIF.
Here is the call graph for this function:

◆ pTcpEchoStoreAndForward()

void pTcpEchoStoreAndForward ( stream< TcpAppData > &  siRXp_Data,
stream< TcpSessId > &  siRXp_SessId,
stream< TcpDatLen > &  siRXp_DatLen,
stream< TcpAppData > &  soTXp_Data,
stream< TcpSessId > &  soTXp_SessId,
stream< TcpDatLen > &  soTXp_DatLen 
)

Echo Store and Forward (ESf)

Parameters
[in]siRXp_DataData stream from pTcpRxPath (RXp).
[in]siRXp_SessIdTCP session-id from [RXp].
[in]siRXp_DatLenTCP data-length from [RXp].
[out]soTXp_DataData stream to pTcpRxPath (TXp).
[out]soTXp_SessIdTCP session-id to [TXp].
[out]soTXp_DatLenTCP data-length to [TXp].

Echo incoming traffic with store and forward in DDR4. Performs a loopback between the receive and transmit ports of the same TCP connection. The echo is said to operate in "store-and-forward" mode because every received segment is stored into the DDR4 memory before being read again and sent back to the remote source.

[TODO - Implement this process as a real store-and-forward process]

Definition at line 89 of file tcp_app_flash.cpp.

96 {
97  //-- DIRECTIVES FOR THIS PROCESS -------------------------------------------
98  #pragma HLS INLINE off
99  #pragma HLS PIPELINE II=1 enable_flush
100 
101  const char *myName = concat3(THIS_NAME, "/", "ESf");
102 
103  //-- STATIC CONTROL VARIABLES (with RESET) ---------------------------------
104  static enum FsmStates { ESF_META=0, ESF_STREAM } \
105  esf_fsmState = ESF_META;
106  #pragma HLS reset variable=esf_fsmState
107  static Ly4Len esf_byteCnt;
108  #pragma HLS reset variable=esf_byteCnt
109 
110  //-- DYNAMIC VARIABLES -----------------------------------------------------
111  AxisApp currChunk;
112  TcpAppMeta tcpSessId;
113 
114  //=====================================================
115  //== PROCESS DATA FORWARDING
116  //=====================================================
117  if ( !siRXp_Data.empty() and !soTXp_Data.full() ) {
118  TcpAppData appData = siRXp_Data.read();
119  soTXp_Data.write(appData);
120  esf_byteCnt += appData.getLen();
121  if (appData.getTLast()) {
122  esf_byteCnt = 0;
123  }
124  }
125 
126  //=====================================================
127  //== PROCESS META FORWARDING
128  //=====================================================
129  if ( !siRXp_SessId.empty() and !soTXp_SessId.full() and
130  !siRXp_DatLen.empty() and !soTXp_DatLen.full() ) {
131  TcpSessId sessId = siRXp_SessId.read();
132  TcpDatLen datLen = siRXp_DatLen.read();
133  soTXp_SessId.write(sessId);
134  soTXp_DatLen.write(datLen);
135  }
136 
137 } // End of: pTcpEchoStoreAndForward()
tLast getTLast() const
Definition: AxisRaw.hpp:219
int getLen() const
Definition: AxisRaw.hpp:411
ap_uint< 16 > Ly4Len
Definition: nts_types.hpp:202
ap_uint< 16 > TcpDatLen
Definition: AxisTcp.hpp:123
#define concat3(firstCharConst, secondCharConst, thirdCharConst)
Definition: nts_utils.hpp:161
TcpSessId TcpAppMeta
Definition: nts.hpp:74
ap_uint< 16 > TcpSessId
Definition: nts_types.hpp:137
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pTcpRxPath()

void pTcpRxPath ( stream< TcpAppData > &  siTSIF_Data,
stream< TcpSessId > &  siTSIF_SessId,
stream< TcpDatLen > &  siTSIF_DatLen,
stream< TcpAppData > &  soEPt_Data,
stream< TcpSessId > &  soEPt_SessId,
stream< TcpDatLen > &  soEPt_DatLen,
stream< TcpAppData > &  soESf_Data,
stream< TcpSessId > &  soESf_SessId,
stream< TcpDatLen > &  soESf_DatLen 
)

TCP Receive Path (RXp) - From SHELL->ROLE/TSIF to THIS.

Parameters
[in]piSHL_MmioEchoCtrlConfiguration of the echo function.
[in]siTSIF_DataData segment from TcpShellInterface (TSIF).
[in]siTSIF_SessIdTCP session-id from [TSIF].
[in]siTSIF_DatLenTCP data-length from [TSIF].
[out]soEPt_DataData segment to EchoPassTrough (EPt).
[out]soEPt_SessIdTCP session-id to [EPt].
[out]soEPt_DatLenTCP data-length to [EPt].
[out]soESf_DataData segment to EchoStoreAndForward (ESf).
[out]soESF_SessIdTCP session-id to [ESf].
[out]soESF_DatLenTCP data-length to [ESf].

This Process waits for a new TCP data segment to read and forwards it to the EchoPathThrough (EPt) or the EchoStoreAndForward (ESf) process upon the setting of LSBit of the session-id (if sessId[0] --> EPt). (FYI-This function used to be performed by the 'piSHL_Mmio_EchoCtrl' bits).

Definition at line 340 of file tcp_app_flash.cpp.

353 {
354  //-- DIRECTIVES FOR THIS PROCESS -------------------------------------------
355  #pragma HLS INLINE off
356  #pragma HLS PIPELINE II=1 enable_flush
357 
358  const char *myName = concat3(THIS_NAME, "/", "RXp");
359 
360  //-- STATIC CONTROL VARIABLES (with RESET) ---------------------------------
361  static enum FsmStates { RXP_START_OF_STREAM=0, RXP_CONTINUATION_OF_STREAM } \
362  rxp_fsmState=RXP_START_OF_STREAM;
363  #pragma HLS reset variable=rxp_fsmState
364  static EchoCtrl rxp_EchoCtrl=ECHO_PATH_THRU;
365  #pragma HLS RESET variable=rxp_EchoCtrl
366 
367  //-- LOCAL VARIABLES -------------------------------------------------------
368  TcpAppData appData;
369  TcpSessId sessId;
370  TcpDatLen datLen;
371 
372  #if defined TAF_USE_NON_FIFO_IO
373  switch(piSHL_MmioEchoCtrl) {
374  case ECHO_PATH_THRU:
375  switch (rxp_fsmState ) {
376  case RXP_START_OF_STREAM:
377  //-- Read incoming metadata and forward to pEchoPathThrough
378  if ( !siTSIF_SessId.empty() and !soEPt_SessId.full() and
379  !siTSIF_DatLen.empty() and !soEPt_DatLen.full() ) {
380  siTSIF_SessId.read(sessId);
381  siTSIF_DatLen.read(datLen);
382  soEPt_SessId.write(sessId);
383  soEPt_DatLen.write(datLen);
384  rxp_fsmState = RXP_CONTINUATION_OF_STREAM;
385  }
386  break;
387  case RXP_CONTINUATION_OF_STREAM:
388  //-- Read incoming data and forward to pEchoPathThrough
389  if (!siTSIF_Data.empty() and !soEPt_Data.full()) {
390  siTSIF_Data.read(appData);
391  soEPt_Data.write(appData);
392  // Update FSM state
393  if (appData.getTLast()) {
394  rxp_fsmState = RXP_START_OF_STREAM;
395  }
396  }
397  break;
398  }
399  break;
400  case ECHO_STORE_FWD:
401  switch (rxp_fsmState ) {
402  case RXP_START_OF_STREAM:
403  //-- Read incoming metadata and forward to pTcpEchoStoreAndForward
404  if ( !siTSIF_SessId.empty() and !soESf_SessId.full() and
405  !siTSIF_DatLen.empty() and !soEPt_DatLen.full()) {
406  soESf_SessId.write(siTSIF_SessId.read());
407  soESf_DatLen.write(siTSIF_DatLen.read());
408  rxp_fsmState = RXP_CONTINUATION_OF_STREAM;
409  }
410  break;
411  case RXP_CONTINUATION_OF_STREAM:
412  //-- Read incoming data and forward to pTcpEchoStoreAndForward
413  if ( !siTSIF_Data.empty() and !soESf_Data.full()) {
414  siTSIF_Data.read(appData);
415  soESf_Data.write(appData);
416  // Update FSM state
417  if (appData.getTLast()) {
418  rxp_fsmState = RXP_START_OF_STREAM;
419  }
420  }
421  break;
422  }
423  break;
424  case ECHO_OFF:
425  default:
426  switch (rxp_fsmState ) {
427  case RXP_START_OF_STREAM:
428  // Drain and drop the TCP metadata
429  if ( !siTSIF_SessId.empty() and !siTSIF_DatLen.empty()) {
430  siTSIF_SessId.read();
431  siTSIF_DatLen.read();
432  rxp_fsmState = RXP_CONTINUATION_OF_STREAM;
433  }
434  break;
435  case RXP_CONTINUATION_OF_STREAM:
436  // Drain and drop the TCP data
437  if ( !siTSIF_Data.empty() ) {
438  siTSIF_Data.read();
439  }
440  // Always alternate between START and CONTINUATION to drain all streams
441  rxp_fsmState = RXP_START_OF_STREAM;
442  break;
443  }
444  break;
445  }
446 
518  #else
519  switch (rxp_fsmState ) {
520  case RXP_START_OF_STREAM:
521  if (!siTSIF_SessId.empty() and !siTSIF_DatLen.empty() and
522  !soEPt_SessId.full() and !soEPt_DatLen.full() and
523  !soESf_SessId.full() and !soESf_DatLen.full()) {
524  siTSIF_SessId.read(sessId);
525  siTSIF_DatLen.read(datLen);
526  if (sessId.get_bit(0)) {
527  soEPt_SessId.write(sessId);
528  soEPt_DatLen.write(datLen);
529  rxp_EchoCtrl = ECHO_PATH_THRU;
530  if (DEBUG_LEVEL & TRACE_RXP) {
531  printInfo(myName, "SessId=%d --> Forwarding segment in ECHO_PATH_THRU mode.\n", sessId.to_ushort());
532  }
533  }
534  else {
535  // Forward to pEchoStoreAndForward
536  soESf_SessId.write(sessId);
537  soESf_DatLen.write(datLen);
538  rxp_EchoCtrl = ECHO_STORE_FWD;
539  if (DEBUG_LEVEL & TRACE_RXP) {
540  printInfo(myName, "SessId=%d --> Forwarding segment in ECHO_STORE_FWD mode.\n", sessId.to_ushort());
541  }
542  }
543  rxp_fsmState = RXP_CONTINUATION_OF_STREAM;
544  }
545  break;
546  case RXP_CONTINUATION_OF_STREAM:
547  if (!siTSIF_Data.empty()) {
548  if ((rxp_EchoCtrl == ECHO_PATH_THRU) and !soEPt_Data.full()) {
549  siTSIF_Data.read(appData);
550  soEPt_Data.write(appData);
551  if (appData.getTLast()) {
552  rxp_fsmState = RXP_START_OF_STREAM;
553  }
554  }
555  else if ((rxp_EchoCtrl == ECHO_STORE_FWD) and !soESf_Data.full()) {
556  siTSIF_Data.read(appData);
557  soESf_Data.write(appData);
558  if (appData.getTLast()) {
559  rxp_fsmState = RXP_START_OF_STREAM;
560  }
561  }
562  }
563  break;
564  }
565  #endif
566 
567 } // End of: pTcpRxPath()
EchoCtrl
Definition: memtest.hpp:49
#define TRACE_RXP
#define DEBUG_LEVEL
@ ECHO_OFF
Definition: memtest.hpp:52
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pTcpTxPath()

void pTcpTxPath ( stream< TcpAppData > &  siEPt_Data,
stream< TcpSessId > &  siEPt_SessId,
stream< TcpDatLen > &  siEPt_DatLen,
stream< TcpAppData > &  siESf_Data,
stream< TcpSessId > &  siESf_SessId,
stream< TcpDatLen > &  siESf_DatLen,
stream< TcpAppData > &  soTSIF_Data,
stream< TcpSessId > &  soTSIF_SessId,
stream< TcpDatLen > &  soTSIF_DatLen 
)

Transmit Path - From THIS to TSIF.

Parameters
[in]piSHL_MmioEchoCtrlConfiguration of the echo function.
[in]siEPt_DataData from EchoPassTrough (EPt).
[in]siEPt_SessIdTCP session-id from [EPt].
[in]siEPt_DatLenTCP data-length from [EPt].
[in]siESf_DataData from EchoStoreAndForward (ESf).
[in]siESf_SessIdTCP session-id from [ESf].
[in]siESf_DatLenTCP data-length from [ESf].
[out]soTSIF_DataData to SHELL (SHL).
[out]soTSIF_SessIdTCP session-id to [SHL].
[out]soTSIF_DatLenTCP data-length to [SHL].

Definition at line 153 of file tcp_app_flash.cpp.

166 {
167  //-- DIRECTIVES FOR THIS PROCESS -------------------------------------------
168  #pragma HLS INLINE off
169  #pragma HLS PIPELINE II=1 enable_flush
170 
171  const char *myName = concat3(THIS_NAME, "/", "TXp");
172 
173  //-- STATIC CONTROL VARIABLES (with RESET) ---------------------------------
174  static enum FsmStates { TXP_START_OF_STREAM=0, TXP_CONTINUATION_OF_STREAM } \
175  txp_fsmState=TXP_START_OF_STREAM;
176  #pragma HLS RESET variable=txp_fsmState
177  static EchoCtrl txp_EchoCtrl=ECHO_PATH_THRU;
178  #pragma HLS RESET variable=txp_EchoCtrl
179 
180  //-- STATIC DATAFLOW VARIABLES ---------------------------------------------
181  static ap_uint<16> txp_msgGapSize;
182 
183  //-- DYNAMIC VARIABLES -----------------------------------------------------
184  TcpAppData appData;
185  TcpAppMeta tcpSessId;
186 
187  #if defined TAF_USE_NON_FIFO_IO
188  switch (txp_fsmState ) {
189  case TXP_START_OF_STREAM:
190  switch(piSHL_MmioEchoCtrl) {
191  case ECHO_PATH_THRU:
192  // Read session Id from pEchoPassThrough and forward to [SHL]
193  if ( !siEPt_SessId.empty() and !soTSIF_SessId.full() and
194  !siEPt_DatLen.empty() and !soTSIF_DatLen.full() ) {
195  TcpSessId sessId;
196  TcpDatLen datLen;
197  siEPt_SessId.read(sessId);
198  siEPt_DatLen.read(datLen);
199  soTSIF_SessId.write(sessId);
200  soTSIF_DatLen.write(datLen);
201  txp_fsmState = TXP_CONTINUATION_OF_STREAM;
202  }
203  break;
204  case ECHO_STORE_FWD:
205  //-- Read session Id from pTcpEchoStoreAndForward and forward to [SHL]
206  if ( !siESf_SessId.empty() and !soTSIF_SessId.full() and
207  !siESf_DatLen.empty() and !soTSIF_DatLen.full() ) {
208  TcpSessId sessId;
209  TcpDatLen datLen;
210  siESf_SessId.read(sessId);
211  siESf_DatLen.read(datLen);
212  soTSIF_SessId.write(sessId);
213  soTSIF_DatLen.write(datLen);
214  txp_fsmState = TXP_CONTINUATION_OF_STREAM;
215  }
216  break;
217  case ECHO_OFF:
218  default:
219  // Always drain and drop the session Id (if any)
220  if ( !siEPt_SessId.empty() ) {
221  siEPt_SessId.read();
222  }
223  else if ( !siESf_SessId.empty() ) {
224  siESf_SessId.read();
225  }
226  // Always drain and drop the data-length (if any)
227  if ( !siEPt_DatLen.empty() ) {
228  siEPt_DatLen.read();
229  }
230  else if ( !siESf_DatLen.empty() ) {
231  siESf_DatLen.read();
232  }
233  txp_fsmState = TXP_CONTINUATION_OF_STREAM;
234  break;
235  } // End-of: switch(piSHL_MmioEchoCtrl) {
236  break;
237  case TXP_CONTINUATION_OF_STREAM:
238  switch(piSHL_MmioEchoCtrl) {
239  case ECHO_PATH_THRU:
240  //-- Read incoming data from pEchoPathThrough and forward to [SHL]
241  if (!siEPt_Data.empty() and !soTSIF_Data.full()) {
242  siEPt_Data.read(appData);
243  soTSIF_Data.write(appData);
244  // Update FSM state
245  if (appData.getTLast()) {
246  txp_fsmState = TXP_START_OF_STREAM;
247  }
248  }
249  break;
250  case ECHO_STORE_FWD:
251  //-- Read incoming data from pTcpEchoStoreAndForward and forward to [SHL]
252  if ( !siESf_Data.empty() and !soTSIF_Data.full()) {
253  siESf_Data.read(appData);
254  soTSIF_Data.write(appData);
255  // Update FSM state
256  if (appData.getTLast()) {
257  txp_fsmState = TXP_START_OF_STREAM;
258  }
259  }
260  break;
261  case ECHO_OFF:
262  default:
263  // Always drain and drop the data streams (if any)
264  if ( !siEPt_Data.empty() ) {
265  siEPt_Data.read(appData);
266  }
267  else if ( !siESf_Data.empty() ) {
268  siESf_Data.read(appData);
269  }
270  // Always alternate between START and CONTINUATION to drain all streams
271  txp_fsmState = TXP_START_OF_STREAM;
272  break;
273  } // End-of: switch(piSHL_MmioEchoCtrl) {
274  break;
275  } // End-of: switch (txp_fsmState ) {
276  #else
277  switch (txp_fsmState ) {
278  case TXP_START_OF_STREAM:
279  if (!siEPt_SessId.empty() and !siEPt_DatLen.empty() and
280  !soTSIF_SessId.full() and !soTSIF_DatLen.full()) {
281  soTSIF_SessId.write(siEPt_SessId.read());
282  soTSIF_DatLen.write(siEPt_DatLen.read());
283  txp_EchoCtrl = ECHO_PATH_THRU;
284  txp_fsmState = TXP_CONTINUATION_OF_STREAM;
285  }
286  else if (!siESf_SessId.empty() and !siESf_DatLen.empty() and
287  !soTSIF_SessId.full() and !soTSIF_DatLen.full()) {
288  soTSIF_SessId.write(siESf_SessId.read());
289  soTSIF_DatLen.write(siESf_DatLen.read());
290  txp_EchoCtrl = ECHO_STORE_FWD;
291  txp_fsmState = TXP_CONTINUATION_OF_STREAM;
292  }
293  break;
294  case TXP_CONTINUATION_OF_STREAM:
295  if (txp_EchoCtrl == ECHO_PATH_THRU) {
296  if(!siEPt_Data.empty() and !soTSIF_Data.full()) {
297  siEPt_Data.read(appData);
298  soTSIF_Data.write(appData);
299  if (appData.getTLast()) {
300  txp_fsmState = TXP_START_OF_STREAM;
301  txp_EchoCtrl = ECHO_STORE_FWD; // Toggle
302  }
303  }
304  }
305  else {
306  if(!siESf_Data.empty() and !soTSIF_Data.full()) {
307  siESf_Data.read(appData);
308  soTSIF_Data.write(appData);
309  if (appData.getTLast()) {
310  txp_fsmState = TXP_START_OF_STREAM;
311  txp_EchoCtrl = ECHO_PATH_THRU; // Toggle
312  }
313  }
314  }
315  break;
316  } // End-of: switch (txp_fsmState ) {
317  #endif
318 
319 } // End of: pTcpTxPath()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pTSIF()

void pTSIF ( int &  nrErr,
stream< TcpAppData > &  soTAF_Data,
stream< TcpSessId > &  soTAF_SessId,
stream< TcpDatLen > &  soTAF_DatLen,
stream< TcpAppData > &  siTAF_Data,
stream< TcpSessId > &  siTAF_SessId,
stream< TcpDatLen > &  siTAF_DatLen 
)

Emulate the behavior of TSIF.

Parameters
[in/out]nrErr A ref to the error counter of the [TB].
[out]poTAF_EchoCtrlA scalar to set the ECHO mode.
[out]soTAF_DataData stream from TcpAppFlash (TAF).
[out]soTAF_SessIdTCP session-id from [TAF].
[out]soTAF_DatLenTCP data-length from [TAF].
[in]siTAF_DataData stream to [TAF].
[in]siTAF_SessIdTCP session-id to [TAF].
[in]siTAF_DatLenTCP data-length to [TAF].

Definition at line 313 of file simu_tcp_app_flash_env.cpp.

327 {
328  const char *myName = concat3(THIS_NAME, "/", "TSIF");
329 
330  //-- STATIC VARIABLES ------------------------------------------------------
331  static bool tsif_doneWithPassThroughTest1 = false;
332  static int tsif_txSegCnt = 0;
333  static int tsif_rxSegCnt = 0;
334  static int tsif_graceTime1 = 25; // Give TEST #1 some grace time to finish
335 
336  static ifstream ifSHL_Data;
337  static ofstream ofRawFile1;
338  static ofstream ofRawGold1;
339  static ofstream ofTcpFile1;
340  static ofstream ofRawFile2;
341  static ofstream ofTcpFile2;
342 
343  //-- DYNAMIC VARIABLES -----------------------------------------------------
344  bool rcSend;
345  bool rcRecv;
346  string ifSHL_DataName = "../../../../test/testVectors/siTSIF_Data.dat";
347  string ofRawFileName1 = "../../../../test/simOutFiles/soTAF_Shl_Echo_Path_Thru_Data.dat";
348  string ofRawGoldName1 = "../../../../test/simOutFiles/soTAF_Shl_Echo_Path_Thru_Data_Gold.dat";
349  string ofTcpFileName1 = "../../../../test/simOutFiles/soTAF_Shl_Echo_Path_Thru_Data.tcp";
350  string ofRawFileName2 = "../../../../test/simOutFiles/soTAF_Shl_Echo_Off_Data.dat";
351  string ofTcpFileName2 = "../../../../test/simOutFiles/soTAF_Shl_Echo_Off_Data.tcp";
352 
353  //------------------------------------------------------
354  //-- STEP-1 : RETURN IF DONE or STARTUP TIME
355  //------------------------------------------------------
356  if (tsif_doneWithPassThroughTest1) {
357  return;
358  }
359  if (gSimCycCnt < STARTUP_DELAY) {
360  return;
361  }
362 
363  //------------------------------------------------------
364  //-- STEP-2 : TEST THE PASS-THROUGH MODE
365  //------------------------------------------------------
366  if (gSimCycCnt == STARTUP_DELAY) {
367  printf("\n## PART-1 : TEST OF THE PASS-THROUGH MODE ####################\n");
368  tsif_rxSegCnt = 0;
369 
370  //-- STEP-2.0 : REMOVE PREVIOUS OUTPUT FILES
371  std::remove(ofRawFileName1.c_str());
372  std::remove(ofRawGoldName1.c_str());
373  std::remove(ofRawFileName2.c_str());
374  std::remove(ofTcpFileName1.c_str());
375  std::remove(ofTcpFileName2.c_str());
376 
377  //-- STEP-2.1 : OPEN INPUT TEST FILE #1
378  if (!ifSHL_Data.is_open()) {
379  ifSHL_Data.open (ifSHL_DataName.c_str(), ifstream::in);
380  if (!ifSHL_Data) {
381  printFatal(myName, "Could not open the input data file \'%s\'. \n", ifSHL_DataName.c_str());
382  nrErr++;
383  tsif_doneWithPassThroughTest1 = true;
384  return;
385  }
386  }
387  //-- STEP-2.2 : OPEN TWO OUTPUT DATA FILES #1
388  if (!ofRawFile1.is_open()) {
389  ofRawFile1.open (ofRawFileName1.c_str(), ofstream::out);
390  if (!ofRawFile1) {
391  printFatal(myName, "Could not open the output Raw data file \'%s\'. \n", ofRawFileName1.c_str());
392  nrErr++;
393  tsif_doneWithPassThroughTest1 = true;
394  return;
395  }
396  }
397  if (!ofRawGold1.is_open()) {
398  ofRawGold1.open (ofRawGoldName1.c_str(), ofstream::out);
399  if (!ofRawGold1) {
400  printFatal(myName, "Could not open the output Raw gold file \'%s\'. \n", ofRawGoldName1.c_str());
401  nrErr++;
402  tsif_doneWithPassThroughTest1 = true;
403  return;
404  }
405  }
406  if (!ofTcpFile1.is_open()) {
407  ofTcpFile1.open (ofTcpFileName1.c_str(), ofstream::out);
408  if (!ofTcpFile1) {
409  printFatal(myName, "Could not open the Tcp output data file \'%s\'. \n", ofTcpFileName1.c_str());
410  nrErr++;
411  tsif_doneWithPassThroughTest1 = true;
412  return;
413  }
414  }
415  }
416  else if (tsif_graceTime1) {
417  //-- STEP-2.3 : FEED THE TAF
418  rcSend = pTSIF_Send(
419  nrErr,
420  soTAF_Data,
421  soTAF_SessId,
422  soTAF_DatLen,
423  ifSHL_Data,
424  ofRawGold1,
425  tsif_txSegCnt);
426  //-- STEP-2.4 : READ FROM THE TAF
427  rcRecv = pTSIF_Recv(
428  nrErr,
429  siTAF_Data,
430  siTAF_SessId,
431  siTAF_DatLen,
432  ofRawFile1,
433  ofTcpFile1,
434  tsif_rxSegCnt);
435  //-- STEP-2.5 : CHECK IF TEST FAILED or IS FINISHED
436  if ((rcSend != OK) or (rcRecv != OK)) {
437  tsif_graceTime1--; // Give the test some grace time to finish
438  }
439  }
440 
441  //------------------------------------------------------
442  //-- STEP-3 : VERIFY THE PASS-THROUGH MODE
443  //------------------------------------------------------
444  if (tsif_graceTime1 == 0) {
445  if (ofRawFile1.tellp() != 0) {
446  int rc1 = system(("diff --brief -w " + std::string(ofRawFileName1) + " " + std::string(ofRawGoldName1) + " ").c_str());
447  if (rc1) {
448  printError(myName, "File '%s' does not match '%s'.\n", ofRawFileName1.c_str(), ofRawGoldName1.c_str());
449  nrErr += 1;
450  }
451  tsif_doneWithPassThroughTest1 = true;
452  }
453  else {
454  printError(THIS_NAME, "File \"%s\" is empty.\n", ofRawFileName1.c_str());
455  nrErr += 1;
456  }
457  //-- Closing open files
458  ifSHL_Data.close();
459  ofRawFile1.close();
460  ofRawGold1.close();
461  ofTcpFile1.close();
462  }
463 }
#define OK
Definition: nts_types.hpp:57
#define printFatal(callerName, format,...)
A macro to print a fatal error message and exit.
Definition: nts_utils.hpp:208
bool pTSIF_Send(int &nrError, stream< TcpAppData > &soTAF_Data, stream< TcpSessId > &soTAF_SessId, stream< TcpDatLen > &soTAF_DatLen, ifstream &inpFileStream, ofstream &outGoldStream, int &nrSegments)
Emulate the sending part of the TSIF process.
bool pTSIF_Recv(int &nrErr, stream< TcpAppData > &siTAF_Data, stream< TcpSessId > &siTAF_SessId, stream< TcpDatLen > &siTAF_DatLen, ofstream &rawFileStream, ofstream &tcpFileStream, int &nrSegments)
Emulate the receiving part of the TSIF process.
#define STARTUP_DELAY
out
Definition: test.py:12
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pTSIF_Recv()

bool pTSIF_Recv ( int &  nrErr,
stream< TcpAppData > &  siTAF_Data,
stream< TcpSessId > &  siTAF_SessId,
stream< TcpDatLen > &  siTAF_DatLen,
ofstream &  rawFileStream,
ofstream &  tcpFileStream,
int &  nrSegments 
)

Emulate the receiving part of the TSIF process.

Parameters
[in/out]nrError A reference to the error counter of the [TB].
[in]siTAF_DataThe data stream to read from [TAF].
[in]siTAF_SessIdTCP session-id to read from [TAF].
[in]siTAF_DatLenTCP data-length to read from [TAF].
[out]outFileStreamA ref to the a raw output file stream.
[out]outFileStreamA ref to the a tcp output file stream.
[out]nrSegmentsA ref to the counter of received segments.
Returns
OK/KO.

SIMULATION ENVIRONMENT FUNCTIONS

Definition at line 106 of file simu_tcp_app_flash_env.cpp.

114 {
115  const char *myName = concat3(THIS_NAME, "/", "TSr");
116 
117  static int tsr_startOfSegCount = 0;
118 
119  TcpAppData currChunk;
120  TcpSessId tcpSessId;
121  TcpDatLen tcpDatLen;
122 
123  // Read and drain the metadata
124  if (!siTAF_SessId.empty() and !siTAF_DatLen.empty()) {
125  siTAF_SessId.read(tcpSessId);
126  siTAF_DatLen.read(tcpDatLen);
127  tsr_startOfSegCount++;
128  if (tsr_startOfSegCount > 1) {
129  printWarn(myName, "Metadata and data streams did not arrive in expected order!\n");
130  }
131  if (DEBUG_LEVEL & TRACE_TSr) {
132  printInfo(myName, "Received SessId=%d and DatLen=%d\n",
133  tcpSessId.to_uint(), tcpDatLen.to_uint());
134  }
135  }
136  // Read and drain data stream
137  if (!siTAF_Data.empty()) {
138  siTAF_Data.read(currChunk);
139  if (DEBUG_LEVEL & TRACE_TSr) { printAxisRaw(myName, "siTAF_Data=", currChunk); }
140  if (currChunk.getTLast()) {
141  tsr_startOfSegCount--;
142  nrSegments++;
143  }
144  //-- Write data to file
145  if (!writeAxisRawToFile(currChunk, rawFileStream) or \
146  !writeAxisAppToFile(currChunk, tcpFileStream)) {
147  return KO;
148  }
149  }
150  return OK;
151 }
bool writeAxisRawToFile(AxisRaw &axisRaw, ofstream &outFileStream)
Dump an Axis raw data chunk to a file.
int writeAxisAppToFile(AxisApp &axisApp, ofstream &outFile)
Dump a TCP or UDP application data chunk into a file. The data are stored as a stream of bytes which ...
void printAxisRaw(const char *callerName, AxisRaw chunk)
Prints an Axis raw data chunk (used for debugging).
Definition: nts_utils.cpp:46
#define printWarn(callerName, format,...)
A macro to print a warning message.
Definition: nts_utils.hpp:182
#define KO
Definition: nts_types.hpp:58
#define TRACE_TSr
Here is the call graph for this function:
Here is the caller graph for this function:

◆ pTSIF_Send()

bool pTSIF_Send ( int &  nrError,
stream< TcpAppData > &  soTAF_Data,
stream< TcpSessId > &  soTAF_SessId,
stream< TcpDatLen > &  soTAF_DatLen,
ifstream &  inpFileStream,
ofstream &  outGoldStream,
int &  nrSegments 
)

Emulate the sending part of the TSIF process.

Parameters
[in/out]nrError A reference to the error counter of the [TB].
[out]soTAF_DataThe data stream to write.
[out]soTAF_SessIdTCP session-id to write.
[out]soTAF_DatLenTCP data-length to write.
[in]inpFileStreamA ref to the input file stream.
[in]outGoldStreamA ref to the a golden raw output file stream.
[out]nrSegmentsA ref to the counter of generated segments.
Returns
OK or KO upon error or end-of-file.

Definition at line 166 of file simu_tcp_app_flash_env.cpp.

174 {
175  const char *myName = concat3(THIS_NAME, "/", "TSs");
176 
177  //-- STATIC VARIABLES ------------------------------------------------------
178  static bool tss_startOfTcpSeg = true;
179  static bool tss_idlingReq = false; // Request to idle (i.e., do not feed TAF's input stream)
180  static unsigned int tss_idleCycReq = 0; // The requested number of idle cycles
181  static unsigned int tss_idleCycCnt = 0; // The count of idle cycles
182  static SimAppData tss_simAppData;
183  static TcpSessId tss_tcpSessId = DEFAULT_SESS_ID;
184 
185  //-- DYNAMIC VARIABLES -----------------------------------------------------
186  string strLine;
187  vector<string> stringVector;
188  TcpAppData currChunk;
189  char *pEnd;
190 
191  //-----------------------------------------------------
192  //-- RETURN IF IDLING IS REQUESTED
193  //-----------------------------------------------------
194  if (tss_idlingReq == true) {
195  if (tss_idleCycCnt >= tss_idleCycReq) {
196  tss_idleCycCnt = 0;
197  tss_idlingReq = false;
198  if (DEBUG_LEVEL & TRACE_TSs) {
199  printInfo(myName, "End of Tx idling phase. \n");
200  }
201  }
202  else {
203  tss_idleCycCnt++;
204  }
205  return true;
206  }
207 
208  //------------------------------------------------------
209  //-- FEED DATA STREAM
210  //------------------------------------------------------
211  if (tss_simAppData.size() != 0) {
212  if (!soTAF_Data.full()) {
213  //-- Feed TAF with a new data chunk
214  AxisApp appChunk = tss_simAppData.pullChunk();
215  soTAF_Data.write(appChunk);
216  if (DEBUG_LEVEL & TRACE_TSs) { printAxisRaw(myName, "soTAF_Data=", appChunk); }
217  increaseSimTime(1);
218  }
219  }
220  else {
221  //------------------------------------------------------
222  //-- BUILD a new DATA STREAM from FILE
223  //------------------------------------------------------
224  while (!inpFileStream.eof()) {
225  //-- Read a line from input vector file -----------
226  getline(inpFileStream, strLine);
227  if (DEBUG_LEVEL & TRACE_TSs) { printf("%s \n", strLine.c_str()); fflush(stdout); }
228  stringVector = myTokenizer(strLine, ' ');
229  if (!strLine.empty()) {
230  //-- Build a new tss_simAppData from file
231  if (stringVector[0].length() == 1) {
232  //------------------------------------------------------
233  //-- Process the command and comment lines
234  //-- FYI: A command or a comment start with a single
235  //-- character followed by a space character.
236  //------------------------------------------------------
237  if (stringVector[0] == "#") {
238  // This is a comment line.
239  continue;
240  }
241  else if (stringVector[0] == ">") {
242  // The test vector is issuing a command
243  // FYI, don't forget to return at the end of command execution.
244  if (stringVector[1] == "IDLE") {
245  // COMMAND = Request to idle for <NUM> cycles.
246  tss_idleCycReq = strtol(stringVector[2].c_str(), &pEnd, 10);
247  tss_idlingReq = true;
248  if (DEBUG_LEVEL & TRACE_TSs) {
249  printInfo(myName, "Request to idle for %d cycles. \n", tss_idleCycReq);
250  }
251  increaseSimTime(tss_idleCycReq);
252  return true;
253  }
254  if (stringVector[1] == "SET") {
255  printWarn(myName, "The 'SET' command is not yet implemented...");
256  }
257  }
258  else {
259  printFatal(myName, "Read unknown command \"%s\" from TSIF.\n", stringVector[0].c_str());
260  }
261  }
262  else {
263  AxisApp currChunk;
264  bool firstChunkFlag = true; // Axis chunk is first data chunk
265  int writtenBytes = 0;
266  do {
267  if (firstChunkFlag == false) {
268  getline(inpFileStream, strLine);
269  if (DEBUG_LEVEL & TRACE_TSs) { printf("%s \n", strLine.c_str()); fflush(stdout); }
270  stringVector = myTokenizer(strLine, ' ');
271  // Skip lines that might be commented out
272  if (stringVector[0] == "#") {
273  // This is a comment line.
274  if (DEBUG_LEVEL & TRACE_TSs) { printf("%s ", strLine.c_str()); fflush(stdout); }
275  continue;
276  }
277  }
278  firstChunkFlag = false;
279  bool rc = readAxisRawFromLine(currChunk, strLine);
280  if (rc) {
281  tss_simAppData.pushChunk(currChunk);
282  }
283  // Write current chunk to the gold file
284  rc = writeAxisRawToFile(currChunk, outGoldStream);
285  if (currChunk.getTLast()) {
286  // Send metadata to [TAF]
287  soTAF_SessId.write(TcpSessId(tss_tcpSessId));
288  soTAF_DatLen.write(TcpDatLen(tss_simAppData.length()));
289  tss_tcpSessId++;
290  return OK;
291  }
292  } while (not currChunk.getTLast());
293  }
294  }
295  }
296  }
297  return OK;
298 }
Class App Data.
Definition: SimAppData.hpp:53
int length()
Definition: SimAppData.hpp:133
void pushChunk(AxisApp appChunk)
Definition: SimAppData.hpp:115
AxisApp pullChunk()
Definition: SimAppData.hpp:125
bool readAxisRawFromLine(AxisRaw &axisRaw, string stringBuffer)
Retrieve an AxisRaw chunk from a string.
vector< string > myTokenizer(string strBuff, char delimiter)
Brakes a string into tokens by using the 'delimiter' character.
#define DEFAULT_SESS_ID
void increaseSimTime(unsigned int cycles)
Increase the simulation time of the testbench.
#define TRACE_TSs
Here is the call graph for this function:
Here is the caller graph for this function:

◆ stepSim()

void stepSim ( )

Increment the simulation counter.

SIMULATION UTILITY HELPERS

Definition at line 73 of file simu_tcp_app_flash_env.cpp.

73  {
74  gSimCycCnt++;
75  if (gTraceEvent || ((gSimCycCnt % 1000) == 0)) {
76  printInfo(THIS_NAME, "-- [@%4.4d] -----------------------------\n", gSimCycCnt);
77  gTraceEvent = false;
78  }
79  else if (0) {
80  printInfo(THIS_NAME, "------------------- [@%d] ------------\n", gSimCycCnt);
81  }
82 }
bool gTraceEvent
Definition: tb_nal.cpp:151

◆ tcp_app_flash()

void tcp_app_flash ( stream< TcpAppData > &  siTSIF_Data,
stream< TcpSessId > &  siTSIF_SessId,
stream< TcpDatLen > &  siTSIF_DataLen,
stream< TcpAppData > &  soTSIF_Data,
stream< TcpSessId > &  soTSIF_SessId,
stream< TcpDatLen > &  soTSIF_DatLen 
)

Main process of the TCP Application Flash (TAF)

Parameters
[in]piSHL_MmioEchoCtrlConfigures the echo function.
[in]siTSIF_DataTCP data stream from the SHELL [SHL].
[in]siTSIF_SessIdTCP session-id from [SHL].
[in]siTSIF_DataLenTCP data-length from [SHL].
[out]soTSIF_DataTCP data stream to [SHL].
[out]soTSIF_SessIdTCP session-id to [SHL].
[outsoTSIF_DatLen TCP data-length to [SHL].

ENTITY - TCP APPLICATION FLASH (TAF)

Definition at line 581 of file tcp_app_flash.cpp.

601 {
602 
603  //-- DIRECTIVES FOR THIS PROCESS -------------------------------------------
604  #pragma HLS DATAFLOW
605  #pragma HLS INLINE
606  #pragma HLS INTERFACE ap_ctrl_none port=return
607 
608  #if defined TAF_USE_NON_FIFO_IO
609  #pragma HLS STABLE variable=piSHL_MmioEchoCtrl
610  #endif
611 
612  //--------------------------------------------------------------------------
613  //-- LOCAL STREAMS (Sorted by the name of the modules which generate them)
614  //--------------------------------------------------------------------------
615 
616  //-- Rx Path (RXp) ---------------------------------------------------------
617  static stream<TcpAppData> ssRXpToTXp_Data ("ssRXpToTXp_Data");
618  #pragma HLS STREAM variable=ssRXpToTXp_Data depth=1024
619  static stream<TcpSessId> ssRXpToTXp_SessId ("ssRXpToTXp_SessId");
620  #pragma HLS STREAM variable=ssRXpToTXp_SessId depth=64
621  static stream<TcpDatLen> ssRXpToTXp_DatLen ("ssRXpToTXp_DatLen");
622  #pragma HLS STREAM variable=ssRXpToTXp_DatLen depth=64
623 
624  static stream<TcpAppData> ssRXpToESf_Data ("ssRXpToESf_Data");
625  #pragma HLS STREAM variable=ssRXpToESf_Data depth=2048
626  static stream<TcpSessId> ssRXpToESf_SessId ("ssRXpToESf_SessId");
627  #pragma HLS STREAM variable=ssRXpToESf_SessId depth=32
628  static stream<TcpDatLen> ssRXpToESf_DatLen ("ssRXpToESf_DatLen");
629  #pragma HLS STREAM variable=ssRXpToESf_DatLen depth=32
630 
631  //-- Echo Store and Forward (ESf) ------------------------------------------
632  static stream<TcpAppData> ssESfToTXp_Data ("ssESfToTXp_Data");
633  #pragma HLS STREAM variable=ssESfToTXp_Data depth=1024
634  static stream<TcpSessId> ssESfToTXp_SessId ("ssESfToTXp_SessId");
635  #pragma HLS STREAM variable=ssESfToTXp_SessId depth=32
636  static stream<TcpDatLen> ssESfToTXp_DatLen ("ssESfToTXp_DatLen");
637  #pragma HLS STREAM variable=ssESfToTXp_DatLen depth=32
638 
639  //-- PROCESS FUNCTIONS -----------------------------------------------------
640  //
641  // +----------+
642  // +-------->| pESf |----------+
643  // | +----------+ |
644  // | --------+ |
645  // | +--------> sEPt |---------+ |
646  // | | --------+ | |
647  // +--+--+--+--+ +--+--+--+--+
648  // | pRXp | | pTXp |
649  // +------+----+ +-----+-----+
650  // /|\ |
651  // | |
652  // | |
653  // | \|/
654  //
655  //--------------------------------------------------------------------------
656  pTcpRxPath(
657  #if defined TAF_USE_NON_FIFO_IO
658  piSHL_MmioEchoCtrl,
659  #endif
660  siTSIF_Data,
661  siTSIF_SessId,
662  siTSIF_DataLen,
663  ssRXpToTXp_Data,
664  ssRXpToTXp_SessId,
665  ssRXpToTXp_DatLen,
666  ssRXpToESf_Data,
667  ssRXpToESf_SessId,
668  ssRXpToESf_DatLen);
669 
671  ssRXpToESf_Data,
672  ssRXpToESf_SessId,
673  ssRXpToESf_DatLen,
674  ssESfToTXp_Data,
675  ssESfToTXp_SessId,
676  ssESfToTXp_DatLen);
677 
678  pTcpTxPath(
679  #if defined TAF_USE_NON_FIFO_IO
680  piSHL_MmioEchoCtrl,
681  #endif
682  ssRXpToTXp_Data,
683  ssRXpToTXp_SessId,
684  ssRXpToTXp_DatLen,
685  ssESfToTXp_Data,
686  ssESfToTXp_SessId,
687  ssESfToTXp_DatLen,
688  soTSIF_Data,
689  soTSIF_SessId,
690  soTSIF_DatLen);
691 
692 }
void pTcpTxPath(stream< TcpAppData > &siEPt_Data, stream< TcpSessId > &siEPt_SessId, stream< TcpDatLen > &siEPt_DatLen, stream< TcpAppData > &siESf_Data, stream< TcpSessId > &siESf_SessId, stream< TcpDatLen > &siESf_DatLen, stream< TcpAppData > &soTSIF_Data, stream< TcpSessId > &soTSIF_SessId, stream< TcpDatLen > &soTSIF_DatLen)
Transmit Path - From THIS to TSIF.
void pTcpRxPath(stream< TcpAppData > &siTSIF_Data, stream< TcpSessId > &siTSIF_SessId, stream< TcpDatLen > &siTSIF_DatLen, stream< TcpAppData > &soEPt_Data, stream< TcpSessId > &soEPt_SessId, stream< TcpDatLen > &soEPt_DatLen, stream< TcpAppData > &soESf_Data, stream< TcpSessId > &soESf_SessId, stream< TcpDatLen > &soESf_DatLen)
TCP Receive Path (RXp) - From SHELL->ROLE/TSIF to THIS.
void pTcpEchoStoreAndForward(stream< TcpAppData > &siRXp_Data, stream< TcpSessId > &siRXp_SessId, stream< TcpDatLen > &siRXp_DatLen, stream< TcpAppData > &soTXp_Data, stream< TcpSessId > &soTXp_SessId, stream< TcpDatLen > &soTXp_DatLen)
Echo Store and Forward (ESf)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ tcp_app_flash_top()

void tcp_app_flash_top ( stream< TcpAppData > &  siTSIF_Data,
stream< TcpSessId > &  siTSIF_SessId,
stream< TcpDatLen > &  siTSIF_DatLen,
stream< TcpAppData > &  soTSIF_Data,
stream< TcpSessId > &  soTSIF_SessId,
stream< TcpDatLen > &  soTSIF_DatLen 
)

Top of TCP Application Flash (TAF)

Parameters
[in]piSHL_MmioEchoCtrlConfigures the echo function.
[in]siTSIF_DataTCP data stream from TcpShellInterface (TSIF).
[in]siTSIF_SessIdTCP session-id from [TSIF].
[in]siTSIF_DatLenTCP data-length from [TSIF].
[out]soTSIF_DataTCP data stream to [TSIF].
[out]soTSIF_SessIdTCP session-id to [TSIF].
[outsoTSIF_DatLen TCP data-length to [TSIF].

ENTITY - TCP APPLICATION FLASH TOP (TAF_TOP)

Definition at line 114 of file tcp_app_flash_top.cpp.

133 {
134  //-- DIRECTIVES FOR THE INTERFACES -----------------------------------------
135  #pragma HLS INTERFACE ap_ctrl_none port=return
136 
137  #if defined TAF_USE_NON_FIFO_IO
138  #pragma HLS INTERFACE ap_stable register port=piSHL_MmioEchoCtrl
139  #endif
140  #pragma HLS INTERFACE axis off port=siTSIF_Data name=siTSIF_Data
141  #pragma HLS INTERFACE axis off port=siTSIF_SessId name=siTSIF_SessId
142  #pragma HLS INTERFACE axis off port=siTSIF_DatLen name=siTSIF_DatLen
143  #pragma HLS INTERFACE axis off port=soTSIF_Data name=soTSIF_Data
144  #pragma HLS INTERFACE axis off port=soTSIF_SessId name=soTSIF_SessId
145  #pragma HLS INTERFACE axis off port=soTSIF_DatLen name=soTSIF_DatLen
146 
147  //-- DIRECTIVES FOR THIS PROCESS -------------------------------------------
148  #if HLS_VERSION == 2017
149  #pragma HLS DATAFLOW
150  #else
151  #pragma HLS DATAFLOW disable_start_propagation
152  #endif
153 
154  //-- INSTANTIATE TOPLEVEL --------------------------------------------------
155  tcp_app_flash (
156  //-- SHELL / MMIO / Configuration Interfaces
157  #if defined TAF_USE_NON_FIFO_IO
158  piSHL_MmioEchoCtrl,
159  #endif
160  //-- SHELL / TCP Rx Data Interface
161  siTSIF_Data,
162  siTSIF_SessId,
163  siTSIF_DatLen,
164  //-- SHELL / TCP Tx Data Interface
165  soTSIF_Data,
166  soTSIF_SessId,
167  soTSIF_DatLen);
168 
169 }
Here is the call graph for this function:

Variable Documentation

◆ gFatalError [1/3]

bool gFatalError
extern

Definition at line 152 of file tb_nal.cpp.

◆ gFatalError [2/3]

bool gFatalError = false

Definition at line 43 of file test_tcp_app_flash.hpp.

◆ gFatalError [3/3]

bool gFatalError = false

Definition at line 43 of file test_tcp_app_flash_top.hpp.

◆ gMaxSimCycles [1/5]

unsigned int gMaxSimCycles
extern

Definition at line 69 of file test_arp.hpp.

◆ gMaxSimCycles [2/5]

unsigned int gMaxSimCycles
extern

Definition at line 69 of file test_arp.hpp.

◆ gMaxSimCycles [3/5]

unsigned int gMaxSimCycles = 500 + 1000

Definition at line 44 of file test_tcp_app_flash.hpp.

◆ gMaxSimCycles [4/5]

unsigned int gMaxSimCycles
extern

Definition at line 69 of file test_arp.hpp.

◆ gMaxSimCycles [5/5]

unsigned int gMaxSimCycles = 500 + 1000

Definition at line 44 of file test_tcp_app_flash_top.hpp.

◆ gSimCycCnt [1/5]

unsigned int gSimCycCnt
extern

GLOBAL VARIABLES USED BY THE SIMULATION ENVIRONMENT

Definition at line 150 of file tb_nal.cpp.

◆ gSimCycCnt [2/5]

unsigned int gSimCycCnt
extern

GLOBAL VARIABLES USED BY THE SIMULATION ENVIRONMENT

Definition at line 150 of file tb_nal.cpp.

◆ gSimCycCnt [3/5]

unsigned int gSimCycCnt = 0

GLOBAL VARIABLES USED BY THE SIMULATION ENVIRONMENT

Definition at line 41 of file test_tcp_app_flash.hpp.

◆ gSimCycCnt [4/5]

unsigned int gSimCycCnt
extern

GLOBAL VARIABLES USED BY THE SIMULATION ENVIRONMENT

Definition at line 150 of file tb_nal.cpp.

◆ gSimCycCnt [5/5]

unsigned int gSimCycCnt = 0

GLOBAL VARIABLES USED BY THE SIMULATION ENVIRONMENT

Definition at line 41 of file test_tcp_app_flash_top.hpp.

◆ gTraceEvent [1/4]

bool gTraceEvent
extern

HELPERS FOR THE DEBUGGING TRACES .e.g: DEBUG_LEVEL = (TRACE_RXP | TRACE_TXP)

HELPERS FOR THE DEBUGGING TRACES .e.g: DEBUG_LEVEL = (MDL_TRACE | IPS_TRACE)

Definition at line 151 of file tb_nal.cpp.

◆ gTraceEvent [2/4]

bool gTraceEvent
extern

HELPERS FOR THE DEBUGGING TRACES .e.g: DEBUG_LEVEL = (MDL_TRACE | IPS_TRACE)

Definition at line 151 of file tb_nal.cpp.

◆ gTraceEvent [3/4]

bool gTraceEvent = false

HELPERS FOR THE DEBUGGING TRACES .e.g: DEBUG_LEVEL = (MDL_TRACE | IPS_TRACE)

Definition at line 42 of file test_tcp_app_flash.hpp.

◆ gTraceEvent [4/4]

bool gTraceEvent = false

HELPERS FOR THE DEBUGGING TRACES .e.g: DEBUG_LEVEL = (MDL_TRACE | IPS_TRACE)

Definition at line 42 of file test_tcp_app_flash_top.hpp.