62 #define USE_DEPRECATED_DIRECTIVES
78 ap_uint<1> &piMMIO_Enable,
79 stream<ap_uint<16> > &soUDMX_OpnReq,
80 stream<bool> &siUDMX_OpnAck,
81 stream<SigOpn> &soFsm_Signal)
84 #pragma HLS PIPELINE II=1 enable_flush
85 #pragma HLS INLINE off
88 static bool opnAck =
false;
89 static bool waitForAck =
false;
90 static ap_uint<8> startupDelay = TIME_5S;
93 if (startupDelay == 0) {
94 if (!opnAck && !waitForAck && !soUDMX_OpnReq.full()) {
99 soUDMX_OpnReq.write(68);
102 else if (!siUDMX_OpnAck.empty() && waitForAck) {
103 siUDMX_OpnAck.read(opnAck);
104 soFsm_Signal.write(SIG_OPEN);
126 stream<UdpWord> &siUDMX_Data,
127 stream<UdpMeta> &siUDMX_Meta,
128 stream<DhcpMetaRep> &soFsm_MetaRepFifo,
129 ap_uint<48> piMMIO_MacAddr)
132 #pragma HLS PIPELINE II=1 enable_flush
133 #pragma HLS INLINE off
136 static bool rcvMsgIsReply =
false;
137 static bool rcvMsgHasMyMac =
true;
138 static bool rcvMsgIsDhcp =
false;
139 static ap_uint<6> rcvWordCount = 0;
144 if (!siUDMX_Data.empty()) {
145 siUDMX_Data.read(currWord);
147 switch (rcvWordCount) {
150 rcvMsgIsReply = currWord.
tdata(7, 0) == 0x2;
152 rcvMsgHasMyMac =
true;
166 rcvMsgHasMyMac = (rcvMsgHasMyMac && (piMMIO_MacAddr(31, 0) == currWord.
tdata(63, 32)));
171 rcvMsgHasMyMac = (rcvMsgHasMyMac && (piMMIO_MacAddr(47, 32) == currWord.
tdata(15, 0)));
182 rcvMsgIsDhcp = (MAGIC_COOKIE == currWord.
tdata(63, 32));
187 if (currWord.
tdata(15, 0) == 0x0135)
188 metaReplyInfo.
type = currWord.
tdata(23, 16);
198 if (currWord.
tlast) {
201 if (rcvMsgIsReply && rcvMsgHasMyMac && rcvMsgIsDhcp)
202 soFsm_MetaRepFifo.write(metaReplyInfo);
207 if (!siUDMX_Meta.empty())
226 stream<DhcpMetaReq> &siFsm_MetaReqFifo,
227 stream<UdpWord> &soUDMX_Data,
228 stream<UdpMeta> &soUDMX_Meta,
229 stream<UdpPLen> &soUDMX_PLen,
230 ap_uint<48> piMMIO_MacAddr)
233 #pragma HLS PIPELINE II=1 enable_flush
234 #pragma HLS INLINE off
237 static ap_uint<6> sm_wordCount = 0;
241 switch (sm_wordCount) {
244 if (!siFsm_MetaReqFifo.empty()) {
245 siFsm_MetaReqFifo.read(meta);
246 sendWord.
tdata( 7, 0) = 0x01;
247 sendWord.
tdata(15, 8) = 0x01;
248 sendWord.
tdata(23, 16) = 0x06;
249 sendWord.
tdata(31, 24) = 0x00;
252 soUDMX_Data.write(sendWord);
254 soUDMX_PLen.write(300);
260 sendWord.
tdata(22, 0) = 0;
261 sendWord.
tdata[23] = 0x1;
262 sendWord.
tdata(63, 24) = 0;
263 soUDMX_Data.write(sendWord);
273 soUDMX_Data.write(sendWord);
279 sendWord.
tdata(31, 0) = 0;
280 sendWord.
tdata(63, 32) = piMMIO_MacAddr(31, 0);
281 soUDMX_Data.write(sendWord);
286 sendWord.
tdata(15, 0) = piMMIO_MacAddr(47, 32);
287 sendWord.
tdata(63, 16) = 0;
288 soUDMX_Data.write(sendWord);
293 sendWord.
tdata(31, 0) = 0;
295 sendWord.
tdata(63, 32) = MAGIC_COOKIE;
296 soUDMX_Data.write(sendWord);
302 sendWord.
tdata(15, 0) = 0x0135;
306 sendWord.
tdata(31, 24) = 0xff;
307 sendWord.
tdata(63, 32) = 0;
311 sendWord.
tdata(31, 24) = 0x32;
312 sendWord.
tdata(39, 32) = 0x04;
316 soUDMX_Data.write(sendWord);
326 soUDMX_Data.write(sendWord);
331 sendWord.
tkeep = 0x0f;
333 soUDMX_Data.write(sendWord);
355 stream<SigOpn> &siOpn_Signal,
356 ap_uint<1> &piMMIO_Enable,
357 stream<DhcpMetaRep> &siRcv_MsgFifo,
358 stream<DhcpMetaReq> &soSnd_MsgFifo,
359 ap_uint<32> &poNts_IpAddress)
363 #pragma HLS PIPELINE II=1 enable_flush
364 #pragma HLS INLINE off
367 static ap_uint<32> randomValue = 0x34aad34b;
368 static ap_uint<32> myIdentity = 0;
370 static ap_uint<32> IpAddressBuffer = 0;
371 static ap_uint<8> waitTime = 100;
377 static enum FsmState {PORT_WAIT=0, INIT, SELECTING, REQUESTING, BOUND}
fsmState;
382 if (!siOpn_Signal.empty()) {
383 SigOpn signal = siOpn_Signal.read();
384 if (signal == SIG_OPEN)
390 if (piMMIO_Enable == 1) {
392 myIdentity = randomValue;
394 randomValue = (randomValue * 8) xor randomValue;
404 if (!siRcv_MsgFifo.empty()) {
405 siRcv_MsgFifo.read(rcvMsg);
426 if (!siRcv_MsgFifo.empty()) {
427 siRcv_MsgFifo.read(rcvMsg);
447 if (!siRcv_MsgFifo.empty())
448 siRcv_MsgFifo.read();
449 if (piMMIO_Enable == 0)
479 ap_uint<1> &piMMIO_This_Enable,
480 ap_uint<48> &piMMIO_This_MacAddress,
485 ap_uint<32> &poTHIS_Nts_IpAddress,
490 stream<AxisAck> &siUDMX_This_OpnAck,
491 stream<UdpPort> &soTHIS_Udmx_OpnReq,
496 stream<UdpWord> &siUDMX_This_Data,
497 stream<UdpMeta> &siUDMX_This_Meta,
498 stream<UdpWord> &soTHIS_Udmx_Data,
499 stream<UdpMeta> &soTHIS_Udmx_Meta,
500 stream<UdpPort> &soTHIS_Udmx_PLen)
504 #pragma HLS INTERFACE ap_ctrl_none port=return
511 #if defined(USE_DEPRECATED_DIRECTIVES)
513 #pragma HLS INTERFACE ap_stable port=piMMIO_This_Enable
514 #pragma HLS INTERFACE ap_stable port=piMMIO_This_MacAddress
516 #pragma HLS INTERFACE ap_none register port=poTHIS_Nts_IpAddress
518 #pragma HLS resource core=AXI4Stream variable=siUDMX_This_OpnAck metadata="-bus_bundle siUDMX_This_OpnAck"
519 #pragma HLS resource core=AXI4Stream variable=soTHIS_Udmx_OpnReq metadata="-bus_bundle soTHIS_Udmx_OpnReq"
521 #pragma HLS resource core=AXI4Stream variable=siUDMX_This_Data metadata="-bus_bundle siUDMX_This_Data"
522 #pragma HLS resource core=AXI4Stream variable=siUDMX_This_Meta metadata="-bus_bundle siUDMX_This_Meta"
523 #pragma HLS DATA_PACK variable=siUDMX_This_Meta
525 #pragma HLS resource core=AXI4Stream variable=soTHIS_Udmx_Data metadata="-bus_bundle soTHIS_Udmx_Data"
526 #pragma HLS resource core=AXI4Stream variable=soTHIS_Udmx_Meta metadata="-bus_bundle soTHIS_Udmx_Meta"
527 #pragma HLS DATA_PACK variable=soTHIS_Udmx_Meta
528 #pragma HLS resource core=AXI4Stream variable=soTHIS_Udmx_PLen metadata="-bus_bundle soTHIS_Udmx_PLen"
532 #pragma HLS INTERFACE ap_stable port=piMMIO_This_Enable
533 #pragma HLS INTERFACE ap_stable port=piMMIO_This_MacAddress
535 #pragma HLS INTERFACE ap_none register port=poTHIS_Nts_IpAddress
537 #pragma HLS INTERFACE axis register both port=siUDMX_This_OpnAck
538 #pragma HLS INTERFACE axis register both port=soTHIS_Udmx_OpnReq
540 #pragma HLS INTERFACE axis register both port=siUDMX_This_Data
541 #pragma HLS INTERFACE axis register both port=siUDMX_This_Meta
542 #pragma HLS DATA_PACK variable=siUDMX_This_Meta instance=siUDMX_This_Meta
544 #pragma HLS INTERFACE axis register both port=soTHIS_Udmx_Data
545 #pragma HLS INTERFACE axis register both port=soTHIS_Udmx_Meta
546 #pragma HLS DATA_PACK variable=soTHIS_Udmx_Meta instance=soTHIS_Udmx_Meta
547 #pragma HLS INTERFACE axis register both port=soTHIS_Udmx_PLen
555 static stream<SigOpn> sOpnToFsm_Signal (
"sOpnToFsm_Signal");
557 static stream<DhcpMetaRep> sRcvToFsm_MetaRepFifo (
"sRcvToFsm_MetaRepFifo");
558 #pragma HLS stream variable=sRcvToFsm_MetaRepFifo depth=4
559 #pragma HLS DATA_PACK variable=sRcvToFsm_MetaRepFifo
561 static stream<DhcpMetaReq> sFsmToSnd_MetaReqFifo (
"sFsmToSnd_MetaReqFifo");
562 #pragma HLS stream variable=sFsmToSnd_MetaReqFifo depth=4
563 #pragma HLS DATA_PACK variable=sFsmToSnd_MetaReqFifo
568 soTHIS_Udmx_OpnReq, siUDMX_This_OpnAck,
572 sRcvToFsm_MetaRepFifo, piMMIO_This_MacAddress);
574 pFsmCtrl(sOpnToFsm_Signal, piMMIO_This_Enable,
575 sRcvToFsm_MetaRepFifo, sFsmToSnd_MetaReqFifo,
576 poTHIS_Nts_IpAddress);
579 soTHIS_Udmx_Data, soTHIS_Udmx_Meta, soTHIS_Udmx_PLen,
580 piMMIO_This_MacAddress);
void pFsmCtrl(stream< SigOpn > &siOpn_Signal, ap_uint< 1 > &piMMIO_Enable, stream< DhcpMetaRep > &siRcv_MsgFifo, stream< DhcpMetaReq > &soSnd_MsgFifo, ap_uint< 32 > &poNts_IpAddress)
Final state machine that controls the sending and reception of DHCP messages. to the.
void pSndMessage(stream< DhcpMetaReq > &siFsm_MetaReqFifo, stream< UdpWord > &soUDMX_Data, stream< UdpMeta > &soUDMX_Meta, stream< UdpPLen > &soUDMX_PLen, ap_uint< 48 > piMMIO_MacAddr)
Build a DHCP message from a meta-request information and send it out to the DHCP server.
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< UdpPort > &soTHIS_Udmx_PLen)
Main process of the DHCP-client.
void pRcvMessage(stream< UdpWord > &siUDMX_Data, stream< UdpMeta > &siUDMX_Meta, stream< DhcpMetaRep > &soFsm_MetaRepFifo, ap_uint< 48 > piMMIO_MacAddr)
Receive a message from the DHCP server and generate a meta-reply information for the FSM control proc...
void pOpnComm(ap_uint< 1 > &piMMIO_Enable, stream< ap_uint< 16 > > &soUDMX_OpnReq, stream< bool > &siUDMX_OpnAck, stream< SigOpn > &soFsm_Signal)
Open a communication end point. This corresponds somehow to the creation of a UDP socket at the clien...
: Dynamic Host Configuration Protocol (DHCP) client.
ap_uint< 32 > myIpAddress