cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
simu_udp_app_flash_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_UAF_H_
31 #define _SIMU_UAF_H_
32 
33 #include <stdio.h>
34 #include <fstream>
35 #include <iostream>
36 #include <hls_stream.h>
37 
38 #include "../src/udp_app_flash.hpp"
39 #include "../../../../cFDK/SRA/LIB/SHELL/LIB/hls/NTS/SimNtsUtils.hpp"
40 #include "../../../../cFDK/SRA/LIB/SHELL/LIB/hls/NTS/SimAppData.hpp"
41 #include "../../../../cFDK/SRA/LIB/SHELL/LIB/hls/NTS/SimUdpDatagram.hpp"
42 
43 //------------------------------------------------------
44 //-- TESTBENCH DEFINES
45 //------------------------------------------------------
46 #define TB_MAX_CYCLES 500
47 #define TB_GRACE_TIME 500 // Give the TB some time to finish
48 #define VALID true
49 #define UNVALID false
50 #define DEBUG_TRACE true
51 
52 #define ENABLED (ap_uint<1>)1
53 #define DISABLED (ap_uint<1>)0
54 
55 
56 //---------------------------------------------------------
57 //-- DEFAULT LOCAL FPGA AND FOREIGN HOST SOCKETS
58 //-- By default, the following sockets will be used by the
59 //-- testbench, unless the user specifies new ones via one
60 //-- of the test vector files.
61 //---------------------------------------------------------
62 #define DEFAULT_FPGA_IP4_ADDR 0x0A0CC801 // FPGA's local IP Address = 10.12.200.01
63 #define DEFAULT_FPGA_LSN_PORT 0x2263 // UDP-ROLE listens on port = 8803
64 #define DEFAULT_FPGA_SND_PORT 0xA263 // UDP-ROLE sends on port = 41571
65 #define DEFAULT_HOST_IP4_ADDR 0x0A0CC832 // HOST's foreign IP Address = 10.12.200.50
66 #define DEFAULT_HOST_LSN_PORT 0x80 // HOST listens on port = 128
67 #define DEFAULT_HOST_SND_PORT 0x8080 // HOST sends on port = 32896
68 
69 #define DEFAULT_DATAGRAM_LEN 32
70 
71 
74 void stepSim();
75 void increaseSimTime(unsigned int cycles);
76 
77 
81  const char *myName,
82  SimUdpDatagram &appDatagram,
83  ifstream &ifsData,
84  SocketPair &sockPair,
85  queue<UdpAppMeta> &udpMetaQueue,
86  queue<UdpAppDLen> &udpDLenQueue,
87  int &inpChunks,
88  int &inpDgrms,
89  int &inpBytes);
90 
92  EchoCtrl tbMode,
93  string inpData_FileName,
94  queue<UdpAppMeta> &udpMetaQueue,
95  queue<UdpAppDLen> &udpDLenQueue,
96  string outData_GoldName,
97  string outMeta_GoldName,
98  string outDLen_GoldName);
99 
101  stream<AxisApp> &ssData,
102  const string ssDataName,
103  stream<UdpAppMeta> &ssMeta,
104  const string ssMetaName,
105  stream<UdpAppDLen> &ssDLen,
106  const string ssDLenName,
107  string datFile,
108  queue<UdpAppMeta> &metaQueue,
109  queue<UdpAppDLen> &dlenQueue,
110  int &nrFeededChunks);
111 
113  stream<UdpAppMeta> &ss,
114  string ssName,
115  string datFile,
116  int &nrChunks,
117  int &nrFrames,
118  int &nrBytes);
119 
121  stream<UdpAppDLen> &ss,
122  string ssName,
123  string datFile,
124  int &nrChunks,
125  int &nrFrames,
126  int &nrBytes);
127 
128 #endif
129 
Class UDP Datagram.
EchoCtrl
Definition: memtest.hpp:49
void stepSim()
Increment the simulation counter.
Definition: test_arp.cpp:54
void increaseSimTime(unsigned int cycles)
Increase the simulation time of the testbench.
int createGoldenTxFiles(string inpData_FileName, string outData_GoldName, queue< UdpAppMeta > &udpMetaQueue, queue< UdpAppDLen > &updDLenQueue, char tbMode)
Create the golden IPTX reference file from an input UAIF test file.
Definition: test_uoe.cpp:381
bool drainUdpDLenStreamToFile(stream< UdpAppDLen > &ss, string ssName, string datFile, int &nrChunks, int &nrFrames, int &nrBytes)
Empty an UdpDLen stream to a DAT file.
Definition: test_uoe.cpp:142
bool readDatagramFromFile(const char *myName, SimUdpDatagram &appDatagram, ifstream &ifsData, UdpAppMeta &udpAppMeta, queue< UdpAppMeta > &udpMetaQueue, queue< UdpAppDLen > &updDLenQueue, int &inpChunks, int &inpDgrms, int &inpBytes, char tbMode)
Read a datagram from a DAT file.
Definition: test_uoe.cpp:297
bool drainUdpMetaStreamToFile(stream< UdpAppMeta > &ss, string ssName, string datFile, int &nrChunks, int &nrFrames, int &nrBytes)
Empty an UdpMeta stream to a DAT file.
Definition: test_uoe.cpp:74
int createUdpRxTraffic(stream< AxisApp > &ssData, const string ssDataName, stream< UdpAppMeta > &ssMeta, const string ssMetaName, stream< UdpAppDLen > &ssDLen, const string ssMDLenName, string datFile, queue< UdpAppMeta > &metaQueue, queue< UdpAppDLen > &dlenQueue, int &nrFeededChunks)
Create the UDP Rx traffic as streams from an input test file.