cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
iptx.cpp
Go to the documentation of this file.
1 
17 
43 
56 #include "iptx.hpp"
57 
58 using namespace hls;
59 
60 
61 
65 #ifndef __SYNTHESIS__
66  extern bool gTraceEvent;
67 #endif
68 #define THIS_NAME "IPTX"
69 
70 #define TRACE_OFF 0x0000
71 #define TRACE_ICA 1 << 1
72 #define TRACE_ICI 1 << 2
73 #define TRACE_IAE 1 << 3
74 #define TRACE_MAI 1 << 4
75 #define TRACE_ALL 0xFFFF
76 
77 #define DEBUG_LEVEL (TRACE_OFF)
78 
79 
80 
108  stream<AxisIp4> &siL3MUX_Data,
109  stream<AxisIp4> &soICi_Data,
110  stream<Ip4HdrCsum> &soICi_Csum)
111 {
112  //-- DIRECTIVES FOR THIS PROCESS ------------------------------------------
113  #pragma HLS INLINE off
114  #pragma HLS PIPELINE II=1 enable_flush
115 
116  const char *myName = concat3(THIS_NAME, "/", "HCa");
117 
118  //-- STATIC CONTROL VARIABLES (with RESET) --------------------------------
119  static bool hca_csumWritten=true;
120  #pragma HLS RESET variable=hca_csumWritten
121  static enum FsmState {S0=0, S1, S2, S3} hca_fsmState=S0;
122  #pragma HLS RESET variable=hca_fsmState
123  static ap_uint<17> hca_ipHdrCsum[4]={0, 0, 0, 0};
124  #pragma HLS RESET variable=hca_ipHdrCsum
125  #pragma HLS ARRAY_PARTITION variable=hca_ipHdrCsum complete dim=1
126  static ap_uint<3> hca_chunkCount=0;
127  #pragma HLS RESET variable=hca_chunkCount
128 
129  //-- STATIC DATAFLOW VARIABLES --------------------------------------------
130  static ap_uint<4> hca_ipHdrLen;
131 
132  //-- DYNAMIC VARIABLES ----------------------------------------------------
133  AxisIp4 currChunk;
134  Ip4HdrCsum tempHdrCsum;
135 
136  currChunk.setLE_TLast(0);
137  if(!hca_csumWritten) {
138  switch (hca_fsmState) {
139  case S0:
140  hca_ipHdrCsum[0] += hca_ipHdrCsum[2];
141  hca_ipHdrCsum[1] += hca_ipHdrCsum[3];
142  hca_ipHdrCsum[0] = (hca_ipHdrCsum[0] + (hca_ipHdrCsum[0] >> 16)) & 0xFFFF;
143  hca_ipHdrCsum[1] = (hca_ipHdrCsum[1] + (hca_ipHdrCsum[1] >> 16)) & 0xFFFF;
144  hca_fsmState = S1;
145  break;
146  case S1:
147  hca_ipHdrCsum[0] += hca_ipHdrCsum[1];
148  hca_ipHdrCsum[0] = (hca_ipHdrCsum[0] + (hca_ipHdrCsum[0] >> 16)) & 0xFFFF;
149  hca_fsmState = S2;
150  break;
151  case S2:
152  hca_ipHdrCsum[0] = ~hca_ipHdrCsum[0];
153  soICi_Csum.write(hca_ipHdrCsum[0](15, 0));
154  hca_fsmState = S3;
155  break;
156  case S3:
157  hca_ipHdrCsum[0] = 0;
158  hca_ipHdrCsum[1] = 0;
159  hca_ipHdrCsum[2] = 0;
160  hca_ipHdrCsum[3] = 0;
161  hca_csumWritten = true;
162  hca_fsmState = S0;
163  break;
164  }
165  }
166  else if (!siL3MUX_Data.empty() and !soICi_Data.full() and hca_csumWritten) {
167  siL3MUX_Data.read(currChunk);
168  // Process the IPv4 header.
169  // Remember that the Internet Header Length (IHL) field contains the
170  // size of the IPv4 header specified in number of 32-bit words, and
171  // its default minimum value is 5.
172  switch (hca_chunkCount) {
173  case 0:
174  hca_ipHdrLen = currChunk.getIp4HdrLen();
175  //-- Accumulate 1st IPv4 header qword [Frag|Ident|TotLen|ToS|IHL]
176  for (int i=0; i<4; i++) {
177  #pragma HLS UNROLL
178  tempHdrCsum( 7, 0) = currChunk.getLE_TData().range(i*16+15, i*16+8);
179  tempHdrCsum(15, 8) = currChunk.getLE_TData().range(i*16+7, i*16);
180  hca_ipHdrCsum[i] += tempHdrCsum;
181  hca_ipHdrCsum[i] = (hca_ipHdrCsum[i] + (hca_ipHdrCsum[i] >> 16)) & 0xFFFF;
182  }
183  hca_chunkCount++;
184  hca_ipHdrLen -= 2;
185  break;
186  case 1:
187  //-- Accumulate 2nd IPv4 header qword [SA|HdCsum|Prot|TTL]
188  for (int i=0; i<4; i++) {
189  #pragma HLS UNROLL
190  if (i != 1) {
191  // Skip 3rd and 4th bytes. They contain the IP header checksum.
192  tempHdrCsum( 7, 0) = currChunk.getLE_TData().range(i*16+15, i*16+8);
193  tempHdrCsum(15, 8) = currChunk.getLE_TData().range(i*16+7, i*16);
194  hca_ipHdrCsum[i] += tempHdrCsum;
195  hca_ipHdrCsum[i] = (hca_ipHdrCsum[i] + (hca_ipHdrCsum[i] >> 16)) & 0xFFFF;
196  }
197  }
198  hca_chunkCount++;
199  hca_ipHdrLen -= 2;
200  break;
201  default:
202  switch (hca_ipHdrLen) {
203  case 0:
204  //-- We are done with the checksum header processing
205  break;
206  case 1:
207  //-- Accumulate half of the 3rd IPv4 header qword [DA] or
208  //-- Accumulate the last IPv4 option dword
209  for (int i = 0; i < 2; i++) {
210  #pragma HLS UNROLL
211  tempHdrCsum( 7, 0) = currChunk.getLE_TData().range(i*16+15, i*16+8);
212  tempHdrCsum(15, 8) = currChunk.getLE_TData().range(i*16+7, i*16);
213  hca_ipHdrCsum[i] += tempHdrCsum;
214  hca_ipHdrCsum[i] = (hca_ipHdrCsum[i] + (hca_ipHdrCsum[i] >> 16)) & 0xFFFF;
215  }
216  hca_ipHdrLen = 0;
217  hca_csumWritten = false;
218  break;
219  default:
220  // Sum up everything
221  for (int i = 0; i < 4; i++) {
222  #pragma HLS UNROLL
223  tempHdrCsum( 7, 0) = currChunk.getLE_TData().range(i*16+15, i*16+8);
224  tempHdrCsum(15, 8) = currChunk.getLE_TData().range(i*16+7, i*16);
225  hca_ipHdrCsum[i] += tempHdrCsum;
226  hca_ipHdrCsum[i] = (hca_ipHdrCsum[i] + (hca_ipHdrCsum[i] >> 16)) & 0xFFFF;
227  }
228  hca_ipHdrLen -= 2;
229  if (hca_ipHdrLen == 0) {
230  hca_csumWritten = false;
231  }
232  break;
233  } // End-of: switch ipHeaderLen
234  break;
235  } // End-of: switch(hca_chunkCount)
236  soICi_Data.write(currChunk);
237  if (currChunk.getLE_TLast()) {
238  hca_chunkCount = 0;
239  }
240  }
241 }
242 
243 
256  stream<AxisIp4> &siHCa_Data,
257  stream<Ip4HdrCsum> &siHCa_Csum,
258  stream<AxisIp4> &soIAe_Data)
259 {
260  //-- DIRECTIVES FOR THIS PROCESS -------------------------------------------
261  #pragma HLS INLINE off
262  #pragma HLS PIPELINE II=1 enable_flush
263 
264  const char *myName = concat3(THIS_NAME, "/", "ICi");
265 
266  //-- STATIC CONTROL VARIABLES (with RESET) ---------------------------------
267  static enum FsmStates { S0=0, S1, S2 } ici_fsmState=S0;
268  #pragma HLS RESET variable=ici_fsmState
269 
270  //-- DYNAMIC VARIABLES -----------------------------------------------------
271  AxisIp4 currChunk;
272  Ip4HdrCsum ipHdrChecksum;
273 
274  currChunk.setLE_TLast(0);
275  switch (ici_fsmState) {
276  case S0:
277  if (!siHCa_Data.empty() and !soIAe_Data.full()) {
278  siHCa_Data.read(currChunk);
279  soIAe_Data.write(currChunk);
280  ici_fsmState = S1;
281  }
282  break;
283  case S1:
284  if (!siHCa_Data.empty() and !siHCa_Csum.empty() and !soIAe_Data.full()) {
285  siHCa_Data.read(currChunk);
286  siHCa_Csum.read(ipHdrChecksum);
287  // Insert the computed ipHeaderChecksum in the incoming stream
288  currChunk.setIp4HdrCsum(ipHdrChecksum);
289  soIAe_Data.write(currChunk);
290  ici_fsmState = S2;
291  }
292  break;
293  default:
294  if (!siHCa_Data.empty() and !soIAe_Data.full()) {
295  siHCa_Data.read(currChunk);
296  soIAe_Data.write(currChunk);
297  }
298  break;
299  } // End-of: switch()
300 
301  if (currChunk.getLE_TLast()) {
302  ici_fsmState = S0;
303  }
304 }
305 
306 
321  Ip4Addr piMMIO_SubNetMask,
322  Ip4Addr piMMIO_GatewayAddr,
323  stream<AxisIp4> &siICi_Data,
324  stream<AxisIp4> &soMAi_Data,
325  stream<Ip4Addr> &soARP_LookupReq)
326 {
327  //-- DIRECTIVES FOR THIS PROCESS -------------------------------------------
328  #pragma HLS INLINE off
329  #pragma HLS PIPELINE II=1 enable_flush
330 
331  const char *myName = concat3(THIS_NAME, "/", "IAe");
332 
333  //-- STATIC CONTROL VARIABLES (with RESET) ---------------------------------
334  static ap_uint<2> iae_chunkCount=0;
335  #pragma HLS RESET variable=iae_chunkCount
336 
337  //-- DYNAMIC VARIABLES -----------------------------------------------------
338  Ip4Addr ipDestAddr;
339 
340  if (!siICi_Data.empty() and !soMAi_Data.full()) {
341  AxisIp4 currChunk = siICi_Data.read();
342  switch (iae_chunkCount) {
343  case 2: // Extract destination IP address
344  ipDestAddr = currChunk.getIp4DstAddr();
345  if ((ipDestAddr & piMMIO_SubNetMask) == (piMMIO_GatewayAddr & piMMIO_SubNetMask)
346  || (ipDestAddr == 0xFFFFFFFF)) {
347  soARP_LookupReq.write(ipDestAddr);
348  }
349  else {
350  soARP_LookupReq.write(piMMIO_GatewayAddr);
351  }
352  iae_chunkCount++;
353  break;
354  default:
355  if (currChunk.getLE_TLast()) {
356  iae_chunkCount = 0;
357  }
358  else if (iae_chunkCount < 3) {
359  iae_chunkCount++;
360  }
361  break;
362  } // End-of: switch()
363  soMAi_Data.write(currChunk);
364  }
365 }
366 
367 
380  EthAddr piMMIO_MacAddress,
381  stream<AxisIp4> &siIAe_Data,
382  stream<ArpLkpReply> &siARP_LookupRsp,
383  stream<AxisEth> &soL2MUX_Data)
384 {
385  //-- DIRECTIVES FOR THIS PROCESS -------------------------------------------
386  #pragma HLS INLINE off
387  #pragma HLS PIPELINE II=1 enable_flush
388 
389  const char *myName = concat3(THIS_NAME, "/", "MAi");
390 
391  //-- STATIC CONTROL VARIABLES (with RESET) ---------------------------------
392  static enum FsmStates {FSM_MAI_WAIT_LOOKUP=0, FSM_MAI_DROP, FSM_MAI_WRITE,
393  FSM_MAI_WRITE_FIRST, FSM_MAI_WRITE_LAST} \
394  mai_fsmState=FSM_MAI_WAIT_LOOKUP;
395  #pragma HLS RESET variable=mai_fsmState
396 
397  //-- STATIC DATAFLOW VARIABLES ---------------------------------------------
398  static AxisIp4 mai_prevChunk;
399 
400  //-- DYNAMIC VARIABLES -----------------------------------------------------
401  AxisEth sendChunk;
402  AxisIp4 currChunk;
403  ArpLkpReply arpResponse;
404  EthAddr macDstAddr;
405 
406  currChunk.setLE_TLast(0);
407  switch (mai_fsmState) {
408  case FSM_MAI_WAIT_LOOKUP:
409  if (!siARP_LookupRsp.empty() and !soL2MUX_Data.full()) {
410  siARP_LookupRsp.read(arpResponse);
411  macDstAddr = arpResponse.macAddress;
412  if (arpResponse.hit) {
413  sendChunk.setEthDstAddr(macDstAddr);
414  sendChunk.setEthSrcAddrHi(piMMIO_MacAddress);
415  sendChunk.setLE_TKeep(0xff);
416  sendChunk.setLE_TLast(0);
417  soL2MUX_Data.write(sendChunk);
418  mai_fsmState = FSM_MAI_WRITE_FIRST;
419  if (DEBUG_LEVEL & TRACE_MAI) {
420  printInfo(myName, "FSM_MAI_WAIT_LOOKUP - Lookup=HIT - Received MAC = 0x%12.12lX\n",
421  arpResponse.macAddress.to_ulong());
422  printAxisRaw(myName, "Forwarding AxisChunk to [L2MUX]: ", sendChunk);
423  }
424  }
425  else { // Drop it all, wait for RT
426  mai_fsmState = FSM_MAI_DROP;
427  if (DEBUG_LEVEL & TRACE_MAI) {
428  printInfo(myName, "FSM_MAI_WAIT_LOOKUP - Lookup=NO-HIT. \n");
429  }
430  }
431  }
432  break;
433  case FSM_MAI_WRITE_FIRST:
434  if (DEBUG_LEVEL & TRACE_MAI) { printInfo(myName, "FSM_MAI_WRITE_FIRST - \n"); }
435  if (!siIAe_Data.empty() and !soL2MUX_Data.full()) {
436  siIAe_Data.read(currChunk);
437  sendChunk.setEthSrcAddrLo(piMMIO_MacAddress);
438  sendChunk.setEthTypeLen(0x0800);
439  sendChunk.setIp4HdrLen(currChunk.getIp4HdrLen());
440  sendChunk.setIp4Version(currChunk.getIp4Version());
441  sendChunk.setIp4ToS(currChunk.getIp4ToS());
442  sendChunk.setLE_TKeep(0xff);
443  sendChunk.setLE_TLast(0);
444  soL2MUX_Data.write(sendChunk);
445  mai_prevChunk = currChunk;
446  mai_fsmState = FSM_MAI_WRITE;
447  }
448  break;
449  case FSM_MAI_WRITE:
450  if (DEBUG_LEVEL & TRACE_MAI) { printInfo(myName, "FSM_MAI_WRITE - \n"); }
451  if (!siIAe_Data.empty() and !soL2MUX_Data.full()) {
452  siIAe_Data.read(currChunk);
453  sendChunk.setLE_TData(mai_prevChunk.getLE_TData(63, 16), 47, 0);
454  sendChunk.setLE_TData( currChunk.getLE_TData(15, 0), 63, 48);
455  sendChunk.setLE_TKeep(mai_prevChunk.getLE_TKeep( 7, 2), 5, 0);
456  sendChunk.setLE_TKeep( currChunk.getLE_TKeep( 1, 0), 7, 6);
457  if (currChunk.getLE_TKeep()[2] == 0) {
458  sendChunk.setLE_TLast(TLAST);
459  }
460  else {
461  sendChunk.setLE_TLast(0);
462  }
463  soL2MUX_Data.write(sendChunk);
464  if (DEBUG_LEVEL & TRACE_MAI) {
465  printAxisRaw(myName, "Forwarding AxisChunk to [L2MUX]: ", sendChunk);
466  }
467  mai_prevChunk = currChunk;
468  if (currChunk.getLE_TLast()) {
469  if (currChunk.getLE_TKeep()[2] == 0) {
470  mai_fsmState = FSM_MAI_WAIT_LOOKUP;
471  }
472  else {
473  mai_fsmState = FSM_MAI_WRITE_LAST;
474  }
475  }
476  else {
477  mai_fsmState = FSM_MAI_WRITE;
478  }
479  }
480  break;
481  case FSM_MAI_WRITE_LAST:
482  if (DEBUG_LEVEL & TRACE_MAI) { printInfo(myName, "FSM_MAI_WRITE_LAST - \n"); }
483  if (!soL2MUX_Data.full()) {
484  sendChunk.setLE_TData(mai_prevChunk.getLE_TData(63, 16), 47, 0);
485  sendChunk.setLE_TData( 0, 63, 48);
486  sendChunk.setLE_TKeep(mai_prevChunk.getLE_TKeep( 7, 2), 5, 0);
487  sendChunk.setLE_TKeep( 0, 7, 6);
488  sendChunk.setLE_TLast(TLAST);
489  soL2MUX_Data.write(sendChunk);
490  if (DEBUG_LEVEL & TRACE_MAI) {
491  printAxisRaw(myName, "Forwarding AxisChunk to [L2MUX]: ", sendChunk);
492  }
493  mai_fsmState = FSM_MAI_WAIT_LOOKUP;
494  }
495  break;
496  case FSM_MAI_DROP:
497  if (DEBUG_LEVEL & TRACE_MAI) { printInfo(myName, "FSM_MAI_DROP - \n"); }
498  if (!siIAe_Data.empty() and !soL2MUX_Data.full()) {
499  siIAe_Data.read(currChunk);
500  if (currChunk.getLE_TLast()) {
501  mai_fsmState = FSM_MAI_WAIT_LOOKUP;
502  }
503  }
504  break;
505 
506  } // End-of: switch()
507 
508 } // End-of: pMacAddressInserter
509 
510 
530 void iptx(
531  //------------------------------------------------------
532  //-- MMIO Interfaces
533  //------------------------------------------------------
534  EthAddr piMMIO_MacAddress,
535  Ip4Addr piMMIO_SubNetMask,
536  Ip4Addr piMMIO_GatewayAddr,
537  //------------------------------------------------------
538  //-- L3MUX Interface
539  //------------------------------------------------------
540  stream<AxisIp4> &siL3MUX_Data,
541  //------------------------------------------------------
542  //-- L2MUX Interface
543  //------------------------------------------------------
544  stream<AxisEth> &soL2MUX_Data,
545  //------------------------------------------------------
546  //-- ARP Interface
547  //------------------------------------------------------
548  stream<Ip4Addr> &soARP_LookupReq,
549  stream<ArpLkpReply> &siARP_LookupRep)
550 {
551  //-- DIRECTIVES FOR THE INTERFACES -----------------------------------------
552  #pragma HLS DATAFLOW
553  #pragma HLS INLINE
554  #pragma HLS INTERFACE ap_ctrl_none port=return
555 
556  //--------------------------------------------------------------------------
557  //-- LOCAL STREAMS (Sorted by the name of the modules which generate them)
558  //--------------------------------------------------------------------------
559 
560  //-- Header Checksum Accumulator (HCa)
561  static stream<AxisIp4> ssHCaToICi_Data ("ssHCaToICi_Data");
562  #pragma HLS STREAM variable=ssHCaToICi_Data depth=1024 // Must hold one IP header for checksum computation
563  #pragma HLS DATA_PACK variable=ssHCaToICi_Data // [FIXME -We only need to store 20 to 24+ bytes]
564 
565  static stream<Ip4HdrCsum> ssHCaToICi_Csum ("ssHCaToICi_Csum");
566  #pragma HLS STREAM variable=ssHCaToICi_Csum depth=16
567 
568  //-- IP Checksum Inserter (ICi)
569  static stream<AxisIp4> ssICiToIAe_Data ("ssICiToIAe_Data");
570  #pragma HLS STREAM variable=ssICiToIAe_Data depth=16
571  #pragma HLS DATA_PACK variable=ssICiToIAe_Data
572 
573  //-- IP Address Extractor (IAe)
574  static stream<AxisIp4> ssIAeToMAi_Data ("ssIAeToMAi_Data");
575  #pragma HLS STREAM variable=ssIAeToMAi_Data depth=16
576  #pragma HLS DATA_PACK variable=ssIAeToMAi_Data
577 
578  //-- PROCESS FUNCTIONS -----------------------------------------------------
579 
581  siL3MUX_Data,
582  ssHCaToICi_Data,
583  ssHCaToICi_Csum);
584 
586  ssHCaToICi_Data,
587  ssHCaToICi_Csum,
588  ssICiToIAe_Data);
589 
591  piMMIO_SubNetMask,
592  piMMIO_GatewayAddr,
593  ssICiToIAe_Data,
594  ssIAeToMAi_Data,
595  soARP_LookupReq);
596 
598  piMMIO_MacAddress,
599  ssIAeToMAi_Data,
600  siARP_LookupRep,
601  soL2MUX_Data);
602 }
603 
604 
616 #if HLS_VERSION == 2017
617  void iptx_top(
618  //------------------------------------------------------
619  //-- MMIO Interfaces
620  //------------------------------------------------------
621  EthAddr piMMIO_MacAddress,
622  Ip4Addr piMMIO_SubNetMask,
623  Ip4Addr piMMIO_GatewayAddr,
624  //------------------------------------------------------
625  //-- L3MUX Interface
626  //------------------------------------------------------
627  stream<AxisIp4> &siL3MUX_Data,
628  //------------------------------------------------------
629  //-- L2MUX Interface
630  //------------------------------------------------------
631  stream<AxisEth> &soL2MUX_Data,
632  //------------------------------------------------------
633  //-- ARP Interface
634  //------------------------------------------------------
635  stream<Ip4Addr> &soARP_LookupReq,
636  stream<ArpLkpReply> &siARP_LookupRep)
637 {
638  //-- DIRECTIVES FOR THE INTERFACES -----------------------------------------
639  #pragma HLS INTERFACE ap_ctrl_none port=return
640 
641 
642 
643 
644 
646  #pragma HLS INTERFACE ap_stable port=piMMIO_MacAddress
647  #pragma HLS INTERFACE ap_stable port=piMMIO_SubNetMask
648  #pragma HLS INTERFACE ap_stable port=piMMIO_GatewayAddr
649 
650  #pragma HLS resource core=AXI4Stream variable=siL3MUX_Data metadata="-bus_bundle siL3MUX_Data"
651  #pragma HLS resource core=AXI4Stream variable=soL2MUX_Data metadata="-bus_bundle soL2MUX_Data"
652 
653  #pragma HLS resource core=AXI4Stream variable=soARP_LookupReq metadata="-bus_bundle soARP_LookupReq"
654  #pragma HLS resource core=AXI4Stream variable=siARP_LookupRep metadata="-bus_bundle siARP_LookupRep"
655  #pragma HLS DATA_PACK variable=siARP_LookupRep
656 
657  //-- DIRECTIVES FOR THIS PROCESS -------------------------------------------
658  #pragma HLS DATAFLOW
659 
660  //-- MAIN IPTX PROCESS -----------------------------------------------------
661  iptx(
662  //-- MMIO Interfaces
663  piMMIO_MacAddress,
664  piMMIO_SubNetMask,
665  piMMIO_GatewayAddr,
666  //-- L3MUX Interface
667  siL3MUX_Data,
668  //-- L2MUX Interface
669  soL2MUX_Data,
670  //-- ARP Interface
671  soARP_LookupReq,
672  siARP_LookupRep);
673 
674 }
675 #else
676  void iptx_top(
677  //------------------------------------------------------
678  //-- MMIO Interfaces
679  //------------------------------------------------------
680  EthAddr piMMIO_MacAddress,
681  Ip4Addr piMMIO_SubNetMask,
682  Ip4Addr piMMIO_GatewayAddr,
683  //------------------------------------------------------
684  //-- L3MUX Interface
685  //------------------------------------------------------
686  stream<AxisRaw> &siL3MUX_Data,
687  //------------------------------------------------------
688  //-- L2MUX Interface
689  //------------------------------------------------------
690  stream<AxisRaw> &soL2MUX_Data,
691  //------------------------------------------------------
692  //-- ARP Interface
693  //------------------------------------------------------
694  stream<Ip4Addr> &soARP_LookupReq,
695  stream<ArpLkpReply> &siARP_LookupRep)
696 {
697  //-- DIRECTIVES FOR THE INTERFACES -----------------------------------------
698  #pragma HLS INTERFACE ap_ctrl_none port=return
699 
700  #pragma HLS INTERFACE ap_stable port=piMMIO_MacAddress
701  #pragma HLS INTERFACE ap_stable port=piMMIO_SubNetMask
702  #pragma HLS INTERFACE ap_stable port=piMMIO_GatewayAddr
703 
704  #pragma HLS INTERFACE axis off port=siL3MUX_Data
705  #pragma HLS INTERFACE axis register both port=soL2MUX_Data
706 
707  #pragma HLS INTERFACE axis off port=soARP_LookupReq
708  #pragma HLS INTERFACE axis off port=siARP_LookupRep
709  #pragma HLS DATA_PACK variable=siARP_LookupRep
710 
711  //-- DIRECTIVES FOR THIS PROCESS -------------------------------------------
712  #pragma HLS DATAFLOW disable_start_propagation
713 
714  //-- LOCAL INPUT and OUTPUT STREAMS ----------------------------------------
715  static stream<AxisIp4> ssiL3MUX_Data ("ssiL3MUX_Data");
716  #pragma HLS STREAM variable=ssiL3MUX_Data depth=8
717  static stream<AxisEth> ssoL2MUX_Data ("ssoL2MUX_Data");
718 
719  //-- INPUT STREAM CASTING --------------------------------------------------
720  pAxisRawCast(siL3MUX_Data, ssiL3MUX_Data);
721 
722  //-- MAIN IPTX PROCESS -----------------------------------------------------
723  iptx(
724  //-- MMIO Interfaces
725  piMMIO_MacAddress,
726  piMMIO_SubNetMask,
727  piMMIO_GatewayAddr,
728  //-- L3MUX Interface
729  ssiL3MUX_Data,
730  //-- L2MUX Interface
731  ssoL2MUX_Data,
732  //-- ARP Interface
733  soARP_LookupReq,
734  siARP_LookupRep);
735 
736  //-- OUTPUT STREAM CASTING -------------------------------------------------
737  pAxisRawCast(ssoL2MUX_Data, soL2MUX_Data);
738 
739 }
740 #endif // HLS_VERSION
741 
EthAddr macAddress
Definition: nts_types.hpp:351
HitBool hit
Definition: nts_types.hpp:352
void setEthDstAddr(EthAddr addr)
Definition: AxisEth.hpp:159
void setIp4Version(Ip4Version ver)
Definition: AxisEth.hpp:233
void setEthSrcAddrHi(EthAddr addr)
Definition: AxisEth.hpp:163
void setEthSrcAddrLo(EthAddr addr)
Definition: AxisEth.hpp:166
void setEthTypeLen(EthTypeLen eTyLe)
Definition: AxisEth.hpp:169
void setIp4ToS(Ip4ToS tos)
Definition: AxisEth.hpp:239
void setIp4HdrLen(Ip4HdrLen ihl)
Definition: AxisEth.hpp:236
Ip4Addr getIp4DstAddr()
Definition: AxisIp4.hpp:230
void setIp4HdrCsum(Ip4HdrCsum csum)
Definition: AxisIp4.hpp:223
Ip4Version getIp4Version()
Definition: AxisIp4.hpp:196
Ip4HdrLen getIp4HdrLen()
Definition: AxisIp4.hpp:199
Ip4ToS getIp4ToS()
Definition: AxisIp4.hpp:202
LE_tKeep getLE_TKeep(int leHi=64/8-1, int leLo=0) const
Definition: AxisRaw.hpp:264
LE_tData getLE_TData(int leHi=64 -1, int leLo=0) const
Definition: AxisRaw.hpp:260
void setLE_TLast(LE_tLast last)
Definition: AxisRaw.hpp:280
void setLE_TData(LE_tData data, int leHi=64 -1, int leLo=0)
Definition: AxisRaw.hpp:272
void setLE_TKeep(LE_tKeep keep, int leHi=64/8-1, int leLo=0)
Definition: AxisRaw.hpp:276
LE_tLast getLE_TLast() const
Definition: AxisRaw.hpp:268
#define TRACE_MAI
Definition: iptx.cpp:74
void pHeaderChecksumAccumulator(stream< AxisIp4 > &siL3MUX_Data, stream< AxisIp4 > &soICi_Data, stream< Ip4HdrCsum > &soICi_Csum)
Definition: iptx.cpp:107
void pIpChecksumInsert(stream< AxisIp4 > &siHCa_Data, stream< Ip4HdrCsum > &siHCa_Csum, stream< AxisIp4 > &soIAe_Data)
Definition: iptx.cpp:255
void iptx(EthAddr piMMIO_MacAddress, Ip4Addr piMMIO_SubNetMask, Ip4Addr piMMIO_GatewayAddr, stream< AxisIp4 > &siL3MUX_Data, stream< AxisEth > &soL2MUX_Data, stream< Ip4Addr > &soARP_LookupReq, stream< ArpLkpReply > &siARP_LookupRep)
Main process of the IP Transmitter Handler (IPTX).
Definition: iptx.cpp:530
void pIp4AddressExtractor(Ip4Addr piMMIO_SubNetMask, Ip4Addr piMMIO_GatewayAddr, stream< AxisIp4 > &siICi_Data, stream< AxisIp4 > &soMAi_Data, stream< Ip4Addr > &soARP_LookupReq)
Definition: iptx.cpp:320
bool gTraceEvent
Definition: tb_nal.cpp:151
#define THIS_NAME
Definition: iptx.cpp:68
void iptx_top(EthAddr piMMIO_MacAddress, Ip4Addr piMMIO_SubNetMask, Ip4Addr piMMIO_GatewayAddr, stream< AxisRaw > &siL3MUX_Data, stream< AxisRaw > &soL2MUX_Data, stream< Ip4Addr > &soARP_LookupReq, stream< ArpLkpReply > &siARP_LookupRep)
Top of IP Transmitter Handler (IPTX)
Definition: iptx.cpp:676
#define DEBUG_LEVEL
Definition: iptx.cpp:77
void pMacAddressInserter(EthAddr piMMIO_MacAddress, stream< AxisIp4 > &siIAe_Data, stream< ArpLkpReply > &siARP_LookupRsp, stream< AxisEth > &soL2MUX_Data)
Definition: iptx.cpp:379
ap_uint< 48 > EthAddr
Definition: AxisEth.hpp:120
void printAxisRaw(const char *callerName, AxisRaw chunk)
Prints an Axis raw data chunk (used for debugging).
Definition: nts_utils.cpp:46
ap_uint< 32 > Ip4Addr
Definition: AxisIp4.hpp:169
ap_uint< 16 > Ip4HdrCsum
Definition: AxisIp4.hpp:165
void pAxisRawCast(hls::stream< TypeIn > &si, hls::stream< TypeOut > &so)
AxisRaw cast - Casts an AxisRaw stream to/from an AxisRaw derived class.
Definition: AxisRaw.hpp:148
#define printInfo(callerName, format,...)
A macro to print an information message.
Definition: nts_utils.hpp:169
#define concat3(firstCharConst, secondCharConst, thirdCharConst)
Definition: nts_utils.hpp:161
#define TLAST
Definition: AxisRaw.hpp:116
: IP Transmitter packet handler (IPTX)