Author Topic: Open (functional!) core for Ethernet / VHDL for Ethernet - Spartan 6?  (Read 18994 times)

0 Members and 1 Guest are viewing this topic.

Offline Kremmen

  • Super Contributor
  • ***
  • Posts: 1283
  • Country: fi
Hi, my turn to pose a tough nut - at least for me. For an upcoming project i am looking for alternatives for connecting to Ethernet from a motion control system. One alternative is to use a FPGA and it would have to be a Xilinx Spartan 6. I am not about to sell the house to license a Xilinx core for this so the question is, if any open alternatives exist. While Google has come up with something, the definitive solution escapes me still. I would only need a relatively basic implementation supporting the basic stack and IP, TCP but nothing more - well possibly ping but that's it.

All pointers / hints gratefully accepted. A generic solution or one tailored for a different environment would be good info, because i am prepared to do necessary modifications, just don't have the time to start from scratch.
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline AndyC_772

  • Super Contributor
  • ***
  • Posts: 3503
  • Country: gb
  • Professional design engineer
    • Cawte Engineering | Reliable Electronics
Re: Open (functional!) core for Ethernet / VHDL for Ethernet - Spartan 6?
« Reply #1 on: February 15, 2013, 11:35:38 am »
Another option is to use a microcontroller that includes an Ethernet interface, and for which an IP stack is freely available. If I recall correctly, Microchip have one that you can use on a PIC32 platform.

Doing it in an FPGA is certainly possible, but probably more time consuming than you'd like. I've done the RMII bit myself, and although it's not "difficult" as such, it does mean spending rather a lot of time doing stuff at a very low level that's already been done many times before in other devices.

Offline Balaur

  • Supporter
  • ****
  • Posts: 525
  • Country: fr
Re: Open (functional!) core for Ethernet / VHDL for Ethernet - Spartan 6?
« Reply #2 on: February 15, 2013, 11:55:47 am »
I have some (i.e. not extensive) experience on this, so please take my comments as is.

In early 2003, I had to design a system around a FPGA with some kind of Ethernet connectivity. After a lot of considerations, I've choose something like this.

The choice was motivated by many factors, including cost and availability of user-friendly Ethernet solutions (not that many at the time). There was significant effort in developing and especially validating the firmware, which was rather complex. We manufacture several tens of such devices and they are still in usage right now.

Then, I helped designing a FPGA-only system where the Ethernet connectivity consists in a Xilinx Virtex 4 with embedded PowerPC CPUs and a Linux OS, eventually complemented by a off-the-shelf Ethernet PHY device.

