61 ap_uint<4> bitCounter = 0;
62 for (uint8_t i=0;i<8;++i) {
63 if (bitVector.bit(i) == 1)
71 for (uint8_t i=0;i<8;++i) {
79 return (inputVector.range(7,0), inputVector(15, 8), inputVector(23, 16), inputVector(31, 24));
83 return (inputVector.range(7,0), inputVector(15, 8));
89 stream<ap_uint<16> >& app2portTable_port_req,
90 stream<ap_uint<16> >& app2portTable_port_rel,
91 stream<bool>& portTable2app_port_assign,
92 stream<bool>& portTable2rxEng_check_rsp) {
93 #pragma HLS pipeline II=1 enable_flush
96 #pragma HLS RESOURCE variable=portTable core=RAM_T2P_BRAM
97 #pragma HLS DEPENDENCE variable=portTable inter false
99 if (!rxEng2portTable_check_req.empty()) {
100 ap_uint<16> currPort = rxEng2portTable_check_req.read();
101 portTable2rxEng_check_rsp.write(
portTable[currPort]);
103 else if (!app2portTable_port_req.empty()) {
104 ap_uint<16> portToOpen = app2portTable_port_req.read();
106 portTable2app_port_assign.write(
true);
108 portTable2app_port_assign.write(
false);
111 else if (!app2portTable_port_rel.empty()) {
112 ap_uint<16> releasedPort = app2portTable_port_rel.read();
117 void inputPathRxEngine(stream<axiWord> &inputPathInputData, stream<ipTuple> &incomingIPaddresses, stream<axiWord> &inputPathIPheader,
stream<ap_uint<16> >& rxEng2portTable_check_req,
118 stream<bool>& portTable2rxEng_assign, stream<bool> &rxChecksum2rxEngine, stream<axiWord> &inputPathOutputData,
119 stream<metadata> &inputPathOutputMetadata, stream<axiWord> &inputPathPortUnreachable) {
120 #pragma HLS INLINE off
121 #pragma HLS pipeline II=1 enable_flush
123 static enum iState{IP_IDLE = 0, IP_WAIT, IP_STREAMFIRST, IP_STREAMIP, IP_STREAMREST, IP_DROP, IP_PORT_UNREACHABLE_IP_FIRST, IP_PORT_UNREACHABLE_IP, IP_PORT_UNREACHABLE_UDP, IP_PORT_UNREACHABLE_RESIDUE, IP_DRAIN} inputPathState;
128 static ap_uint<4> rxEngIpHdrWordCount = 0;
129 static ap_uint<1> rxEngNoPayloadFlag = 0;
131 switch(inputPathState) {
133 if (!inputPathInputData.empty() && !incomingIPaddresses.empty() && !inputPathIPheader.empty() && !rxEng2portTable_check_req.full()) {
134 ipTuple ipAddressBuffer = incomingIPaddresses.read();
136 ipHdrWord = inputPathIPheader.read();
137 rxEngIpHdrWordCount = ipHdrWord.
data.range(3,0) - 2;
138 bufferWord = inputPathInputData.read();
139 (
byteSwap16(bufferWord.
data.range(47, 32)) > 8) ? rxEngNoPayloadFlag = 0 : rxEngNoPayloadFlag = 1;
140 rxEng2portTable_check_req.write(
byteSwap16(bufferWord.
data.range(31, 16)));
142 inputPathState = IP_WAIT;
146 if (!portTable2rxEng_assign.empty() && !rxChecksum2rxEngine.empty()) {
147 bool checksumResult = rxChecksum2rxEngine.read();
148 bool portResult = portTable2rxEng_assign.read();
149 if(portResult && checksumResult && rxEngNoPayloadFlag == 0)
150 inputPathState = IP_STREAMFIRST;
151 else if (!checksumResult || rxEngNoPayloadFlag == 1)
152 inputPathState = IP_DROP;
154 inputPathState = IP_PORT_UNREACHABLE_IP_FIRST;
158 if (!inputPathInputData.empty() && !inputPathOutputData.full() && !inputPathOutputMetadata.full()) {
159 axiWord inputWord = inputPathInputData.read();
160 inputPathOutputData.write(inputWord);
161 inputPathOutputMetadata.write(rxPathMetadata);
162 if (inputWord.
last == 1)
163 inputPathState = IP_DRAIN;
165 inputPathState = IP_STREAMIP;
169 if (!inputPathInputData.empty() && !inputPathIPheader.empty() && !inputPathOutputData.full() && !inputPathOutputMetadata.full()) {
170 axiWord inputWord = inputPathInputData.read();
171 inputPathIPheader.read();
172 inputPathOutputData.write(inputWord);
173 if (inputWord.
last == 1) {
174 if (rxEngIpHdrWordCount <= 2)
175 inputPathState = IP_IDLE;
177 inputPathState = IP_DRAIN;
180 if (rxEngIpHdrWordCount <= 2)
181 inputPathState = IP_STREAMREST;
183 rxEngIpHdrWordCount -= 2;
187 if (!inputPathInputData.empty() && !inputPathOutputData.full()) {
188 axiWord inputWord = inputPathInputData.read();
189 inputPathOutputData.write(inputWord);
190 if (inputWord.
last == 1) {
191 inputPathState = IP_IDLE;
196 if (!inputPathInputData.empty()) {
197 axiWord inputWord = inputPathInputData.read();
198 if (rxEngIpHdrWordCount > 0) {
199 inputPathIPheader.read();
200 rxEngIpHdrWordCount > 2 ? rxEngIpHdrWordCount -= 2 : rxEngIpHdrWordCount = 0;
202 if (inputWord.
last == 1) {
203 if (rxEngIpHdrWordCount == 0 )
204 inputPathState = IP_IDLE;
206 inputPathState = IP_DRAIN;
210 case IP_PORT_UNREACHABLE_IP_FIRST:
211 if (!inputPathPortUnreachable.full()) {
212 inputPathPortUnreachable.write(ipHdrWord);
213 inputPathState = IP_PORT_UNREACHABLE_IP;
216 case IP_PORT_UNREACHABLE_IP:
217 if (!inputPathIPheader.empty() && !inputPathPortUnreachable.full()) {
218 axiWord inputWord = inputPathIPheader.read();
219 if (inputWord.
last == 1) {
221 inputWord.
data.range(63, 32) = bufferWord.
data.range(31, 0);
222 inputPathState = IP_PORT_UNREACHABLE_UDP;
224 inputPathPortUnreachable.write(inputWord);
227 case IP_PORT_UNREACHABLE_UDP:
228 if (!inputPathInputData.empty() && !inputPathPortUnreachable.full()) {
229 axiWord inputWord = inputPathInputData.read();
230 bufferWord.
data = (inputWord.
data.range(31, 0), bufferWord.
data.range(63, 32));
231 if (inputWord.
last == 1) {
232 if (inputWord.
keep.range(7, 4) == 0x0) {
233 bufferWord.
keep.range(7, 4) = inputWord.
keep.range(3, 0);
235 inputPathState = IP_IDLE;
239 inputPathState = IP_PORT_UNREACHABLE_RESIDUE;
241 inputPathPortUnreachable.write(bufferWord);
244 inputPathPortUnreachable.write(bufferWord);
248 case IP_PORT_UNREACHABLE_RESIDUE:
249 if (!inputPathPortUnreachable.full()) {
251 bufferWord.
data.range(31, 0) = bufferWord.
data.range(63, 32);
252 bufferWord.
keep.range(3, 0) = bufferWord.
keep.range(7, 4);
253 inputPathPortUnreachable.write(bufferWord);
254 inputPathState = IP_IDLE;
258 if (!inputPathIPheader.empty()) {
259 inputPathIPheader.read();
260 if (rxEngIpHdrWordCount > 2)
261 rxEngIpHdrWordCount -= 2;
263 inputPathState = IP_IDLE;
269 void stripIpHeader(stream<axiWord> &inputPathInData, stream<axiWord> &strip2inputPath_data, stream<axiWord> &strip2inputPath_IpHeader, stream<ipTuple> &strip2inputPath_IP, stream<axiWord> &strip2rxChecksum) {
270 #pragma HLS INLINE off
271 #pragma HLS pipeline II=1 enable_flush
273 static enum sState{STRIP_IDLE = 0, STRIP_IP, STRIP_SKIPOPTIONS, STRIP_IP2, STRIP_FORWARD, STRIP_FORWARDALIGNED, STRIP_FORWARD_CS, STRIP_FORWARDCSALIGNED, STRIP_RESIDUE, STRIP_CS_RESIDUE, STRIP_CS_RESIDUEALIGNNED} stripState;
276 static ap_uint<16> udpLength = 0;
277 static ap_uint<4> ipHeaderLength = 0;
278 static ap_uint<4> bitCounter = 0;
279 static ap_uint<3> ipHdrWordCount = 0;
283 if (!inputPathInData.empty() && !strip2inputPath_IpHeader.full()) {
286 outputWord = inputPathInData.read();
287 udpLength = (outputWord.
data.range(23, 16), outputWord.
data.range(31, 24));
288 ipHeaderLength = outputWord.
data.range(3, 0);
289 udpLength = udpLength - (ipHeaderLength * 4);
290 strip2inputPath_IpHeader.write(outputWord);
291 stripState = STRIP_IP;
295 if (!inputPathInData.empty() && !strip2inputPath_IpHeader.full()) {
296 outputWord = inputPathInData.read();
298 strip2inputPath_IpHeader.write(outputWord);
301 if (ipHeaderLength == 3)
302 stripState = STRIP_IP2;
303 else if (ipHeaderLength > 3)
304 stripState = STRIP_SKIPOPTIONS;
307 case STRIP_SKIPOPTIONS:
308 if (!inputPathInData.empty() && !strip2inputPath_IpHeader.full() && !strip2inputPath_IP.full()) {
309 outputWord = inputPathInData.read();
310 if (ipHdrWordCount == 1) {
312 strip2inputPath_IP.write(stripIpTuple);
315 strip2rxChecksum.write(checksumWord);
317 strip2inputPath_IpHeader.write(outputWord);
320 if (ipHeaderLength == 2)
321 stripState = STRIP_FORWARDALIGNED;
322 else if (ipHeaderLength == 3)
323 stripState = STRIP_IP2;
324 else if (ipHeaderLength > 3)
325 stripState = STRIP_SKIPOPTIONS;
329 if (!inputPathInData.empty() && !strip2rxChecksum.full() && !strip2inputPath_IP.full()) {
330 outputWord = inputPathInData.read();
331 if (ipHdrWordCount == 1) {
333 strip2inputPath_IP.write(stripIpTuple);
335 strip2rxChecksum.write(checksumWord);
337 strip2inputPath_IpHeader.write(
axiWord(outputWord.
data.range(31, 0), 0x0F, 1));
338 stripState = STRIP_FORWARD;
341 case STRIP_FORWARDALIGNED:
342 if (!inputPathInData.empty() && !strip2rxChecksum.full() && !strip2inputPath_data.full()) {
343 outputWord = inputPathInData.read();
345 checksumWord.
data.range(31, 16) =
byteSwap16(udpLength.range(15, 0));
346 checksumWord.
data.range(63, 32) = outputWord.
data.range(31, 0);
347 strip2rxChecksum.write(checksumWord);
348 strip2inputPath_data.write(outputWord);
349 stripState = STRIP_FORWARDCSALIGNED;
353 if (!inputPathInData.empty() && !strip2rxChecksum.full() && !strip2inputPath_data.full()) {
355 checksumWord.
data.range(31, 16) =
byteSwap16(udpLength.range(15, 0));
356 checksumWord.
data.range(63, 32) = outputWord.
data.range(63, 32);
357 strip2rxChecksum.write(checksumWord);
359 tempWord.
data.range(31, 0) = outputWord.
data.range(63, 32);
360 outputWord = inputPathInData.read();
361 tempWord.
data.range(63, 32) = outputWord.
data.range(31, 0);
362 tempWord.
keep.range(7, 4) = outputWord.
keep.range(3, 0);
363 strip2inputPath_data.write(tempWord);
364 if (outputWord.
last == 1) {
366 stripState = STRIP_RESIDUE;
369 stripState = STRIP_FORWARD_CS;
372 case STRIP_FORWARDCSALIGNED:
373 if (!inputPathInData.empty() && !strip2rxChecksum.full() && !strip2inputPath_data.full()) {
375 checksumWord.
data.range(31, 0) = outputWord.
data.range(63, 32);
376 outputWord = inputPathInData.read();
377 checksumWord.
data.range(63, 32) = outputWord.
data.range(31, 0);
378 strip2rxChecksum.write(checksumWord);
379 strip2inputPath_data.write(outputWord);
380 if (outputWord.
last == 1) {
381 if (outputWord.
keep.range(7, 4) > 0)
382 stripState = STRIP_CS_RESIDUEALIGNNED;
384 stripState = STRIP_IDLE;
388 case STRIP_FORWARD_CS:
389 if (!inputPathInData.empty() && !strip2rxChecksum.full() && !strip2inputPath_data.full()) {
390 strip2rxChecksum.write(outputWord);
393 tempWord.
data.range(31, 0) = outputWord.
data.range(63, 32);
394 outputWord = inputPathInData.read();
395 tempWord.
data.range(63, 32) = outputWord.
data.range(31, 0);
396 tempWord.
keep.range(7, 4) = outputWord.
keep.range(3, 0);
397 if (outputWord.
last == 1) {
399 if (outputWord.
keep.range(7, 4) != 0)
400 stripState = STRIP_RESIDUE;
402 tempWord.
keep.range(7,4) = outputWord.
keep.range(3, 0);
404 stripState = STRIP_CS_RESIDUE;
407 strip2inputPath_data.write(tempWord);
411 if (!strip2rxChecksum.full() && !strip2inputPath_data.full()) {
414 csWord.
data.range((bitCounter.to_int() * 8) - 1, 0) = outputWord.
data.range((bitCounter.to_int() * 8) - 1, 0);
415 strip2rxChecksum.write(csWord);
417 tempWord.
data.range(31, 0) = outputWord.
data.range(63, 32);
418 tempWord.
keep.range(3, 0) = outputWord.
keep.range(7, 4);
420 strip2inputPath_data.write(tempWord);
421 stripState = STRIP_IDLE;
424 case STRIP_CS_RESIDUE:
425 if (!strip2rxChecksum.full()) {
427 csWord.
data.range((bitCounter.to_int() * 8) - 1, 0) = outputWord.
data.range((bitCounter.to_int() * 8) - 1, 0);
428 strip2rxChecksum.write(csWord);
429 stripState = STRIP_IDLE;
432 case STRIP_CS_RESIDUEALIGNNED:
433 if (!strip2rxChecksum.full()) {
436 strip2rxChecksum.write(
axiWord(outputWord.
data.range(63, 32), outputWord.
keep.range(7, 4), 1));
437 stripState = STRIP_IDLE;
444 stream<bool> &udpChecksumOut) {
445 #pragma HLS INLINE off
446 #pragma HLS pipeline II=1 enable_flush
448 static ap_uint<32> udpChecksum = 0;
449 static ap_uint<16> receivedChecksum = 0;
450 static ap_uint<10> wordCounter = 0;
452 if (!dataIn.empty()) {
454 axiWord inputWord = dataIn.read();
456 receivedChecksum = (inputWord.
data.range(23, 16), inputWord.
data.range(31, 24));
457 udpChecksum = ((((udpChecksum + inputWord.
data.range(63, 48)) + inputWord.
data.range(47, 32)) + inputWord.
data.range(31, 16)) + inputWord.
data.range(15, 0));
458 if (inputWord.
last) {
460 udpChecksum = (udpChecksum & 0xFFFF) + (udpChecksum >> 16);
461 udpChecksum = (udpChecksum & 0xFFFF) + (udpChecksum >> 16);
462 udpChecksum = ~udpChecksum;
463 ap_uint<16> tempChecksum = udpChecksum.range(15, 0);
464 udpChecksumOut.write(tempChecksum == 0 || receivedChecksum == 0);
482 stream<axiWord> &inputPathInData,
483 stream<ap_uint<16> > &app2portTable_port_req,
484 stream<ap_uint<16> > &app2portTable_port_rel,
485 stream<bool> &portTable2app_port_assign,
486 stream<axiWord> &inputPathOutData,
487 stream<metadata> &inputPathOutputMetadata,
488 stream<axiWord> &inputPathPortUnreachable) {
491 static stream<ap_uint<16> > rxEng2portTable_check_req(
"rxEng2portTable_check_req");
492 static stream<bool> portTable2rxEng_assign(
"portTable2rxEng_assign");
493 static stream<axiWord> strip2inputPath_data(
"strip2inputPath_data");
494 static stream<ipTuple> strip2inputPath_IP(
"strip2inputPath_IP");
495 static stream<axiWord> strip2rxChecksum(
"strip2rxChecksum");
496 static stream<bool> rxChecksum2rxEngine(
"rxChecksum2rxEngine");
497 static stream<axiWord> strip2inputPath_IPheader(
"strip2inputPath_IPheader");
499 #pragma HLS STREAM variable=strip2inputPath_data depth=4096
500 #pragma HLS STREAM variable=strip2inputPath_IPheader depth=32
501 #pragma HLS STREAM variable=strip2inputPath_IP depth=8
502 #pragma HLS STREAM variable=strip2rxChecksum depth=8
503 #pragma HLS STREAM variable=rxChecksum2rxEngine depth=4
505 stripIpHeader(inputPathInData, strip2inputPath_data, strip2inputPath_IPheader, strip2inputPath_IP, strip2rxChecksum);
507 inputPathRxEngine(strip2inputPath_data, strip2inputPath_IP, strip2inputPath_IPheader, rxEng2portTable_check_req, portTable2rxEng_assign, rxChecksum2rxEngine, inputPathOutData, inputPathOutputMetadata, inputPathPortUnreachable);
508 portTable(rxEng2portTable_check_req, app2portTable_port_req, app2portTable_port_rel, portTable2app_port_assign, portTable2rxEng_assign);
512 stream<ap_uint<64> > &packetData,
stream<ap_uint<16> > &packetLength, stream<metadata> &udpMetadata,
513 stream<ioWord> &outputPathWriteFunction2checksumCalculation) {
514 #pragma HLS INLINE off
515 #pragma HLS pipeline II=1 enable_flush
517 static enum opwfState{OW_IDLE = 0, OW_PSEUDOHEADER, OW_MIX, OW_STREAM, OW_RESIDUE, OW_SWCS, OW_ONLYPACKETRESIDUE} outputPathWriteFunctionState;
519 static ap_uint<16> outputPathPacketLength = 0;
522 switch(outputPathWriteFunctionState) {
524 if (!outputPathInMetadata.empty() && !outputPathWriteFunction2checksumCalculation.full()) {
525 tempMetadata = outputPathInMetadata.read();
526 udpMetadata.write(tempMetadata);
527 ioWord checksumOutput = {0, 0};
529 outputPathWriteFunction2checksumCalculation.write(checksumOutput);
530 outputPathWriteFunctionState = OW_PSEUDOHEADER;
533 case OW_PSEUDOHEADER:
534 if (!outputpathInLength.empty() && !outputPathWriteFunction2checksumCalculation.full()) {
535 outputPathPacketLength = outputpathInLength.read();
536 outputPathPacketLength += 8;
537 packetLength.write(outputPathPacketLength);
538 ioWord checksumOutput = {0x1100, 0};
541 outputPathWriteFunction2checksumCalculation.write(checksumOutput);
542 outputPathWriteFunctionState = OW_MIX;
546 if (!outputPathInData.empty() && !outputPathWriteFunction2checksumCalculation.full()) {
547 outputPathInputWord = outputPathInData.read();
548 ioWord checksumOutput = {0, 0};
549 checksumOutput.
data.range(15, 0) = (outputPathPacketLength.range(7, 0), outputPathPacketLength.range(15, 8));
550 checksumOutput.
data.range(63, 32) = outputPathInputWord.
data.range(31, 0);
551 if (outputPathInputWord.
last == 1) {
552 packetData.write(outputPathInputWord.
data);
553 if (outputPathInputWord.
keep.range(7, 4) == 0) {
554 outputPathWriteFunctionState = OW_IDLE;
555 checksumOutput.
eop = 1;
558 outputPathWriteFunctionState = OW_SWCS;
561 outputPathWriteFunctionState = OW_STREAM;
562 outputPathWriteFunction2checksumCalculation.write(checksumOutput);
566 if (!outputPathInData.empty() && !packetData.full() && !outputPathWriteFunction2checksumCalculation.full()) {
567 packetData.write(outputPathInputWord.
data);
568 ioWord checksumOutput = {0, 0};
569 checksumOutput.
data.range(31,0) = outputPathInputWord.
data.range(63, 32);
570 outputPathInputWord = outputPathInData.read();
571 checksumOutput.
data.range(63, 32) = outputPathInputWord.
data.range(31, 0);
572 if (outputPathInputWord.
last == 1) {
573 if (outputPathInputWord.
keep.bit(4) == 1)
574 outputPathWriteFunctionState = OW_RESIDUE;
576 outputPathWriteFunctionState = OW_ONLYPACKETRESIDUE;
577 checksumOutput.
eop = 1;
580 outputPathWriteFunction2checksumCalculation.write(checksumOutput);
583 case OW_ONLYPACKETRESIDUE:
584 if (!packetData.full()) {
585 packetData.write(outputPathInputWord.
data);
586 outputPathWriteFunctionState = OW_IDLE;
590 if (!outputPathWriteFunction2checksumCalculation.full()) {
591 ioWord checksumOutput = {0, 1};
592 checksumOutput.
data.range(31, 0) = outputPathInputWord.
data.range(63, 32);
593 outputPathWriteFunction2checksumCalculation.write(checksumOutput);
594 outputPathWriteFunctionState = OW_IDLE;
598 if (!packetData.full() && !outputPathWriteFunction2checksumCalculation.full()) {
599 ioWord checksumOutput = {0, 1};
600 checksumOutput.
data.range(31, 0) = outputPathInputWord.
data.range(63, 32);
601 outputPathWriteFunction2checksumCalculation.write(checksumOutput);
602 packetData.write(outputPathInputWord.
data);
603 outputPathWriteFunctionState = OW_IDLE;
610 stream<ap_uint<16> >& udpChecksumOut) {
611 #pragma HLS INLINE off
612 #pragma HLS pipeline II=1 enable_flush
614 static ap_uint<32> udpChecksum = 0;
616 if (!dataIn.empty()) {
617 ioWord inputWord = dataIn.read();
618 udpChecksum = ((((udpChecksum + inputWord.
data.range(63, 48)) + inputWord.
data.range(47, 32)) + inputWord.
data.range(31, 16)) + inputWord.
data.range(15, 0));
620 udpChecksum = (udpChecksum & 0xFFFF) + (udpChecksum >> 16);
621 udpChecksum = (udpChecksum & 0xFFFF) + (udpChecksum >> 16);
622 udpChecksum = ~udpChecksum;
623 udpChecksumOut.write(udpChecksum.range(15, 0));
630 stream<axiWord> &outputPathOutData, stream<ipTuple> &outIPaddresses,
stream<ap_uint<16> > &outputPathReadFunction2addIpHeader_length) {
632 #pragma HLS INLINE off
633 #pragma HLS pipeline II=1 enable_flush
635 static enum oprfState{OR_IDLE = 0, OR_STREAM} outputPathReadFunctionState;
636 static ap_uint<16> readFunctionOutputPathPacketLength;
637 static uint32_t myPacketCounter = 0;
639 switch(outputPathReadFunctionState) {
641 if (!packetLength.empty() && !udpMetadata.empty() && !udpChecksum.empty() ) {
645 packetLength.read(readFunctionOutputPathPacketLength);
646 ap_uint<16> interimLength = readFunctionOutputPathPacketLength;
647 readFunctionOutputPathPacketLength -= 8;
648 outputPathReadFunction2addIpHeader_length.write(interimLength);
649 metadata tempMetadata = udpMetadata.read();
654 outputWord.
data.range(63, 48) = udpChecksum.read();
656 outputPathOutData.write(outputWord);
658 outIPaddresses.write(tempIPaddresses);
659 outputPathReadFunctionState = OR_STREAM;
663 if (!packetData.empty()) {
664 ap_uint<64> inputWord = packetData.read();
667 if (readFunctionOutputPathPacketLength > 8)
668 readFunctionOutputPathPacketLength -= 8;
672 readFunctionOutputPathPacketLength = 0;
673 outputPathReadFunctionState = OR_IDLE;
675 outputPathOutData.write(outputWord);
681 void addIpHeader(stream<axiWord> &outputPathRead2addIpHeader_data, stream<ipTuple> &outputPathRead2addIpHeader_ipAddress,
682 stream<axiWord> &outputPathOutData,
stream<ap_uint<16> > &outputPathReadFunction2addIpHeader_length) {
684 #pragma HLS pipeline II=1 enable_flush
686 static enum iState {IPH_IDLE, IPH_IP1, IPH_IP2, IPH_FORWARD, IPH_RESIDUE} iphState;
692 if(!outputPathRead2addIpHeader_data.empty() && !outputPathRead2addIpHeader_ipAddress.empty() &&!outputPathReadFunction2addIpHeader_length.empty() && !outputPathOutData.full()) {
693 ap_uint<16> tempLength = outputPathReadFunction2addIpHeader_length.read();
698 outputPathOutData.write(tempWord);
703 if(!outputPathRead2addIpHeader_data.empty() && !outputPathRead2addIpHeader_ipAddress.empty() && !outputPathOutData.full()) {
705 ipHeaderTuple = outputPathRead2addIpHeader_ipAddress.read();
706 tempWord.
data.range(31, 0) = 0x000011FF;
708 outputPathOutData.write(tempWord);
713 if(!outputPathRead2addIpHeader_data.empty() && !outputPathOutData.full()) {
715 outputWord = outputPathRead2addIpHeader_data.read();
717 tempWord.
data.range(63, 32) = outputWord.
data.range(31, 0);
718 outputPathOutData.write(tempWord);
719 iphState = IPH_FORWARD;
723 if(!outputPathRead2addIpHeader_data.empty() && !outputPathOutData.full()) {
725 tempWord.
data.range(31, 0) = outputWord.
data.range(63, 32);
726 outputWord = outputPathRead2addIpHeader_data.read();
727 tempWord.
data.range(63, 32) = outputWord.
data.range(31, 0);
728 if(outputWord.
last) {
729 if (outputWord.
keep.range(7, 4) != 0) {
730 tempWord.
keep.range(7, 4) = 0xF;
731 iphState = IPH_RESIDUE;
734 tempWord.
keep.range(7, 4) = outputWord.
keep.range(3, 0);
740 tempWord.
keep.range(7, 4) = 0xF;
741 outputPathOutData.write(tempWord);
745 if (!outputPathOutData.full()) {
747 outputPathOutData.write(tempWord);
766 stream<axiWord> &outputPathInData,
767 stream<metadata> &outputPathInMetadata,
768 stream<ap_uint<16> > &outputpathInLength,
769 stream<axiWord> &outputPathOutData) {
774 static stream<ap_uint<64> > packetData(
"packetData");
775 static stream<ap_uint<16> > packetLength(
"packetLength");
776 static stream<metadata> udpMetadata(
"udpMetadata");
777 static stream<ap_uint<16> > checksumCalculation2outputPathReadFunction(
"checksumCalculation2outputPathReadFunction");
778 static stream<ioWord> outputPathWriteFunction2checksumCalculation(
"outputPathWriteFunction2checksumCalculation");
779 static stream<axiWord> outputPathRead2addIpHeader_data(
"outputPathRead2addIpHeader_data");
780 static stream<ipTuple> outputPathRead2addIpHeader_ipAddress(
"outputPathRead2addIpHeader_ipAddress");
781 static stream<ap_uint<16> > outputPathReadFunction2addIpHeader_length(
"outputPathReadFunction2addIpHeader_length");
783 #pragma HLS DATA_PACK variable=udpMetadata
784 #pragma HLS DATA_PACK variable=outputPathRead2addIpHeader_ipAddress
786 #pragma HLS STREAM variable=packetData depth=4096
787 #pragma HLS STREAM variable=packetLength depth=8
788 #pragma HLS STREAM variable=udpMetadata depth=8
789 #pragma HLS STREAM variable=outputPathWriteFunction2checksumCalculation depth=32
791 outputPathWriteFunction(outputPathInData, outputPathInMetadata, outputpathInLength, packetData, packetLength, udpMetadata,
792 outputPathWriteFunction2checksumCalculation);
793 udpChecksumCalculation(outputPathWriteFunction2checksumCalculation, checksumCalculation2outputPathReadFunction);
794 outputPathReadFunction(packetData, packetLength, udpMetadata, checksumCalculation2outputPathReadFunction, outputPathRead2addIpHeader_data, outputPathRead2addIpHeader_ipAddress, outputPathReadFunction2addIpHeader_length);
795 addIpHeader(outputPathRead2addIpHeader_data, outputPathRead2addIpHeader_ipAddress, outputPathOutData, outputPathReadFunction2addIpHeader_length);
815 stream<ap_uint<16> > &openPort,
816 stream<bool> &confirmPortStatus,
820 stream<axiWord> &inputPathInData,
821 stream<axiWord> &inputpathOutData,
824 stream<metadata> &inputPathOutputMetadata,
825 stream<ap_uint<16> > &portRelease,
826 stream<axiWord> &outputPathInData,
827 stream<axiWord> &outputPathOutData,
828 stream<metadata> &outputPathInMetadata,
829 stream<ap_uint<16> > &outputpathInLength,
830 stream<axiWord> &inputPathPortUnreachable) {
832 #pragma HLS INTERFACE ap_ctrl_none port=return
833 #pragma HLS DATAFLOW interval=1
835 #pragma HLS DATA_PACK variable=inputPathOutputMetadata
836 #pragma HLS DATA_PACK variable=outputPathInMetadata
839 #pragma HLS resource core=AXI4Stream variable=inputPathInData metadata="-bus_bundle inputPathInData"
840 #pragma HLS resource core=AXI4Stream variable=inputpathOutData metadata="-bus_bundle inputpathOutData"
841 #pragma HLS resource core=AXI4Stream variable=openPort metadata="-bus_bundle openPort"
842 #pragma HLS resource core=AXI4Stream variable=confirmPortStatus metadata="-bus_bundle confirmPortStatus"
843 #pragma HLS resource core=AXI4Stream variable=inputPathOutputMetadata metadata="-bus_bundle inputPathOutputMetadata"
844 #pragma HLS resource core=AXI4Stream variable=portRelease metadata="-bus_bundle portRelease"
845 #pragma HLS resource core=AXI4Stream variable=outputPathInData metadata="-bus_bundle outputPathInData"
846 #pragma HLS resource core=AXI4Stream variable=outputPathOutData metadata="-bus_bundle outputPathOutData"
847 #pragma HLS resource core=AXI4Stream variable=outputPathInMetadata metadata="-bus_bundle outputPathInMetadata"
848 #pragma HLS resource core=AXI4Stream variable=inputPathPortUnreachable metadata="-bus_bundle inputPathPortUnreachable"
849 #pragma HLS resource core=AXI4Stream variable=outputpathInLength metadata="-bus_bundle outputpathInLength"
853 rxEngine(inputPathInData, openPort, portRelease, confirmPortStatus, inputpathOutData, inputPathOutputMetadata, inputPathPortUnreachable);
854 txEngine(outputPathInData, outputPathInMetadata, outputpathInLength, outputPathOutData);
ap_uint< 32 > destinationIP
void outputPathWriteFunction(stream< axiWord > &outputPathInData, stream< metadata > &outputPathInMetadata, stream< ap_uint< 16 > > &outputpathInLength, stream< ap_uint< 64 > > &packetData, stream< ap_uint< 16 > > &packetLength, stream< metadata > &udpMetadata, stream< ioWord > &outputPathWriteFunction2checksumCalculation)
void rxEngine(stream< axiWord > &inputPathInData, stream< ap_uint< 16 > > &app2portTable_port_req, stream< ap_uint< 16 > > &app2portTable_port_rel, stream< bool > &portTable2app_port_assign, stream< axiWord > &inputPathOutData, stream< metadata > &inputPathOutputMetadata, stream< axiWord > &inputPathPortUnreachable)
void addIpHeader(stream< axiWord > &outputPathRead2addIpHeader_data, stream< ipTuple > &outputPathRead2addIpHeader_ipAddress, stream< axiWord > &outputPathOutData, stream< ap_uint< 16 > > &outputPathReadFunction2addIpHeader_length)
void stripIpHeader(stream< axiWord > &inputPathInData, stream< axiWord > &strip2inputPath_data, stream< axiWord > &strip2inputPath_IpHeader, stream< ipTuple > &strip2inputPath_IP, stream< axiWord > &strip2rxChecksum)
ap_uint< 8 > length2keep_mapping(ap_uint< 4 > lengthValue)
void rxEngineUdpChecksumVerification(stream< axiWord > &dataIn, stream< bool > &udpChecksumOut)
void txEngine(stream< axiWord > &outputPathInData, stream< metadata > &outputPathInMetadata, stream< ap_uint< 16 > > &outputpathInLength, stream< axiWord > &outputPathOutData)
void outputPathReadFunction(stream< ap_uint< 64 > > &packetData, stream< ap_uint< 16 > > &packetLength, stream< metadata > &udpMetadata, stream< ap_uint< 16 > > &udpChecksum, stream< axiWord > &outputPathOutData, stream< ipTuple > &outIPaddresses, stream< ap_uint< 16 > > &outputPathReadFunction2addIpHeader_length)
void udp(stream< ap_uint< 16 > > &openPort, stream< bool > &confirmPortStatus, stream< axiWord > &inputPathInData, stream< axiWord > &inputpathOutData, stream< metadata > &inputPathOutputMetadata, stream< ap_uint< 16 > > &portRelease, stream< axiWord > &outputPathInData, stream< axiWord > &outputPathOutData, stream< metadata > &outputPathInMetadata, stream< ap_uint< 16 > > &outputpathInLength, stream< axiWord > &inputPathPortUnreachable)
void udpChecksumCalculation(stream< ioWord > &dataIn, stream< ap_uint< 16 > > &udpChecksumOut)
ap_uint< 4 > countBits(ap_uint< 8 > bitVector)
void inputPathRxEngine(stream< axiWord > &inputPathInputData, stream< ipTuple > &incomingIPaddresses, stream< axiWord > &inputPathIPheader, stream< ap_uint< 16 > > &rxEng2portTable_check_req, stream< bool > &portTable2rxEng_assign, stream< bool > &rxChecksum2rxEngine, stream< axiWord > &inputPathOutputData, stream< metadata > &inputPathOutputMetadata, stream< axiWord > &inputPathPortUnreachable)
void portTable(stream< ap_uint< 16 > > &rxEng2portTable_check_req, stream< ap_uint< 16 > > &app2portTable_port_req, stream< ap_uint< 16 > > &app2portTable_port_rel, stream< bool > &portTable2app_port_assign, stream< bool > &portTable2rxEng_check_rsp)
ap_uint< 32 > byteSwap32(ap_uint< 32 > inputVector)
ap_uint< 16 > byteSwap16(ap_uint< 16 > inputVector)