cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
tb_nal.cpp File Reference
#include <stdio.h>
#include <hls_stream.h>
#include <inttypes.h>
#include "../src/nal.hpp"
#include "../../simulation_utils.hpp"
#include "../../NTS/nts_utils.hpp"
Include dependency graph for tb_nal.cpp:

Go to the source code of this file.

Macros

#define VALID   true
 
#define UNVALID   false
 
#define DEBUG_TRACE   true
 
#define THIS_NAME   "TB"
 
#define TRACE_OFF   0x0000
 
#define TRACE_TOE   1 << 1
 
#define TRACE_ROLE   1 << 2
 
#define TRACE_ALL   0xFFFF
 
#define DEBUG_LEVEL   (TRACE_TOE | TRACE_ROLE)
 
#define MAX_SIM_CYCLES   450
 
#define DEFAULT_FPGA_IP4_ADDR   0x0A0CC801
 
#define DEFAULT_FPGA_LSN_PORT   0x0057
 
#define DEFAULT_HOST_IP4_ADDR   0x0A0CC832
 
#define DEFAULT_HOST_LSN_PORT   0x80
 
#define DEFAULT_SESSION_ID   42
 
#define DEFAULT_SESSION_LEN   32
 
#define DEFAULT_TCP_LEN_REP   16
 

Enumerations

enum  RxFsmStates { RX_WAIT_META =0 , RX_STREAM }
 
enum  RoleFsmStates { ROLE_WAIT_META =0 , ROLE_STREAM }
 
enum  LsnStates { LSN_WAIT_REQ , LSN_SEND_ACK }
 
enum  OpnStates { OPN_WAIT_REQ , OPN_SEND_REP , OPN_TIMEOUT }
 
enum  RxpStates {
  RXP_SEND_NOTIF , RXP_WAIT_DREQ , RXP_SEND_META , RXP_SEND_DATA ,
  RXP_DONE
}
 
enum  TxpStates { TXP_WAIT_REQ , TXP_WAIT_DATA , TXP_RECV_DATA }
 

Functions

stream< UdpPortsNRC_UOE_LsnReq ("sNRC_UOE_LsnReq")
 
stream< StsBoolsUOE_NRC_LsnRep ("sUOE_NRC_LsnRep")
 
stream< UdpPortsNRC_UOE_ClsReq ("sNRC_UOE_ClsReq")
 
stream< StsBoolsUOE_NRC_ClsRep ("sUOE_NRC_ClsRep")
 
stream< UdpAppDatasUOE_NRC_Data ("sUOE_NRC_Data")
 
stream< UdpAppMetasUOE_NRC_Meta ("sUOE_NRC_Meta")
 
stream< UdpAppDLensUOE_NRC_DLen ("sUOE_NRC_DLen")
 
stream< UdpAppDatasNRC_UOE_Data ("sNRC_UOE_Data")
 
stream< UdpAppMetasNRC_UOE_Meta ("sNRC_UOE_Meta")
 
stream< UdpAppDLensNRC_UOE_DLen ("sNRC_UOE_DLen")
 
stream< NetworkMetaStreamsiUdp_meta ("siUdp_meta")
 
stream< NetworkMetaStreamsoUdp_meta ("soUdp_meta")
 
stream< NetworkWordsROLE_NRC_Data ("sROLE_NRC_Data")
 
stream< NetworkWordsNRC_Role_Data ("sNRC_Role_Data")
 
stream< NetworkWordsROLE_Nrc_Tcp_data ("sROLE_Nrc_Tcp_data")
 
stream< NetworkMetaStreamsROLE_Nrc_Tcp_meta ("sROLE_Nrc_Tcp_meta")
 
stream< NetworkWordsNRC_Role_Tcp_data ("sNRC_Role_Tcp_data")
 
stream< NetworkMetaStreamsNRC_Role_Tcp_meta ("sNRC_Role_Tcp_meta")
 
