cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
network_utils.hpp File Reference
#include <stdint.h>
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <string>
#include <math.h>
#include <vector>
#include "ap_int.h"
#include "ap_utils.h"
#include <hls_stream.h>
#include "../../../hls/network.hpp"
#include "NTS/nts.hpp"
#include "NTS/nts_types.hpp"
#include "NTS/nts_config.hpp"
#include "NTS/nts_utils.hpp"
#include "NTS/AxisRaw.hpp"
Include dependency graph for network_utils.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef TcpSessId AppMeta
 

Functions

ap_uint< 32 > bigEndianToInteger (ap_uint< 8 > *buffer, int lsb)
 
void integerToBigEndian (ap_uint< 32 > n, ap_uint< 8 > *bytes)
 
ap_uint< 8 > lenToKeep (ap_uint< 4 > noValidBytes)
 Returns the 'tkeep' field of an AxiWord as a function of the number of valid bytes in that word. More...
 
ap_uint< 4 > keepToLen (ap_uint< 8 > keepValue)
 Swap the two bytes of a word (.i.e, 16 bits). More...
 

Typedef Documentation

◆ AppMeta

typedef TcpSessId AppMeta

Application Metadata Meta-data transfered between TOE and APP.

Definition at line 76 of file network_utils.hpp.

Function Documentation

◆ bigEndianToInteger()

ap_uint<32> bigEndianToInteger ( ap_uint< 8 > *  buffer,
int  lsb 
)

Definition at line 41 of file network_utils.cpp.

42 {
43  UINT32 tmp = 0;
44  tmp = ((UINT32) buffer[lsb + 0]);
45  tmp |= ((UINT32) buffer[lsb + 1]) << 8;
46  tmp |= ((UINT32) buffer[lsb + 2]) << 16;
47  tmp |= ((UINT32) buffer[lsb + 3]) << 24;
48 
49  //printf("LSB: %#1x, return: %#04x\n",(UINT8) buffer[lsb + 3], (UINT32) tmp);
50 
51  return tmp;
52 }
#define UINT32

◆ integerToBigEndian()

void integerToBigEndian ( ap_uint< 32 >  n,
ap_uint< 8 > *  bytes 
)

Definition at line 54 of file network_utils.cpp.

55 {
56  bytes[3] = (n >> 24) & 0xFF;
57  bytes[2] = (n >> 16) & 0xFF;
58  bytes[1] = (n >> 8) & 0xFF;
59  bytes[0] = n & 0xFF;
60 }

◆ keepToLen()

ap_uint<4> keepToLen ( ap_uint< 8 >  keepValue)

Swap the two bytes of a word (.i.e, 16 bits).

Parameters
[in]inpWord,the16-bit unsigned data to swap.
Returns
a 16-bit unsigned data.

Swap the four bytes of a double-word (.i.e, 32 bits).

Parameters
[in]inpDWord,a32-bit unsigned data.
Returns
a 32-bit unsigned data.

Returns the number of valid bytes in an AxiWord.

Parameters
[in]The'tkeep' field of the AxiWord.

Definition at line 94 of file network_utils.cpp.

94  {
95  ap_uint<4> count = 0;
96  switch(keepValue){
97  case 0x01: count = 1; break;
98  case 0x03: count = 2; break;
99  case 0x07: count = 3; break;
100  case 0x0F: count = 4; break;
101  case 0x1F: count = 5; break;
102  case 0x3F: count = 6; break;
103  case 0x7F: count = 7; break;
104  case 0xFF: count = 8; break;
105  }
106  return count;
107 }

◆ lenToKeep()

ap_uint<8> lenToKeep ( ap_uint< 4 >  noValidBytes)

Returns the 'tkeep' field of an AxiWord as a function of the number of valid bytes in that word.

Parameters
[in]Thenumber of valid bytes in an AxiWord.

Definition at line 114 of file network_utils.cpp.

114  {
115  ap_uint<8> keep = 0;
116 
117  switch(noValidBytes) {
118  case 1: keep = 0x01; break;
119  case 2: keep = 0x03; break;
120  case 3: keep = 0x07; break;
121  case 4: keep = 0x0F; break;
122  case 5: keep = 0x1F; break;
123  case 6: keep = 0x3F; break;
124  case 7: keep = 0x7F; break;
125  case 8: keep = 0xFF; break;
126  }
127  return keep;
128 }