The practical learning of all this is that if you don't want/cannot spend a lot of effort by starting from scratch. You need a fairly good base that usually consists in a CPU, an OS with UDP and TCP/IP capabilities and so on.
Frankly, I cannot see how you can go halfway/basic with the transport layer (TCP/IP or UDP let's say) stuff. It's relatively complex and a custom implementation is bound to encounter problems when connecting to a reasonable-sized network or when transiting through the first hub or switch.

From my perspective, it's not reasonable to start from scratch. It's much more efficient to start with an existing solution, for both technical and cost considerations.
A single-board computer (starting from USD 25) will most likely offer the features, quality and performances you'll need. Use GPIOs to get out of the CPU.
Or choose a FPGA device and a PHY chip; I think that some Ethernet solutions licenses are free in some cases. You will still need a CPU and an OS. It's usually my second preference as it may restrict the implementation choices and will certainly make you spend some time to understand if the licenses you need for your particular eth>cpu>os combination is free or affordable.

Best regards,
Dan
 

Offline Kremmen

  • Super Contributor
  • ***
  • Posts: 1283
  • Country: fi
Re: Open (functional!) core for Ethernet / VHDL for Ethernet - Spartan 6?
« Reply #3 on: February 15, 2013, 12:33:03 pm »
Thanks guys. It is exactly these points that prompted me to ask after an already functional implementation. I don't have the time to do the low level stuff from scratch, nor the motivation, frankly.
Also, my plans do not include a soft processor in the FPGA which raises the bar still more. My requirements as to the Ethernet functionality are not complex - this will not be a general purpose Ethernet host, but rather a purpose oriented device running in a dedicated network segment.

The alternative and indeed possibly the first choice is to run Ethernet in a regular microcontroller, because there will be one - an ARM or a 32 bit Atmel. It is just that this is a distributed system and the early system design is in progress. I have yet to fix the hardware platform for each interface.
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline poorchava

  • Super Contributor
  • ***
  • Posts: 1548
  • Country: pl
  • Troll Cave Electronics!
Re: Open (functional!) core for Ethernet / VHDL for Ethernet - Spartan 6?
« Reply #4 on: February 15, 2013, 02:11:21 pm »
How about WizNET W5100 IC? For ~$9 in singles and half of that @1kpcs you get MAC+PHY with integrated protocol stack supporting TCP, UDP, IPv4, ICMP, ARP, IGMP and PPPoE. It has 3 different interfaces including parallel 'direct bus interface' to simple SPI.

I'd say it's worth its  price considering how much time (=money) you would have to spend to implement all that in an FPGA.
I love the smell of FR4 in the morning!
 

Offline free_electron

  • Super Contributor
  • ***
  • Posts: 7267
  • Country: us
    • SiliconValleyGarage
Re: Open (functional!) core for Ethernet / VHDL for Ethernet - Spartan 6?
« Reply #5 on: February 15, 2013, 02:52:41 pm »
Get an stm32 with built-in ethernet. Use the mikro-e compiler. They give you the entire stack for free. Compiler costs 200$.... No runtime fees (important to know!  A lot of stacks require a runtime fee.. Cmx, micrium etc )
Problem solved.
Professional Electron Wrangler.
Any comments, or points of view expressed, are my own and not endorsed , induced or compensated by my employer(s).
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 18331
  • Country: nl
    • NCT Developments
Re: Open (functional!) core for Ethernet / VHDL for Ethernet - Spartan 6?
« Reply #6 on: February 15, 2013, 03:20:41 pm »
Another route is Freertos which runs on almost any microcontroller. Several microcontroller vendors took care of the license fees of an ethernet stack so if you buy their devices, you already have a license.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline Kremmen

  • Super Contributor
  • ***
  • Posts: 1283
  • Country: fi
Re: Open (functional!) core for Ethernet / VHDL for Ethernet - Spartan 6?
« Reply #7 on: February 15, 2013, 04:28:02 pm »
The thing with the processor solution is that if i do the Ethernet there, it needs to coexist with lots of other stuff. So the processor is not only for Ethernet.
FreeRTOS is an old friend and my RTOS of choice; i have done several projects with it. It was in the plans for this project as well. For me the most familiar chip would be an Atmel UC3C that supports Ethernet. The good thing is that the toolchain is free and familiar with no restrictions and i already have much of the code needed for this application. So unless any serious altermnatives emerge on the FPGA side, that will be my Plan A.
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline mrflibble

  • Super Contributor
  • ***
  • Posts: 1947
  • Country: nl
Re: Open (functional!) core for Ethernet / VHDL for Ethernet - Spartan 6?
« Reply #8 on: February 15, 2013, 06:02:56 pm »
Depends on the datarate. If you need only 10 or 100 MBit I would go the microcontroller route.

Low IP cost on the fpga usually means <insert plenty of development time here/>. If you only need UDP then for the stack side of it you can get away with a fairly simple FSM, assuming an external PHY. But if you want a full tcp/ip stack you'll need either a softcore or aspirin. Since you say you don't have lots of time to spend on it, and don't even mention a datarate which henceforth shall assumed to be low, mcu it is. ;)

And if you do find a cheap solution for a full tcp/ip stack on spartan-6, please post details. :)
 

