cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
axi_utils.hpp
Go to the documentation of this file.
1 
17 // *
18 // * cloudFPGA
19 // * =============================================
20 // * Created: Apr 2019
21 // * Authors: FAB, WEI, NGL
22 // *
23 // * Description:
24 // * This file contains AXI types and functions that are shared between SHELL and ROLE.
25 // *
26 
27 #ifndef _CF_AXI_USER_UTILS_
28 #define _CF_AXI_USER_UTILS_
29 
30 
31 #include <stdint.h>
32 #include <stdio.h>
33 
34 #include "ap_int.h"
35 #include "ap_utils.h"
36 #include <hls_stream.h>
37 
38 
39 using namespace hls;
40 
41 /*
42  * A generic unsigned AXI4-Stream interface used all over the cloudFPGA place.
43  * It has NO defined byte order. The user can use this for BE and LE (and must ensure the encoding)!.
44  */
45 template<int D>
46 struct Axis {
47  protected:
48  ap_uint<D> tdata;
49  ap_uint<(D+7)/8> tkeep;
50  ap_uint<1> tlast;
51  public:
52  Axis() {}
53  Axis(ap_uint<D> single_data) : tdata((ap_uint<D>)single_data), tkeep(~(((ap_uint<D>) single_data) & 0)), tlast(1) {}
54  Axis(ap_uint<D> new_data, ap_uint<(D+7/8)> new_keep, ap_uint<1> new_last) : tdata(new_data), tkeep(new_keep), tlast(new_last) {}
55  ap_uint<D> getTData() {
56  return tdata;
57  }
58  ap_uint<(D+7)/8> getTKeep() {
59  return tkeep;
60  }
61  ap_uint<1> getTLast() {
62  return tlast;
63  }
64  void setTData(ap_uint<D> new_data) {
65  tdata = new_data;
66  }
67  void setTKeep(ap_uint<(D+7)/8> new_keep) {
68  tkeep = new_keep;
69  }
70  void setTLast(ap_uint<1> new_last) {
71  tlast = new_last;
72  }
73  //Axis<64>& operator= (const NetworkWord& nw) {
74  // this->tdata = nw.tdata;
75  // this->tkeep = nw.tkeep;
76  // this->tlast = nw.tlast;
77  // return *this;
78  //}
79  Axis<D>& operator= (const Axis<D>& ot) {
80  this->tdata = ot.tdata;
81  this->tkeep = ot.tkeep;
82  this->tlast = ot.tlast;
83  return *this;
84  }
85  //operator NetworkWord() {
86  // return NetworkWord(this->tdata, this->tkeep, this->tlast);
87  //}
88  //Axis(NetworkWord nw) : tdata((ap_uint<D>) nw.tdata), tkeep((ap_uint<(D+7/8)>) nw.tkeep), tlast(nw.tlast) {}
89 };
90 
91 
92 
93 #endif
Axis(ap_uint< D > single_data)
Definition: axi_utils.hpp:53
ap_uint< D > getTData()
Definition: axi_utils.hpp:55
ap_uint<(D+7)/8 > tkeep
Definition: axi_utils.hpp:49
void setTLast(ap_uint< 1 > new_last)
Definition: axi_utils.hpp:70
Axis(ap_uint< D > new_data, ap_uint<(D+7/8)> new_keep, ap_uint< 1 > new_last)
Definition: axi_utils.hpp:54
ap_uint< 1 > getTLast()
Definition: axi_utils.hpp:61
ap_uint<(D+7)/8 > getTKeep()
Definition: axi_utils.hpp:58
void setTKeep(ap_uint<(D+7)/8 > new_keep)
Definition: axi_utils.hpp:67
ap_uint< 1 > tlast
Definition: axi_utils.hpp:50
Axis()
Definition: axi_utils.hpp:52
ap_uint< D > tdata
Definition: axi_utils.hpp:48
void setTData(ap_uint< D > new_data)
Definition: axi_utils.hpp:64