cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
simu_tcp_shell_if_env.hpp
Go to the documentation of this file.
1 /*
2  * Copyright 2016 -- 2021 IBM Corporation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 
30 #ifndef _SIMU_TSIF_H_
31 #define _SIMU_TSIF_H_
32 
33 #include <stdio.h>
34 #include <fstream>
35 #include <iostream>
36 #include <hls_stream.h>
37 #include <map>
38 #include <set>
39 
40 #include "../src/tcp_shell_if.hpp"
41 #include "../../../../cFDK/SRA/LIB/SHELL/LIB/hls/NTS/SimNtsUtils.hpp"
42 #include "../../../../cFDK/SRA/LIB/SHELL/LIB/hls/NTS/SimAppData.hpp"
43 
44 //------------------------------------------------------
45 //-- TESTBENCH DEFINES
46 //------------------------------------------------------
47 const int cSimToeStartupDelay = 1000;
48 const int cGraceTime = 2500;
49 
50 const int cNrSegToSend = 5;
51 const int cNrSessToSend = 2;
52 
53 const int cMinWAIT = cMaxSessions; // To avoid that TSIF accumulates the byte counts of the Notifs
54 
55 //---------------------------------------------------------
56 //-- DEFAULT LOCAL FPGA AND FOREIGN HOST SOCKETS
57 //-- By default, the following sockets will be used by the
58 //-- testbench, unless the user specifies new ones via one
59 //-- of the test vector files.
60 //---------------------------------------------------------
61 #define DEFAULT_FPGA_IP4_ADDR 0x0A0CC801 // TOE's local IP Address = 10.12.200.01
62 #define DEFAULT_FPGA_LSN_PORT 0x0057 // TOE listens on port = 87 (static ports must be 0..32767)
63 #define DEFAULT_HOST_IP4_ADDR 0x0A0CC832 // TB's foreign IP Address = 10.12.200.50
64 #define DEFAULT_HOST_TCP_SRC_PORT 0x80 // TB source port = 128
65 
66 #define DEFAULT_SESSION_ID 0
67 #define DEFAULT_SESSION_LEN 32
68 
69 
70 
73 void stepSim();
74 void increaseSimTime(unsigned int cycles);
75 bool drainDebugSinkCounter(stream<ap_uint<32> > &ss, string ssName);
76 bool drainDebugSpaceCounter(stream<ap_uint<16> > &ss, string ssName);
77 
78 
79 
82 void pTAF(
83  ofstream &ofTAF_Data,
84  stream<TcpAppData> &siTSIF_Data,
85  stream<TcpSessId> &siTSIF_SessId,
86  stream<TcpDatLen> &siTSIF_DatLen,
87  stream<TcpAppData> &soTAF_Data,
88  stream<TcpSessId> &soTAF_Meta,
89  stream<TcpSessId> &soTAF_DLen);
90 
91 void pMMIO(
92  StsBit *piSHL_Ready,
93  CmdBit *poTSIF_Enable);
94 
95 void pTOE(
96  int &nrErr,
97  ofstream &ofTAF_Gold,
98  ofstream &ofTOE_Gold,
99  ofstream &ofTOE_Data,
100  TcpDatLen echoDatLen,
101  SockAddr testSock,
102  TcpDatLen testDatLen,
103  //-- MMIO / Ready Signal
104  StsBit *poMMIO_Ready,
105  //-- TSIF / Tx Data Interfaces
106  stream<TcpAppNotif> &soTSIF_Notif,
107  stream<TcpAppRdReq> &siTSIF_DReq,
108  stream<TcpAppData> &soTSIF_Data,
109  stream<TcpAppMeta> &soTSIF_Meta,
110  //-- TSIF / Listen Interfaces
111  stream<TcpAppLsnReq> &siTSIF_LsnReq,
112  stream<TcpAppLsnRep> &soTSIF_LsnRep,
113  //-- TSIF / Rx Data Interfaces
114  stream<TcpAppData> &siTSIF_Data,
115  stream<TcpAppSndReq> &siTSIF_SndReq,
116  stream<TcpAppSndRep> &soTSIF_SndRep,
117  //-- TSIF / Open Interfaces
118  stream<TcpAppOpnReq> &siTSIF_OpnReq,
119  stream<TcpAppOpnRep> &soTSIF_OpnRep);
120 
121 #endif
122 
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)
Definition: tb_nal.cpp:840
void stepSim()
Increment the simulation counter.
Definition: test_arp.cpp:54
void increaseSimTime(unsigned int cycles)
Increase the simulation time of the testbench.
ap_uint< 1 > StsBit
Definition: nts_types.hpp:116
ap_uint< 16 > TcpDatLen
Definition: AxisTcp.hpp:123
ap_uint< 1 > CmdBit
Definition: nts_types.hpp:108
bool drainDebugSpaceCounter(stream< ap_uint< 16 > > &ss, string ssName)
Empty the DebugSpaceCounter stream and check its last value.
const int cSimToeStartupDelay
const int cGraceTime
void pMMIO(StsBit *piSHL_Ready, CmdBit *poTSIF_Enable)
Emulate the behavior of the SHELL & MMIO.
const int cMinWAIT
bool drainDebugSinkCounter(stream< ap_uint< 32 > > &ss, string ssName)
Empty the DebugSinkCounter stream and throw it away.
const int cNrSessToSend
const int cNrSegToSend
void pTAF(ofstream &ofTAF_Data, stream< TcpAppData > &siTSIF_Data, stream< TcpSessId > &siTSIF_SessId, stream< TcpDatLen > &siTSIF_DatLen, stream< TcpAppData > &soTSIF_Data, stream< TcpSessId > &soTSIF_Meta, stream< TcpSessId > &soTSIF_DLen)
Emulate the behavior of the ROLE/TcpAppFlash (TAF).
const int cMaxSessions