Hi, all:
I am testing with XC-3 Board. I never succeeded in transmitting an Ethernet packet in ".xc" file, using syntax:
outPort <: packet
But I can transmit the packet in assembly file "*.s", using syntax:
out res[r0], r1
So, is it possible to do the packet transmission in ".xc" file?
Or we always need to use assembly file "*.s"?
Thanks
Jerry
Never succeed in transmitting ethernet packet (in *.xc)!
-
- Experienced Member
- Posts: 65
- Joined: Tue Apr 30, 2013 10:41 pm
-
- Active Member
- Posts: 63
- Joined: Mon Jul 15, 2013 11:39 pm
Perhaps more context in terms of surrounding code w/full text would help illuminate the issue.
Regards,
Jason Whiteman
Regards,
Jason Whiteman
-
- Experienced Member
- Posts: 65
- Joined: Tue Apr 30, 2013 10:41 pm
Thanks, below is the function I used in my project:
*I just copy codes from "sc_ethernet" at github.com/xcore
*Basic operation of my project:
-My PC send an packet to XC-3 board
-XC-3 should reply with a random preset packet
-(I am testing EtherCat packet, but the exact packet is actually not relevant)
*packet[80] and txbuf[20] are same content
- packet[]: 8-bit char array (future testing, good for EtherCat)
- txbuf[]: 32-bit int array (currently testing!!!)
*The project compiled and run OK, but:
- XC-3 received the packet
- but not packet received at PC.
You can focus on 20 line of codes between while(1) and switch (tail_byte_count):
-- Above while(1): create a packet
---After switch (tail_byte_count): CRC calculation
----------------- codes below -----------------------------------------------------------------
*I just copy codes from "sc_ethernet" at github.com/xcore
*Basic operation of my project:
-My PC send an packet to XC-3 board
-XC-3 should reply with a random preset packet
-(I am testing EtherCat packet, but the exact packet is actually not relevant)
*packet[80] and txbuf[20] are same content
- packet[]: 8-bit char array (future testing, good for EtherCat)
- txbuf[]: 32-bit int array (currently testing!!!)
*The project compiled and run OK, but:
- XC-3 received the packet
- but not packet received at PC.
You can focus on 20 line of codes between while(1) and switch (tail_byte_count):
-- Above while(1): create a packet
---After switch (tail_byte_count): CRC calculation
----------------- codes below -----------------------------------------------------------------
Code: Select all
void packetTxD( chanend c_out, out buffered port:32 p_mii_txd)
{
register const unsigned poly = 0xEDB88320;
unsigned int crc = 0, idx, word_count = 20;
unsigned int word;
unsigned int txbuf[20];
int tail_byte_count = word_count & 3;
char packet[80] = { 0x00, 0x22, 0x97, 0x00, 0x10, 0x2b, 0x68, 0x05, 0xca, 0x15, 0xbd, 0xa7, 0x88, 0xA4, 0x38, 0x10,
//---------------------- ----------------------- ----------------------
0xb9, 0xb2, 0xb6, 0xc4, 0xbb, 0xe1, 0x68, 0xa5, 0xca, 0x15, 0xbd, 0xa7, 0xa9, 0xfe, 0x5f, 0xf8,
//--------------------- ---------------------- -----------------------
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa9, 0xfe, 0x46, 0x7a, 0xaa, 0xaa };
//----------------------
for(int i=43;i<73;i++) packet[i]= (i+2);
for(int i=73;i<80;i++) packet[i]= i;
for (int i = 0; i < 80; i++) (txbuf, unsigned char[])[i] = packet[i];
while(1)
{
chkct(c_out, 1);crc=0;
printstrln(" start.txd..");
idx=0;
p_mii_txd <: 0x55555555;
p_mii_txd <: 0xD5555555;
word = txbuf[idx];
#pragma xta endpoint "mii_tx_first_word"
p_mii_txd <: word;
idx++;
crc32(crc, ~word, poly);
do {
#pragma xta label "mii_tx_loop"
word = txbuf[idx];
idx++;
crc32(crc, word, poly);
#pragma xta endpoint "mii_tx_word"
p_mii_txd <: word;
} while (idx < word_count);
switch (tail_byte_count)
{
case 0:
crc32(crc, 0, poly);
crc = ~crc;
#pragma xta endpoint "mii_tx_crc_0"
p_mii_txd <: crc; printhexln(crc);
break;
case 1:
word = txbuf[idx];
crc8shr(crc, word, poly);
#pragma xta endpoint "mii_tx_final_partword_1"
partout(p_mii_txd, 8, word);
crc32(crc, 0, poly);
crc = ~crc;
#pragma xta endpoint "mii_tx_crc_1"
p_mii_txd <: crc;
break;
case 2:
word = txbuf[idx];
#pragma xta endpoint "mii_tx_final_partword_2"
partout(p_mii_txd, 16, word);
word = crc8shr(crc, word, poly);
crc8shr(crc, word, poly);
crc32(crc, 0, poly);
crc = ~crc;
#pragma xta endpoint "mii_tx_crc_2"
p_mii_txd <: crc;
break;
case 3:
word = txbuf[idx];
#pragma xta endpoint "mii_tx_final_partword_3"
partout(p_mii_txd, 24, word);
word = crc8shr(crc, word, poly);
word = crc8shr(crc, word, poly);
crc8shr(crc, word, poly);
crc32(crc, 0, poly);
crc = ~crc;
#pragma xta endpoint "mii_tx_crc_3"
p_mii_txd <: crc;
break;
}
}
}