cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
network.hpp
Go to the documentation of this file.
1 
17 // *
18 // * cloudFPGA
19 // * =============================================
20 // * Created: Apr 2019
21 // * Authors: FAB, WEI, NGL
22 // *
23 // * Description:
24 // * This file contains network types and functions that are shared between SHELL and ROLE
25 // *
26 
27 #ifndef _CF_NETWORK_USER_UTILS_
28 #define _CF_NETWORK_USER_UTILS_
29 
30 
31 #include <stdint.h>
32 #include <stdio.h>
33 
34 #include "ap_int.h"
35 #include "ap_utils.h"
36 #include <hls_stream.h>
37 
38 
39 using namespace hls;
40 
41 
45 #define NETWORK_WORD_BYTE_WIDTH 8
46 #define NETWORK_WORD_BIT_WIDTH 64
47 
48 struct NetworkWord {
49  ap_uint<64> tdata;
50  ap_uint<8> tkeep;
51  ap_uint<1> tlast;
53  NetworkWord(ap_uint<64> tdata, ap_uint<8> tkeep, ap_uint<1> tlast) :
54  tdata(tdata), tkeep(tkeep), tlast(tlast) {}
55  NetworkWord(ap_uint<64> single_data) : tdata(single_data), tkeep(0xFFF), tlast(1) {}
56  ap_uint<64> getTData() {
57  return tdata;
58  }
59  ap_uint<8> getTKeep() {
60  return tkeep;
61  }
62  ap_uint<1> getTLast() {
63  return tlast;
64  }
65  void setTData(ap_uint<64> new_data) {
66  tdata = new_data;
67  }
68  void setTKeep(ap_uint<8> new_keep) {
69  tkeep = new_keep;
70  }
71  void setTLast(ap_uint<1> new_last) {
72  tlast = new_last;
73  }
74 };
75 
76 
79 
80 
81 typedef ap_uint<16> NrcPort; // UDP/TCP Port Number
82 typedef ap_uint<8> NodeId; // Cluster Node Id
83 
84 //#define MAX_CF_NODE_ID (128-1)
85 #define MAX_CF_NODE_ID (64-1)
86 
87 #define NAL_THIS_FPGA_PSEUDO_NID (MAX_CF_NODE_ID + 1)
88 
89 #define NAL_RX_MIN_PORT 2718
90 #define NAL_RX_MAX_PORT 2749
91 
92 typedef ap_uint<16> NetworkDataLength;
93 
94 struct NetworkMeta {
100 
102  //"alphabetical order"
103  NetworkMeta(NodeId d_id, NrcPort d_port, NodeId s_id, NrcPort s_port, NetworkDataLength length) :
104  dst_rank(d_id), dst_port(d_port), src_rank(s_id), src_port(s_port), len(length) {}
105 };
106 
107 //split between NetworkMeta and NetworkMetaStream to not make the Shell Role interface depend of "DATA_PACK"
110  ap_uint<8> tkeep;
111  ap_uint<1> tlast;
113  NetworkMetaStream(NetworkMeta single_data) : tdata(single_data), tkeep(0xFFF), tlast(1) {}
114 };
115 
116 
117 #endif
118 
119 
ap_uint< 8 > NodeId
Definition: network.hpp:82
ap_uint< 16 > NrcPort
Definition: network.hpp:81
ap_uint< 16 > NetworkDataLength
Definition: network.hpp:92
NetworkWord TcpWord
Definition: network.hpp:78
NetworkWord UdpWord
Definition: network.hpp:77
ap_uint< 1 > tlast
Definition: network.hpp:111
ap_uint< 8 > tkeep
Definition: network.hpp:110
NetworkMeta tdata
Definition: network.hpp:109
NetworkMetaStream(NetworkMeta single_data)
Definition: network.hpp:113
NetworkDataLength len
Definition: network.hpp:99
NodeId dst_rank
Definition: network.hpp:95
NodeId src_rank
Definition: network.hpp:97
NrcPort src_port
Definition: network.hpp:98
NrcPort dst_port
Definition: network.hpp:96
NetworkMeta(NodeId d_id, NrcPort d_port, NodeId s_id, NrcPort s_port, NetworkDataLength length)
Definition: network.hpp:103
ap_uint< 64 > getTData()
Definition: network.hpp:56
void setTData(ap_uint< 64 > new_data)
Definition: network.hpp:65
void setTLast(ap_uint< 1 > new_last)
Definition: network.hpp:71
ap_uint< 1 > getTLast()
Definition: network.hpp:62
ap_uint< 64 > tdata
Definition: network.hpp:49
ap_uint< 8 > getTKeep()
Definition: network.hpp:59
ap_uint< 8 > tkeep
Definition: network.hpp:50
ap_uint< 1 > tlast
Definition: network.hpp:51
void setTKeep(ap_uint< 8 > new_keep)
Definition: network.hpp:68
NetworkWord(ap_uint< 64 > single_data)
Definition: network.hpp:55
NetworkWord(ap_uint< 64 > tdata, ap_uint< 8 > tkeep, ap_uint< 1 > tlast)
Definition: network.hpp:53