Offline Kremmen

  • Super Contributor
  • ***
  • Posts: 1283
  • Country: fi
Re: Open (functional!) core for Ethernet / VHDL for Ethernet - Spartan 6?
« Reply #9 on: February 15, 2013, 07:30:06 pm »
Definitely no more than 100 Mb needed, even 10 would do it but i'm targeting 100 - for no specific reason.
Looks like it will be more trouble than it's worth to try the FPGA route. Oh well, maybe it was a long shot anyway and i don't think the project will actually suffer from doing the network bit in an MCU.
At this point i don't have high hopes of actually finding a worthwhile free implementation for a FPGA. But if miracles happen, i'll be sure to let you know.
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline Smokey

  • Super Contributor
  • ***
  • Posts: 1595
  • Country: us
Re: Open (functional!) core for Ethernet / VHDL for Ethernet - Spartan 6?
« Reply #10 on: February 15, 2013, 08:54:11 pm »
Is there anything on OpenCores you could use?
http://opencores.org/projects
 

Offline mrflibble

  • Super Contributor
  • ***
  • Posts: 1947
  • Country: nl
Re: Open (functional!) core for Ethernet / VHDL for Ethernet - Spartan 6?
« Reply #11 on: February 15, 2013, 09:45:40 pm »
You mean as counter examples for good design? Sure thing!
 

Offline joelby

  • Frequent Contributor
  • **
  • Posts: 634
Open (functional!) core for Ethernet / VHDL for Ethernet - Spartan 6?
« Reply #12 on: February 17, 2013, 01:54:10 am »
Designing a general purpose TCP implementation in HDL is a bit tricky. UDP is much easier though. For a design that works on a Spartan-6 with the 88E1111 MAC at 1000 Mbps (only), have a look at http://tristesse.org/FPGA/DigilentAtlysResources .
 

Offline Kremmen

  • Super Contributor
  • ***
  • Posts: 1283
  • Country: fi
Re: Open (functional!) core for Ethernet / VHDL for Ethernet - Spartan 6?
« Reply #13 on: February 17, 2013, 01:30:55 pm »
Thanks, for some reason i missed this. The 1Gb only could be a showstopper because the actual network may be incapable, but perhaps it can be modified. We'll see.
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline marshallh

  • Supporter
  • ****
  • Posts: 1462
  • Country: us
    • retroactive
Re: Open (functional!) core for Ethernet / VHDL for Ethernet - Spartan 6?
« Reply #14 on: February 18, 2013, 10:23:47 pm »
Forget about full network on FPGA unless you are an HDL god or have money/time to blow getting the POS jokes on opencores to work.

Recommend using a MCU with 10/100 built in and cooking up a simple bus to communicate between the mcu/fpga.
Verilog tips
BGA soldering intro

11:37 <@ktemkin> c4757p: marshall has transcended communications media
11:37 <@ktemkin> He speaks protocols directly.
 

Offline Kremmen

  • Super Contributor
  • ***
  • Posts: 1283
  • Country: fi
Re: Open (functional!) core for Ethernet / VHDL for Ethernet - Spartan 6?
« Reply #15 on: February 18, 2013, 10:36:01 pm »
Forget about full network on FPGA unless you are an HDL god or have money/time to blow getting the POS jokes on opencores to work.

Recommend using a MCU with 10/100 built in and cooking up a simple bus to communicate between the mcu/fpga.
Its starting to look more and more like a pointless tour de force to do in the FPGA. No functional solutions seem to be freely available. Opencores is mostly a joke and the licensed cores cost an arm and a leg. While i can hold my own in VHDL, a full Ethernet stack is the opposite of trivial to start from scratch, not an option really because Ethernet is not the point of the project, just a tool to move data.

Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline codeboy2k

  • Super Contributor
  • ***
  • Posts: 1838
  • Country: ca
