cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
dhcp_client.hpp
Go to the documentation of this file.
1 
2 
18 
44 
53 #include <hls_stream.h>
54 #include "ap_int.h"
55 
56 using namespace hls;
57 
58 
59 
62 struct DhcpMetaRep { // DHCP meta-reply information
63  ap_uint<32> identifier;
64  ap_uint<32> assignedIpAddress;
65  ap_uint<32> serverAddress;
66  ap_uint<8> type;
67 };
68 
69 struct DhcpMetaReq { // DHCP meta-request information
70  ap_uint<32> identifier;
71  ap_uint<8> type;
72  ap_uint<32> requestedIpAddress;
73 
75  DhcpMetaReq(ap_uint<32> i, ap_uint<8> type) :
76  identifier(i), type(type), requestedIpAddress(0) {}
77  DhcpMetaReq(ap_uint<32> i, ap_uint<8> type, ap_uint<32> ip) :
78  identifier(i), type(type), requestedIpAddress(ip) {}
79 };
80 
81 
82 
86 enum DhcpOperationCode { // Specifies the general type of message.
87  DHCPDISCOVER = 0x01, // An odd value indicates a request message.
88  DHCPOFFER = 0x02, // An even value indicates a reply message.
89  DHCPREQUEST = 0x03,
90  DHCPACK = 0x05
91 };
92 
93 
94 
97 static const ap_uint<32> MAGIC_COOKIE = 0x63538263;
98 
99 #ifndef __SYNTHESIS__
100  static const ap_uint<32> TIME_US = 200;
101  static const ap_uint<32> TIME_5S = 100;
102  static const ap_uint<32> TIME_30S = 300;
103 #else
104  static const ap_uint<32> TIME_US = 20000;
105  static const ap_uint<32> TIME_5S = 750750750;
106  static const ap_uint<32> TIME_30S = 0xFFFFFFFF;
107 #endif
108 
109 
110 
113 struct SocketAddr {
114  ap_uint<16> port; // Port in network byte order
115  ap_uint<32> addr; // IPv4 address
117  SocketAddr(ap_uint<32> addr, ap_uint<16> port) :
118  addr(addr), port(port) {}
119 };
120 
121 
122 
125 struct UdpWord { // UDP Streaming Chunk (i.e. 8 bytes)
126  ap_uint<64> tdata;
127  ap_uint<8> tkeep;
128  ap_uint<1> tlast;
129  UdpWord() {}
130  UdpWord(ap_uint<64> tdata, ap_uint<8> tkeep, ap_uint<1> tlast) :
131  tdata(tdata), tkeep(tkeep), tlast(tlast) {}
132 };
133 
134 struct UdpMeta { // UDP Socket Pair Association
135  SocketAddr src; // Source socket address
136  SocketAddr dst; // Destination socket address
137  UdpMeta() {}
139  src(src), dst(dst) {}
140 };
141 
142 typedef ap_uint<16> UdpPLen; // UDP Payload Length
143 
144 typedef ap_uint<16> UdpPort; // UDP Port Number
145 
146 
147 
148 
151 typedef bool AxisAck; // Acknowledgment over Axi4-Stream I/F
152 
153 
154 
157 typedef ap_uint<1> SigOpn; // Signal that the socket is open.
158 
159 static const SigOpn SIG_OPEN = 1;
160 
161 
162 
163 
164 void dhcp_client(
165 
166  //------------------------------------------------------
167  //-- MMIO / This / Config Interfaces
168  //------------------------------------------------------
169  ap_uint<1> &piMMIO_This_Enable,
170  ap_uint<48> &piMMIO_This_MacAddress,
171 
172  //------------------------------------------------------
173  //-- THIS / Nts / IPv4 Interfaces
174  //------------------------------------------------------
175  ap_uint<32> &poTHIS_Nts_IpAddress,
176 
177  //------------------------------------------------------
178  //-- UDMX / This / Open-Port Interfaces
179  //------------------------------------------------------
180  stream<AxisAck> &siUDMX_This_OpnAck,
181  stream<UdpPort> &soTHIS_Udmx_OpnReq,
182 
183  //------------------------------------------------------
184  //-- UDMX / This / Data & MetaData Interfaces
185  //------------------------------------------------------
186  stream<UdpWord> &siUDMX_This_Data,
187  stream<UdpMeta> &siUDMX_This_Meta,
188  stream<UdpWord> &soTHIS_Udmx_Data,
189  stream<UdpMeta> &soTHIS_Udmx_Meta,
190  stream<UdpPLen> &soTHIS_Udmx_PLen
191 );
ap_uint< 1 > SigOpn
ap_uint< 16 > UdpPLen
void dhcp_client(ap_uint< 1 > &piMMIO_This_Enable, ap_uint< 48 > &piMMIO_This_MacAddress, ap_uint< 32 > &poTHIS_Nts_IpAddress, stream< AxisAck > &siUDMX_This_OpnAck, stream< UdpPort > &soTHIS_Udmx_OpnReq, stream< UdpWord > &siUDMX_This_Data, stream< UdpMeta > &siUDMX_This_Meta, stream< UdpWord > &soTHIS_Udmx_Data, stream< UdpMeta > &soTHIS_Udmx_Meta, stream< UdpPLen > &soTHIS_Udmx_PLen)
Main process of the DHCP-client.
DhcpOperationCode
Definition: dhcp_client.hpp:86
@ DHCPACK
Definition: dhcp_client.hpp:90
@ DHCPOFFER
Definition: dhcp_client.hpp:88
@ DHCPREQUEST
Definition: dhcp_client.hpp:89
@ DHCPDISCOVER
Definition: dhcp_client.hpp:87
ap_uint< 16 > UdpPort
bool AxisAck
ap_uint< 32 > serverAddress
Definition: dhcp_client.hpp:65
ap_uint< 8 > type
Definition: dhcp_client.hpp:66
ap_uint< 32 > identifier
Definition: dhcp_client.hpp:63
ap_uint< 32 > assignedIpAddress
Definition: dhcp_client.hpp:64
ap_uint< 8 > type
Definition: dhcp_client.hpp:71
ap_uint< 32 > requestedIpAddress
Definition: dhcp_client.hpp:72
ap_uint< 32 > identifier
Definition: dhcp_client.hpp:70
DhcpMetaReq(ap_uint< 32 > i, ap_uint< 8 > type)
Definition: dhcp_client.hpp:75
DhcpMetaReq(ap_uint< 32 > i, ap_uint< 8 > type, ap_uint< 32 > ip)
Definition: dhcp_client.hpp:77
ap_uint< 16 > port
ap_uint< 32 > addr
SocketAddr(ap_uint< 32 > addr, ap_uint< 16 > port)
SocketAddr src
SocketAddr dst
UdpMeta(SocketAddr src, SocketAddr dst)
ap_uint< 64 > tdata
UdpWord(ap_uint< 64 > tdata, ap_uint< 8 > tkeep, ap_uint< 1 > tlast)
ap_uint< 1 > tlast
ap_uint< 8 > tkeep