30 #ifndef _SIM_ETH_FRAME_
31 #define _SIM_ETH_FRAME_
59 std::deque<AxisEth> frmQ;
63 void setLen(
int frmLen) {
77 return this->frmQ.front();
81 this->frmQ.pop_front();
84 void push_back(
AxisEth ethChunk) {
85 this->frmQ.push_back(ethChunk);
92 this->myName =
"SimEthFrame";
94 if (frmLen > 0 && frmLen <=
MTU) {
104 this->myName =
"SimEthFrame";
110 if (this->
size() > 0) {
112 this->frmQ[this->
size()-1].setLE_TLast(0);
114 this->push_back(ethChunk);
115 this->setLen(this->getLen() + ethChunk.
getLen());
120 AxisEth headingChunk = this->front();
122 setLen(getLen() - headingChunk.
getLen());
130 int size() {
return this->frmQ.size(); }
139 frmQ[1].setEthSrcAddrLo(addr); }
143 return (macHi | macLo); }
152 if (ethTypLen < 0x0600) {
169 bool alternate =
true;
170 bool endOfFrm =
false;
171 int ethFrmSize = this->
size();
172 while (chunkInpCnt < ethFrmSize) {
176 else if (alternate) {
180 if (this->frmQ[chunkInpCnt].getLE_TKeep() & 0x40) {
181 newTData.range( 7, 0) = this->frmQ[chunkInpCnt].getLE_TData().range(55, 48);
182 newTKeep = newTKeep | (0x01);
184 if (this->frmQ[chunkInpCnt].getLE_TKeep() & 0x80) {
185 newTData.range(15, 8) = this->frmQ[chunkInpCnt].getLE_TData().range(63, 56);
186 newTKeep = newTKeep | (0x02);
188 if (this->frmQ[chunkInpCnt].getLE_TLast()) {
193 alternate = !alternate;
197 if (this->frmQ[chunkInpCnt].getLE_TKeep() & 0x01) {
198 newTData.range(23, 16) = this->frmQ[chunkInpCnt].getLE_TData().range( 7, 0);
199 newTKeep = newTKeep | (0x04);
201 if (this->frmQ[chunkInpCnt].getLE_TKeep() & 0x02) {
202 newTData.range(31, 24) = this->frmQ[chunkInpCnt].getLE_TData().range(15, 8);
203 newTKeep = newTKeep | (0x08);
205 if (this->frmQ[chunkInpCnt].getLE_TKeep() & 0x04) {
206 newTData.range(39, 32) = this->frmQ[chunkInpCnt].getLE_TData().range(23, 16);
207 newTKeep = newTKeep | (0x10);
209 if (this->frmQ[chunkInpCnt].getLE_TKeep() & 0x08) {
210 newTData.range(47, 40) = this->frmQ[chunkInpCnt].getLE_TData().range(31, 24);
211 newTKeep = newTKeep | (0x20);
213 if (this->frmQ[chunkInpCnt].getLE_TKeep() & 0x10) {
214 newTData.range(55, 48) = this->frmQ[chunkInpCnt].getLE_TData().range(39, 32);
215 newTKeep = newTKeep | (0x40);
217 if (this->frmQ[chunkInpCnt].getLE_TKeep() & 0x20) {
218 newTData.range(63, 56) = this->frmQ[chunkInpCnt].getLE_TData().range(47, 40);
219 newTKeep = newTKeep | (0x80);
221 if (this->frmQ[chunkInpCnt].getLE_TLast() && (not (this->frmQ[chunkInpCnt].getLE_TKeep() & 0xC0))) {
225 alternate = !alternate;
241 bool alternate =
true;
242 bool endOfFrm =
false;
243 int ethFrmSize = this->
size();
244 while (chunkInpCnt < ethFrmSize) {
248 else if (alternate) {
252 if (this->frmQ[chunkInpCnt].getLE_TKeep() & 0x40) {
253 newTData.range( 7, 0) = this->frmQ[chunkInpCnt].getLE_TData().range(55, 48);
254 newTKeep = newTKeep | (0x01);
256 if (this->frmQ[chunkInpCnt].getLE_TKeep() & 0x80) {
257 newTData.range(15, 8) = this->frmQ[chunkInpCnt].getLE_TData().range(63, 56);
258 newTKeep = newTKeep | (0x02);
260 if (this->frmQ[chunkInpCnt].getLE_TLast()) {
265 alternate = !alternate;
269 if (this->frmQ[chunkInpCnt].getLE_TKeep() & 0x01) {
270 newTData.range(23, 16) = this->frmQ[chunkInpCnt].getLE_TData().range( 7, 0);
271 newTKeep = newTKeep | (0x04);
273 if (this->frmQ[chunkInpCnt].getLE_TKeep() & 0x02) {
274 newTData.range(31, 24) = this->frmQ[chunkInpCnt].getLE_TData().range(15, 8);
275 newTKeep = newTKeep | (0x08);
277 if (this->frmQ[chunkInpCnt].getLE_TKeep() & 0x04) {
278 newTData.range(39, 32) = this->frmQ[chunkInpCnt].getLE_TData().range(23, 16);
279 newTKeep = newTKeep | (0x10);
281 if (this->frmQ[chunkInpCnt].getLE_TKeep() & 0x08) {
282 newTData.range(47, 40) = this->frmQ[chunkInpCnt].getLE_TData().range(31, 24);
283 newTKeep = newTKeep | (0x20);
285 if (this->frmQ[chunkInpCnt].getLE_TKeep() & 0x10) {
286 newTData.range(55, 48) = this->frmQ[chunkInpCnt].getLE_TData().range(39, 32);
287 newTKeep = newTKeep | (0x40);
289 if (this->frmQ[chunkInpCnt].getLE_TKeep() & 0x20) {
290 newTData.range(63, 56) = this->frmQ[chunkInpCnt].getLE_TData().range(47, 40);
291 newTKeep = newTKeep | (0x80);
293 if (this->frmQ[chunkInpCnt].getLE_TLast() && (not (this->frmQ[chunkInpCnt].getLE_TKeep() & 0xC0))) {
297 alternate = !alternate;
315 bool alternate =
true;
316 bool endOfPkt =
false;
324 if (this->getLen() != 14) {
325 printError(this->myName,
"Frame is expected to be of length 14 bytes (was found to be %d bytes).\n", this->getLen());
335 this->frmQ[ethChunkCnt].setLE_TKeep(this->frmQ[ethChunkCnt].getLE_TKeep() | (0x40));
336 this->setLen(this->getLen() + 1);
339 this->frmQ[ethChunkCnt].setLE_TData(arpChunk.
getLE_TData().range(15, 8), 63, 56);
340 this->frmQ[ethChunkCnt].setLE_TKeep(this->frmQ[ethChunkCnt].getLE_TKeep() | (0x80));
341 this->setLen(this->getLen() + 1);
344 this->frmQ[ethChunkCnt].setLE_TLast(
TLAST);
348 this->frmQ[ethChunkCnt].setLE_TLast(0);
350 alternate = !alternate;
393 alternate = !alternate;
409 bool alternate =
true;
410 bool endOfPkt =
false;
415 if (this->getLen() != 14) {
416 printError(this->myName,
"Frame is expected to be of length 14 bytes (was found to be %d bytes).\n", this->getLen());
425 this->frmQ[ethChunkCnt].setLE_TKeep(this->frmQ[ethChunkCnt].getLE_TKeep() | (0x40));
426 this->setLen(this->getLen() + 1);
429 this->frmQ[ethChunkCnt].setLE_TData(ip4Chunk.
getLE_TData(15, 8), 63, 56);
430 this->frmQ[ethChunkCnt].setLE_TKeep(this->frmQ[ethChunkCnt].getLE_TKeep() | (0x80));
431 this->setLen(this->getLen() + 1);
434 this->frmQ[ethChunkCnt].setLE_TLast(
TLAST);
438 this->frmQ[ethChunkCnt].setLE_TLast(0);
440 alternate = !alternate;
483 alternate = !alternate;
496 for (
int i=0; i < this->
size(); i++) {
497 AxisEth axisEth = this->frmQ[i];
: A simulation class to build and handle ARP packets.
: A simulation class to build and handle IPv4 packets.
: Utilities for the simulation of the Network-Transport-Stack (NTS) components.
LE_tKeep getLE_TKeep(int leHi=64/8-1, int leLo=0) const
LE_tData getLE_TData(int leHi=64 -1, int leLo=0) const
void setLE_TLast(LE_tLast last)
void setLE_TData(LE_tData data, int leHi=64 -1, int leLo=0)
void setLE_TKeep(LE_tKeep keep, int leHi=64/8-1, int leLo=0)
LE_tLast getLE_TLast() const
Class ARP Packet for simulation.
void pushChunk(AxisArp arpChunk)
LE_EthAddr getLE_MacDestinAddress()
void pushChunk(AxisEth ethChunk)
SimIp4Packet getIpPacket()
bool writeToDatFile(ofstream &outFileStream)
Dump this Ethernet frame as raw AxisEth chunks into a file.
void setMacDestinAddress(EthAddr addr)
EthAddr getMacDestinAddress()
bool addPayload(SimArpPacket arpPkt)
Add data payload to this frame from an ARP packet.
void setTypeLength(EthTypeLen typLen)
bool addPayload(SimIp4Packet ipPkt)
Add data payload to this frame from an IP4 packet.
void setMacSourceAddress(EthAddr addr)
SimArpPacket getArpPacket()
EthAddr getMacSourceAddress()
EthTypeLen getTypeLength()
Class IPv4 Packet for simulation.
void pushChunk(AxisIp4 ip4Chunk)
bool writeAxisRawToFile(AxisRaw &axisRaw, ofstream &outFileStream)
Dump an Axis raw data chunk to a file.
#define printError(callerName, format,...)
A macro to print an error message.
LE_tKeep lenToLE_tKeep(ap_uint< 4 > noValidBytes)
A function to set a number of '1' in an 8-bit field. It is used here to set the number of valid bytes...
: Utilities and helpers for the Network-Transport-Stack (NTS) components.