Re: Open (functional!) core for Ethernet / VHDL for Ethernet - Spartan 6?
« Reply #16 on: February 19, 2013, 06:48:47 am »
seconded, the MCU with built in ethernet.

One approach would be to make a memory mapped interface between the MCU and the FPGA if you can, i.e. the MCU looks like memory to the FPGA, or the FPGA looks like memory to the MCU.  There are some MCU's with built in Ethernet that already have an interface that can talk to SRAM, so you can use that to communicate to your FPGA's BRAM and send buffers of data, using mailboxes in the BRAM to indicate status, data ready, etc, plus some external GPIO and interrupt pins

Some MCU's can use one of their built in DMA controllers to communicate to the FPGA as well.

my point being, choose an MCU with either a built in SRAM controller, or one that has enough hardware DMA. This will make interfacing the MCU and FPGA much easier without sacrificing bandwidth by using a simple SPI or USART or I2C interface.

« Last Edit: February 19, 2013, 06:52:02 am by codeboy2k »
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 18331
  • Country: nl
    • NCT Developments
Re: Open (functional!) core for Ethernet / VHDL for Ethernet - Spartan 6?
« Reply #17 on: February 19, 2013, 11:13:33 am »
Forget about full network on FPGA unless you are an HDL god or have money/time to blow getting the POS jokes on opencores to work.

Recommend using a MCU with 10/100 built in and cooking up a simple bus to communicate between the mcu/fpga.
Its starting to look more and more like a pointless tour de force to do in the FPGA. No functional solutions seem to be freely available. Opencores is mostly a joke and the licensed cores cost an arm and a leg. While i can hold my own in VHDL, a full Ethernet stack is the opposite of trivial to start from scratch, not an option really because Ethernet is not the point of the project, just a tool to move data.
IMHO the designs on Opencores aren't the best but some are usefull. You just need to check the code a bit to see if the author knows what he/she is doing.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline joelby

  • Frequent Contributor
  • **
  • Posts: 634
Re: Open (functional!) core for Ethernet / VHDL for Ethernet - Spartan 6?
« Reply #18 on: February 19, 2013, 12:50:37 pm »
Thanks, for some reason i missed this. The 1Gb only could be a showstopper because the actual network may be incapable, but perhaps it can be modified. We'll see.

Yep, I don't think it'd be too tricky to modify it to 100 Mbps (only). The MAC in my implementation was taken from the USRP project. In its original form it was not documented at all (and unfortunately my example implementation currently only does a tiny bit to mitigate this) but the code is reasonably straightforward, if a little overcomplicated.
 

Offline Kremmen

  • Super Contributor
  • ***
  • Posts: 1283
  • Country: fi
Re: Open (functional!) core for Ethernet / VHDL for Ethernet - Spartan 6?
« Reply #19 on: February 19, 2013, 04:15:57 pm »
seconded, the MCU with built in ethernet.

One approach would be to make a memory mapped interface between the MCU and the FPGA if you can, i.e. the MCU looks like memory to the FPGA, or the FPGA looks like memory to the MCU.  There are some MCU's with built in Ethernet that already have an interface that can talk to SRAM, so you can use that to communicate to your FPGA's BRAM and send buffers of data, using mailboxes in the BRAM to indicate status, data ready, etc, plus some external GPIO and interrupt pins

Some MCU's can use one of their built in DMA controllers to communicate to the FPGA as well.

my point being, choose an MCU with either a built in SRAM controller, or one that has enough hardware DMA. This will make interfacing the MCU and FPGA much easier without sacrificing bandwidth by using a simple SPI or USART or I2C interface.
Yes, i have to decide soon(ish) and although the FPGA route may not be a totally lost cause, i guess it will be for another day.

