cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)
AxisArp.hpp
Go to the documentation of this file.
1 
18 
67 #ifndef _AXIS_ARP_H_
68 #define _AXIS_ARP_H_
69 
70 #include "AxisRaw.hpp"
71 #include "AxisEth.hpp"
72 
73 
76 typedef ap_uint<16> LE_ArpHwType; // ARP Hardware Type (HTYPE)
77 typedef ap_uint<16> LE_ArpProtType; // ARP Protocol Type (PTYPE)
78 typedef ap_uint< 8> LE_ArpHwLen; // ARP Hardware address Length (HLEN)
79 typedef ap_uint< 8> LE_ArpProtLen; // ARP Protocol address Length (PLEN)
80 typedef ap_uint<16> LE_ArpOper; // ARP Operation (1=request; 2=reply)
81 typedef ap_uint<48> LE_ArpSendHwAddr; // ARP Sender Hardware Address (SHA)
82 typedef ap_uint<32> LE_ArpSendProtAddr; // ARP Sender Protocol Address (SPA)
83 typedef ap_uint<48> LE_ArpTargHwAddr; // ARP Target Hardware Address (THA)
84 typedef ap_uint<32> LE_ArpTargProtAddr; // ARP Target Protocol Address (TPA)
85 
86 typedef ap_uint<16> LE_ArpShaHi; // ARP SHA 16-MSbits (.i.e 47:32)
87 typedef ap_uint<32> LE_ArpShaLo; // ARP SHA 32-LSbits (.i.e 31: 0)
88 typedef ap_uint<16> LE_ArpTpaHi; // ARP TPA 16-MSbits (.i.e 47:32)
89 typedef ap_uint<16> LE_ArpTpaLo; // ARP TPA 16-LSbits (.i.e 31: 0)
90 
91 
95 typedef ap_uint<16> ArpHwType; // ARP Hardware Type (HTYPE)
96 typedef ap_uint<16> ArpProtType; // ARP Protocol Type (PTYPE)
97 typedef ap_uint< 8> ArpHwLen; // ARP Hardware address Length (HLEN)
98 typedef ap_uint< 8> ArpProtLen; // ARP Protocol address Length (PLEN)
99 typedef ap_uint<16> ArpOper; // ARP Operation (1=request; 2=reply)
100 typedef ap_uint<48> ArpSendHwAddr; // ARP Sender Hardware Address (SHA)
101 typedef ap_uint<32> ArpSendProtAddr; // ARP Sender Protocol Address (SPA)
102 typedef ap_uint<48> ArpTargHwAddr; // ARP Target Hardware Address (THA)
103 typedef ap_uint<32> ArpTargProtAddr; // ARP Target Protocol Address (TPA)
104 
105 typedef ap_uint<16> ArpShaHi; // ARP SHA 16-MSbits (.i.e 47:32)
106 typedef ap_uint<32> ArpShaLo; // ARP SHA 32-LSbits (.i.e 31: 0)
107 typedef ap_uint<16> ArpTpaHi; // ARP TPA 16-MSbits (.i.e 47:32)
108 typedef ap_uint<16> ArpTpaLo; // ARP TPA 16-LSbits (.i.e 31: 0)
109 
110 
111 
115 class AxisArp: public AxisRaw {
116 
117  public:
118  AxisArp() {}
119  AxisArp(AxisRaw axisRaw) :
120  AxisRaw(axisRaw.getLE_TData(), axisRaw.getLE_TKeep(), axisRaw.getLE_TLast()) {}
122  AxisRaw(tdata, tkeep, tlast) {}
123  AxisArp(const AxisArp &axisArp) :
124  AxisRaw(axisArp.tdata, axisArp.tkeep, axisArp.tlast) {}
125 
126 
130  // Set-Get the Hardware Type (HTYPE) field
131  void setArpHardwareType(ArpHwType htype) { tdata.range(15, 0) = swapWord(htype); }
132  ArpHwType getArpHardwareType() { return swapWord (tdata.range(15, 0)); }
133  // Set-Get the Protocol type (PTYPE) field
134  void setArpProtocolType(ArpProtType ptype) { tdata.range(31, 16) = swapWord(ptype); }
135  ArpProtType getArpProtocolType() { return swapWord (tdata.range(31, 16)); }
136  // Set the Hardware Address Length (HLEN) field
137  void setArpHardwareLength(ArpHwLen hlen) { tdata.range(39, 32) = hlen; }
138  ArpHwLen getArpHardwareLength() { return tdata.range(39, 32); }
139  // Set-Get Protocol Address length (PLEN) field
140  void setArpProtocolLength(ArpProtLen plen) { tdata.range(47, 40) = plen; }
141  ArpProtLen getArpProtocolLength() { return tdata.range(47, 40); }
142  // Set-Get the Operation code (OPER) field
143  void setArpOperation(ArpOper oper) { tdata.range(63, 48) = swapWord(oper); }
144  ArpOper getArpOperation() { return swapWord (tdata.range(63, 48)); }
145  // Set-Get the Sender Hardware Address (SHA)
146  void setArpSenderHwAddr(ArpSendHwAddr sha) { tdata.range(47, 0) = swapMacAddr(sha);}
147  ArpSendHwAddr getArpSenderHwAddr() { return swapMacAddr(tdata.range(47, 0)); }
148  // Set-Get the 16-MSbits of the Sender Protocol Address (SPA)
149  void setArpSenderProtAddrHi(ArpSendProtAddr spa) { tdata.range(63, 48) = swapDWord(spa).range(15, 0); }
150  ap_uint<16> getArpSenderProtAddrHi() { return swapWord(tdata.range(63, 48)); }
151  // Set-Get the 16-LSbits of the Sender Protocol Address (SPA)
152  void setArpSenderProtAddrLo(ArpSendProtAddr spa) { tdata.range(15, 0) = swapDWord(spa).range(31,16); }
153  ap_uint<32> getArpSenderProtAddrLo() { return swapWord(tdata.range(15, 0)); }
154  // Set-Get the Target Hardware Address (SHA)
155  void setArpTargetHwAddr(ArpTargHwAddr tha) { tdata.range(63, 16) = swapMacAddr(tha);}
156  ArpTargHwAddr getArpTargetHwAddr() { return swapMacAddr(tdata.range(63, 16)); }
157  // Set-Get the Target Protocol Address (TPA)
158  void setArpTargetProtAddr(ArpTargProtAddr tpa) { tdata.range(31, 0) = swapDWord(tpa);}
159  ArpTargProtAddr getArpTargetProtAddr() { return swapDWord(tdata.range(31, 0)); }
160 
161  private:
162  // Swap the two bytes of a word (.i.e, 16 bits)
163  ap_uint<16> swapWord(ap_uint<16> inpWord) {
164  return (inpWord.range(7,0), inpWord.range(15, 8));
165  }
166  // Swap the four bytes of a double-word (.i.e, 32 bits)
167  ap_uint<32> swapDWord(ap_uint<32> inpDWord) {
168  return (inpDWord.range( 7, 0), inpDWord.range(15, 8),
169  inpDWord.range(23,16), inpDWord.range(31, 24));
170  }
171  // Swap the six bytes of a MAC address (.i.e, 48 bits)
172  ap_uint<48> swapMacAddr(ap_uint<48> macAddr) {
173  return (macAddr.range( 7, 0), macAddr.range(15, 8),
174  macAddr.range(23, 16), macAddr.range(31, 24),
175  macAddr.range(39, 32), macAddr.range(47, 40));
176  }
177 
178 }; // End of: AxisArp
179 
180 #endif
181 
: A class to access an ETHernet data chunk transmitted over an AXI4-Stream interface.
: A generic class used by the Network-Transport-Stack (NTS) to to transfer a chunk of data over an AX...
AxisArp(const AxisArp &axisArp)
Definition: AxisArp.hpp:123
ArpHwType getArpHardwareType()
Definition: AxisArp.hpp:132
void setArpHardwareLength(ArpHwLen hlen)
Definition: AxisArp.hpp:137
void setArpProtocolLength(ArpProtLen plen)
Definition: AxisArp.hpp:140
ArpProtType getArpProtocolType()
Definition: AxisArp.hpp:135
AxisArp(LE_tData tdata, LE_tKeep tkeep, LE_tLast tlast)
Definition: AxisArp.hpp:121
void setArpSenderProtAddrLo(ArpSendProtAddr spa)
Definition: AxisArp.hpp:152
void setArpTargetHwAddr(ArpTargHwAddr tha)
Definition: AxisArp.hpp:155
void setArpHardwareType(ArpHwType htype)
Definition: AxisArp.hpp:131
ap_uint< 16 > getArpSenderProtAddrHi()
Definition: AxisArp.hpp:150
ArpOper getArpOperation()
Definition: AxisArp.hpp:144
ArpProtLen getArpProtocolLength()
Definition: AxisArp.hpp:141
ArpTargProtAddr getArpTargetProtAddr()
Definition: AxisArp.hpp:159
void setArpTargetProtAddr(ArpTargProtAddr tpa)
Definition: AxisArp.hpp:158
void setArpProtocolType(ArpProtType ptype)
Definition: AxisArp.hpp:134
void setArpOperation(ArpOper oper)
Definition: AxisArp.hpp:143
ap_uint< 32 > getArpSenderProtAddrLo()
Definition: AxisArp.hpp:153
ArpTargHwAddr getArpTargetHwAddr()
Definition: AxisArp.hpp:156
AxisArp(AxisRaw axisRaw)
Definition: AxisArp.hpp:119
void setArpSenderHwAddr(ArpSendHwAddr sha)
Definition: AxisArp.hpp:146
void setArpSenderProtAddrHi(ArpSendProtAddr spa)
Definition: AxisArp.hpp:149
AxisArp()
Definition: AxisArp.hpp:118
ArpSendHwAddr getArpSenderHwAddr()
Definition: AxisArp.hpp:147
ArpHwLen getArpHardwareLength()
Definition: AxisArp.hpp:138
LE_tKeep getLE_TKeep(int leHi=64/8-1, int leLo=0) const
Definition: AxisRaw.hpp:264
LE_tData tdata
Definition: AxisRaw.hpp:173
LE_tData getLE_TData(int leHi=64 -1, int leLo=0) const
Definition: AxisRaw.hpp:260
LE_tKeep tkeep
Definition: AxisRaw.hpp:174
LE_tLast getLE_TLast() const
Definition: AxisRaw.hpp:268
LE_tLast tlast
Definition: AxisRaw.hpp:175
ap_uint< 16 > ArpProtType
Definition: AxisArp.hpp:96
ap_uint< 48 > ArpSendHwAddr
Definition: AxisArp.hpp:100
ap_uint< 32 > LE_ArpSendProtAddr
Definition: AxisArp.hpp:82
ap_uint< 8 > ArpProtLen
Definition: AxisArp.hpp:98
ap_uint< 32 > ArpSendProtAddr
Definition: AxisArp.hpp:101
ap_uint< 32 > ArpTargProtAddr
Definition: AxisArp.hpp:103
ap_uint< 64 > LE_tData
Definition: AxisRaw.hpp:122
ap_uint< 16 > LE_ArpProtType
Definition: AxisArp.hpp:77
ap_uint< 48 > LE_ArpSendHwAddr
Definition: AxisArp.hpp:81
ap_uint< 16 > LE_ArpTpaLo
Definition: AxisArp.hpp:89
ap_uint< 16 > ArpShaHi
Definition: AxisArp.hpp:105
ap_uint< 8 > ArpHwLen
Definition: AxisArp.hpp:97
ap_uint< 64/8 > LE_tKeep
Definition: AxisRaw.hpp:124
ap_uint< 32 > LE_ArpShaLo
Definition: AxisArp.hpp:87
ap_uint< 1 > LE_tLast
Definition: AxisRaw.hpp:125
ap_uint< 32 > ArpShaLo
Definition: AxisArp.hpp:106
ap_uint< 16 > LE_ArpTpaHi
Definition: AxisArp.hpp:88
ap_uint< 48 > LE_ArpTargHwAddr
Definition: AxisArp.hpp:83
ap_uint< 16 > ArpOper
Definition: AxisArp.hpp:99
ap_uint< 48 > ArpTargHwAddr
Definition: AxisArp.hpp:102
ap_uint< 16 > ArpHwType
Definition: AxisArp.hpp:95
ap_uint< 16 > ArpTpaLo
Definition: AxisArp.hpp:108
ap_uint< 32 > LE_ArpTargProtAddr
Definition: AxisArp.hpp:84
ap_uint< 16 > LE_ArpHwType
Definition: AxisArp.hpp:76
ap_uint< 8 > LE_ArpHwLen
Definition: AxisArp.hpp:78
ap_uint< 16 > LE_ArpOper
Definition: AxisArp.hpp:80
ap_uint< 8 > LE_ArpProtLen
Definition: AxisArp.hpp:79
ap_uint< 16 > ArpTpaHi
Definition: AxisArp.hpp:107
ap_uint< 16 > LE_ArpShaHi
Definition: AxisArp.hpp:86