stream< NetworkWordsFMC_Nrc_Tcp_data ("sFMC_Nrc_Tcp_data")
 
stream< TcpSessIdsFMC_Nrc_Tcp_sessId ("sFMC_Nrc_Tcp_sessId")
 
stream< NetworkWordsNRC_FMC_Tcp_data ("sNRC_FMC_Tcp_data")
 
stream< TcpSessIdsNRC_FMC_Tcp_sessId ("sNRC_FMC_Tcp_sessId")
 
stream< TcpAppNotifsTOE_Nrc_Notif ("sTOE_Nrc_Notif")
 
stream< TcpAppRdReqsNRC_Toe_DReq ("sNrc_TOE_DReq")
 
stream< TcpAppDatasTOE_Nrc_Data ("sTOE_Nrc_Data")
 
stream< TcpAppMetasTOE_Nrc_SessId ("sTOE_Nrc_SessId")
 
stream< TcpAppLsnReqsNRC_Toe_LsnReq ("sNRC_TOE_LsnReq")
 
stream< TcpAppLsnRepsTOE_Nrc_LsnAck ("sTOE_Nrc_LsnAck")
 
stream< TcpAppDatasNRC_Toe_Data ("sNRC_TOE_Data")
 
stream< TcpAppSndReqsNRC_Toe_SndReq ("sNRC_TOE_SndReq")
 
stream< TcpAppSndRepsTOE_Nrc_SndRep ("sTOE_NRC_SndRep")
 
stream< TcpAppOpnReqsNRC_Toe_OpnReq ("sNRC_Toe_OpnReq")
 
stream< TcpAppOpnRepsTOE_Nrc_OpnRep ("sTOE_NRC_OpenRep")
 
stream< TcpAppClsReqsNRC_Toe_ClsReq ("sNRC_TOE_ClsReq")
 
void stepDut ()
 Run a single iteration of the DUT model. More...
 
bool setInputDataStream (stream< UdpAppData > &sDataStream, const string dataStreamName, const string inpFileName)
 Initialize an input data stream from a file. More...
 
bool setInputDataStream (stream< NetworkWord > &sDataStream, const string dataStreamName, const string inpFileName)
 
bool setInputMetaStream (stream< UdpAppMeta > &sMetaStream, const string dataStreamName, const string inpFileName)
 Initialize an input meta stream from a file. More...
 
bool readDataStream (stream< UdpAppData > &sDataStream, UdpAppData *udpWord)
 Read data from a stream. More...
 
bool readMetaStream (stream< UdpAppMeta > &sMetaStream, const string metaStreamName, UdpAppMeta *udpMeta)
 Read an output metadata stream from the DUT. More...
 
bool readPLenStream (stream< UdpPLen > &sPLenStream, const string plenStreamName, UdpPLen *udpPLen)
 Read an output payload length stream from the DUT. More...
 
bool dumpDataToFile (UdpAppData *udpWord, ofstream &outFileStream)
 Dump a data word to a file. More...
 
bool dumpDataToFile (NetworkWord *udpWord, ofstream &outFileStream)
 
bool dumpMetaToFile (UdpAppMeta *udpMeta, ofstream &outFileStream)
 Dump a metadata information to a file. More...
 
bool dumpPLenToFile (UdpPLen *udpPLen, ofstream &outFileStream)
 Dump a payload length information to a file. More...
 
bool getOutputDataStream (stream< UdpAppData > &sDataStream, const string dataStreamName, const string outFileName)
 Fill an output file with data from an output stream. More...
 
bool getOutputDataStream (stream< NetworkWord > &sDataStream, const string dataStreamName, const string outFileName)
 
bool getOutputMetaStream (stream< UdpAppMeta > &sMetaStream, const string metaStreamName, const string outFileName)
 Fill an output file with metadata from an output stream. More...
 
bool getOutputPLenStream (stream< UdpPLen > &sPLenStream, const string plenStreamName, const string outFileName)
 Fill an output file with payload length from an output stream. More...
 