My MCU of choice would be the Atmel UC3C due to a number of factors:
- first and foremost, it is a familiar chip,
- the toolchain is free and open (gcc), with an out-of-the box functional IDE. And it supports C++ (don't want to use anything else)
- built-in Ethernet MAC
- built-in high speed external bus interface
- separate dedicated memory and peripheral DMA controllers
- hardware assisted peripheral event controller and bus (and i know how to use it)
- hardware floating point unit (must have this)
- a shitload of other peripherals, many of which i will need

Alternative candidates would be ARMs, most likely Cortex M4F that would have many of the same features. If only they had similarly easy and uncrippled toolchains available. I know you can roll your own and i am looking into it. Just noted i have a couple of Stellaris Launchpads sitting on the shelf unused. Maybe take a look into those. Then there is the STM32 and i have heard NXP makes some credible ARMs as well.
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline TheDirty

  • Frequent Contributor
  • **
  • Posts: 440
  • Country: ca
Re: Open (functional!) core for Ethernet / VHDL for Ethernet - Spartan 6?
« Reply #20 on: February 19, 2013, 05:38:07 pm »
Somebody already mentioned using one of the Wiznet chips, but there was no response to this.  It seems like a perfect solution.  W5200 or W5100.  It's been a few years since I worked with them, so I don't know the updates.
Mark Higgins
 

Offline Kremmen

  • Super Contributor
  • ***
  • Posts: 1283
  • Country: fi
Re: Open (functional!) core for Ethernet / VHDL for Ethernet - Spartan 6?
« Reply #21 on: February 19, 2013, 06:47:59 pm »
Those Wiznet chips actually look quite interesting. I will have to take a more detailed look into the MCU interface, but it looks like the controller contains at least all that is needed here. Since the Atmel MCU already comes with a MAC, the choice is between using the Wiznet chip or e.g. a TI DP83848I PHY transceiver and a software stack. The LwIP is directly supported in Atmel Software Framework. Using the MCU MAC + SW stack will result in a "true" TCP/IP interface to the app SW. The Wiznet chip provides a SPI interface and i will have to check what kind of data structures it carries over that link. Could be a tough choice. Sure, the Wiznet chip is 4 times the price of the lowest cost Micrel alternative, but maybe that is not a showstopper in a short production run.
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 18331
  • Country: nl
    • NCT Developments
Re: Open (functional!) core for Ethernet / VHDL for Ethernet - Spartan 6?
« Reply #22 on: February 19, 2013, 10:08:56 pm »
Alternative candidates would be ARMs, most likely Cortex M4F that would have many of the same features. If only they had similarly easy and uncrippled toolchains available. I know you can roll your own and i am looking into it. Just noted i have a couple of Stellaris Launchpads sitting on the shelf unused. Maybe take a look into those. Then there is the STM32 and i have heard NXP makes some credible ARMs as well.
Codesourcery lite for ARM is free and has no limitations. It is the full blow GCC (and binutils). Any IDE which knows how to drive GCC can be used as a front-end.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline Kremmen

  • Super Contributor
  • ***
  • Posts: 1283
  • Country: fi
Re: Open (functional!) core for Ethernet / VHDL for Ethernet - Spartan 6?
« Reply #23 on: February 19, 2013, 11:12:49 pm »
Actually, i am just in the process of looking into that. Sourcery installed with little problems, now it is just to persuade Eclipse to play along...
Nothing sings like a kilovolt.
Dr W. Bishop
 

Offline Scrts

  • Frequent Contributor
  • **
  • Posts: 601
  • Country: lt
Re: Open (functional!) core for Ethernet / VHDL for Ethernet - Spartan 6?
« Reply #24 on: February 25, 2013, 10:22:42 am »
OpenCores has 10/100Mbps MAC, which works on Altera FPGAs. You can also consider choosing new FPGA with Ethernet MAC already built-in. Or if You only need some basic data transmission (e.g. using fixed length packets and UDP protocol), then it is not so hard to write Your own MAC. The hardest part will be CRC32, but it is already available in VHDL on the internet.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf