Sign In

Don't have a Xilinx account yet?

  • Choose to receive important news and product information
  • Gain access to special content
  • Personalize your web experience on Xilinx.com

Create Account

Username

Password

Forgot your password?
XClose Panel
Xilinx Home
Reply
Regular Contributor
kensou
Posts: 81
Registered: ‎05-15-2009
0

UDP IP stack on a Spartan-6

Hello everybody, I'm looking for an UDP/IP stack written in VHDL language (I have to implement it in Spartan-6 FPGA). I'm looking for a one, as simple as possible, with these features:

-written in VHDL language ONLY, not Verilog
-to be implement in a Spartan-6
-no use of other processors or devices (as Microblaze, PowerPC and others)
-no use of external memory, no DDR or external ports, should be use only distributed memory or block ram, no other possibilities
-obviously a free UDP/IP Stack is the best but also a licensed one could be fine

Is there anywhere an UDP/IP stack with these features?

Thank you very much!

Expert Contributor
drjohnsmith
Posts: 917
Registered: ‎07-09-2009
0

Re: UDP IP stack on a Spartan-6

HI

 

I've just done a google and found a lot of links to this, including xilinx Xapps,

 

try this 

 

http://www.cs.york.ac.uk/rts/docs/Xilinx-datasource-2003-q1/Xcell%20Journal%20Articles/xcell_pdfs/xc...

Expert Contributor
evgenis1
Posts: 338
Registered: ‎12-03-2007

Re: UDP IP stack on a Spartan-6

Hi,

 

I needed a custom implementation of UDP a while ago (Verilog, no processor). Researching available cores didn't produce any good results, so I've implemented the stack from scratch. Depending on the features you want it can be relatively simple or complex. Do you want IP fragmentation or not; how do you assign IP: static or DHCP; do you need ARP; do you need an application protocol on top of UDP (like TFTP), and several other considerations.

 

 

Thanks,

Evgeni

Expert Contributor
joelby
Posts: 1,056
Registered: ‎10-05-2010

Re: UDP IP stack on a Spartan-6

If you just want to periodically generate UDP packets, it's very easy to do this with a fairly simple state machine.

 

You're welcome to look at the example I've written, at http://tristesse.org/DigilentAtlysResources that does just this. It's running successfully on a Spartan 6. It's written in Verilog, but the UDP/IP/Ethernet part alone would be trivial to rewrite in VHDL if you so desired.

Visitor
u4usman_786
Posts: 1
Registered: ‎05-11-2011
0

Re: UDP IP stack on a Spartan-6

I Download your code in spartan 6 Atlys Board I change the physical address and Ip address and than simulate and burn on board it cannot send any data on th UDP

Please guide me how yor code  will work on my board

Thanks

Expert Contributor
joelby
Posts: 1,056
Registered: ‎10-05-2010
0

Re: UDP IP stack on a Spartan-6

In that particular implementation the IP header checksum is hard coded. If you change it, your computer may just drop the packets before reaching user space. You'll need to manually recalculate the correct checksum (it's very easy) or for the ultimate flexibility write a calculation step into the state machine (I went on to do this later and it was very easy).
Visitor
fadikhn
Posts: 3
Registered: ‎05-03-2011
0

Re: UDP IP stack on a Spartan-6

Same problem i have faced, How can i calculate the checksum? i just change the IP addrs and Mc addrs, do i need to change any other thing?

 

When i burn the code the LAN leds goes on but i didn't see any thing on wireshark. Can you guide me how i can add the calculation steps into the state machine which you are talking about.

 

Regards.

Fadi

 

Expert Contributor
joelby
Posts: 1,056
Registered: ‎10-05-2010
0

Re: UDP IP stack on a Spartan-6

Read the checksum section on the Wikipedia page: http://en.m.wikipedia.org/wiki/IPv4#Header

I calculated it manually and updated the HDL, but for any "real" application you'll want to implement this calculation in HDL so that you can change the IP header at will. Let me know if you have any trouble figuring it out and I'll dig up my code when I'm back at work next week.
Visitor
fadikhn
Posts: 3
Registered: ‎05-03-2011
0

Re: UDP IP stack on a Spartan-6

i calculated the checksum  and i have tried but did get any thing

can you tell me what i m doing wrong

 

 

initial begin
packet_buffer[0] = 32'h0016_d402; // dstmac (8)
packet_buffer[1] = 32'hec32_0018; // dstmac (4), srcmac (4)
packet_buffer[2] = 32'h3e00_c926; // srcmac(8)
packet_buffer[3] = 32'h0800_4500; // hwtype ethernet (4), protocol type ipv4 (1),  header length (1) (*4), dsc (2)
packet_buffer[4] = 32'h0023_1234; // total length (4), identification (4), 
packet_buffer[5] = 32'h0000_4011; // flags/frag offset (4), ttl (2), protocol (2)
packet_buffer[6] = 32'he53a_c0a8; // checksum (4), srcip (4)
packet_buffer[7] = 32'h0103_c0a8; // srcip (4), dstip (4)
packet_buffer[8] = 32'h0108_0402; // dstip (4), srcport(4)
packet_buffer[9] = 32'h0404_000f; // dstport (4), length (4)
packet_buffer[10] = 32'h0000_4846; // checksum (4), data (4)
packet_buffer[11] = 32'h4c4c_4f40; // data
end
My
Source IP: 192.168.1.3
Destination IP: 192.168.1.8
Source Mac Addrss: 00183e00c926
Destination Mac Addrss: 0016d402ec34
LAN Leds are blinking but i didn't see anything on wireshark,
On network it didn't pick the IP which i m assigning to FGPA. don't know whats wrong?

 

Expert Contributor
joelby
Posts: 1,056
Registered: ‎10-05-2010
0

Re: UDP IP stack on a Spartan-6

Your checksum is wrong. I get:

 

4500 + 0023 +1234 + 0000 + 4011 + 0000 + c0a8 + 0103 + c0a8 + 0108

= 21AC3

 

2 + 1AC3 = 1AC5

 

Things to note:

 

 

  • When doing the calculation, set the IP checksum to zero
  • You only checksum the IP header. Skip the MAC addresses and hwtype. Start from 4500. Assuming you used a normal header with no options, you'll stop after the dstip. srcport is the first part of the UDP header.