void pFMC (stream< NetworkWord > &siTRIF_Data, stream< TcpSessId > &siTRIF_SessId, stream< NetworkWord > &soTRIF_Data, stream< TcpSessId > &soTRIF_SessId)
 Emulate the behavior of the FMC. More...
 
void pROLE (stream< NetworkWord > &siTRIF_Data, stream< NetworkMetaStream > &siTRIF_meta, stream< NetworkWord > &soTRIF_Data, stream< NetworkMetaStream > &soTRIF_meta)
 Emulate the behavior of the ROLE. More...
 
void pTOE (int &nrErr, stream< TcpAppNotif > &soTRIF_Notif, stream< TcpAppRdReq > &siTRIF_DReq, stream< TcpAppData > &soTRIF_Data, stream< TcpAppMeta > &soTRIF_SessId, stream< TcpAppLsnReq > &siTRIF_LsnReq, stream< TcpAppLsnRep > &soTRIF_LsnAck, stream< TcpAppData > &siTRIF_Data, stream< TcpAppSndReq > &siTRIF_SndReq, stream< TcpAppSndRep > &soTRIF_SndRep, stream< TcpAppOpnReq > &siTRIF_OpnReq, stream< TcpAppOpnRep > &soTRIF_OpnRep)
 
int main ()
 Main Testbench Loop; Emulates also the behavior of the UDP Offload Engine (UOE). More...
 

Variables

ap_uint< 1 > layer_4_enabled = 0b1
 
ap_uint< 1 > layer_7_enabled = 0b1
 
ap_uint< 1 > role_decoupled = 0b0
 
ap_uint< 1 > sNTS_Nrc_ready = 0b1
 
ap_uint< 32 > sIpAddress = 0x0a0b0c0d
 
ap_uint< 32 > ctrlLink [64+16+16]
 
ap_uint< 32 > s_udp_rx_ports = 0x1
 
ap_uint< 32 > s_tcp_rx_ports = 0x1
 
ap_uint< 32 > myIpAddress
 
ap_uint< 16 > sMMIO_FmcLsnPort = 8803
 
ap_uint< 32 > sMMIO_CfrmIp4Addr = 0x0A0CC832
 
unsigned int gSimCycCnt = 0
 
bool gTraceEvent = false
 
bool gFatalError = false
 
unsigned int simCnt
 
int tcp_packets_send = 0
 
int tcp_packets_recv = 0
 
int tcp_recv_frag_cnt = 0
 
int tcp_packets_expected_timeout = 0
 
int tcp_timout_packet_drop = 0
 
enum RxFsmStates rxFsmState = RX_WAIT_META
 
enum RoleFsmStates roleFsmState = ROLE_WAIT_META
 
Ip4Addr hostIp4Addr = 0
 Emulate the behavior of the TCP Offload Engine (TOE). More...
 
TcpPort fpgaLsnPort = -1
 
TcpPort hostSrcPort = 80
 
int loop = 1
 
enum LsnStates lsnState = LSN_WAIT_REQ
 
enum OpnStates opnState = OPN_WAIT_REQ
 
enum RxpStates rxpState = RXP_SEND_NOTIF
 
enum TxpStates txpState = TXP_WAIT_REQ
 
int opnStartupDelay = 0
 
int rxpStartupDelay = 100
 
int txpStartupDelay = 0
 
TcpAppRdReq appRdReq
 
AppMeta sessionId = 42
 
AppMeta sessionId_reply = 42
 
int byteCnt = 0
 
int segCnt = 0
 
int nrSegToSend = 3
 
ap_uint< 64 > data =0
 
TcpSegLen tcpSegLen = 32
 
const char * myLsnName = "NAL" "/" "TOE/Listen"
 
const char * myOpnName = "NAL" "/" "TOE/OpnCon"
 
const char * myRxpName = "NAL" "/" "TOE/RxPath"
 
const char * myTxpName = "NAL" "/" "TOE/TxPath"