Author Topic: Ethernet and FPGAs?  (Read 4199 times)

0 Members and 1 Guest are viewing this topic.

Offline Thane of CawdorTopic starter

  • Regular Contributor
  • *
  • Posts: 96
Ethernet and FPGAs?
« on: September 05, 2021, 09:32:26 am »
I am working on an FPGA design and I'm on a journey to connect an ethernet port (10Mbps) to the FPGA by using the least amount of FPGA IO. From reading, there are a two main options:

1. RJ45 -> magnetics -> ethernet controller (MAC -> PHY) -> FPGA

2. RJ45 -> magnetics -> PHY -> FPGA (using RGMII, RMII, MII) and ethernet IP core

Has anyone here had experience with a similar design and recommend any method?
« Last Edit: September 12, 2021, 05:28:01 am by Thane of Cawdor »
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9885
  • Country: us
Re: Ethernet and FPGAs?
« Reply #1 on: September 05, 2021, 02:53:52 pm »
That ENC28J60 has been around for a long time and is available on a small PCB for about $9

https://www.amazon.com/HiLetgo-ENC28J60-Ethernet-Network-Arduino/dp/B00WX1NRO0

This approach still leaves the daunting task of implementing the TCP/IP (or UDP/IP) stack in FPGA fabric unless you are using a programmable CPU core but there is a project at Opencores.org that implements the stack and it uses the ENC28J60

You may have to register to get to the file but it does exist.

https://opencores.org/projects/tcp_ip_core_w_dhcp

I used the ENC28J60 with the uIP stack (predecessor to the lwIP stack) a long while back with a LPC2106 ARM board.  It made a connection with a Linux server and grabbed music files to play.  Just a demonstration, really but it all worked well.
« Last Edit: September 05, 2021, 02:56:22 pm by rstofer »
 
The following users thanked this post: Thane of Cawdor

Offline Thane of CawdorTopic starter

  • Regular Contributor
  • *
  • Posts: 96
Re: Ethernet and FPGAs?
« Reply #2 on: September 05, 2021, 03:38:41 pm »
Thanks  :-+ I have been reading into that chip and it looks quite good, I shall continue the research. Do you by chance know the logic/memory resources (approximately) required to implement the required cores? Out of interest, have you had any experience working with 1000BASE-T ethernet? If so, do you need a high-end FPGA to get 1Gbps to work with available MAC IP?
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9885
  • Country: us
Re: Ethernet and FPGAs?
« Reply #3 on: September 05, 2021, 04:12:36 pm »
The Artix A7 has onboard PHY and MAC and can do 10/100 Mbps.  The Opencores project I linked above struggles to make 10 Mbps and that is primarily a limitation of the ENC28J60 (10 Mbps).  The problem with the project may be that it will only handle one connection at a time.  I don't know what to think about the limitation.  Both of my projects only required one connection.

https://digilent.com/shop/arty-a7-artix-7-fpga-development-board/

The Opencores project doesn't talk about resources, AFAICT.

The high dollar Nexys Video Artix-7 will do 10/100/1000 Mbps

https://digilent.com/shop/nexys-video-artix-7-fpga-trainer-board-for-multimedia-applications/

Here's a white paper regarding Xilinx's IP core for lwIP

https://www.xilinx.com/support/documentation/application_notes/xapp1026.pdf
 
The following users thanked this post: Thane of Cawdor

Offline Thane of CawdorTopic starter

  • Regular Contributor
  • *
  • Posts: 96
Re: Ethernet and FPGAs?
« Reply #4 on: September 05, 2021, 04:31:02 pm »
Thanks for the information  :-DMM I am interested in using a lower cost Actel part like the IGLOO series, hence the interest in the resources. I imagine it would be difficult to achieve greater than 10Mbps due to the reason you mentioned and unlike the higher end IGLOO2 series, there is no ethernet MAC IP for the device. Thanks for the links, I'll have a look through them now.
 

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9885
  • Country: us
Re: Ethernet and FPGAs?
« Reply #5 on: September 05, 2021, 04:52:27 pm »
That's why I went with the mbed LPC1768.  It had a 100 Mbps MAC built on the card and the lwIP stack supported Berkeley Sockets - all I needed for my simple project.

https://www.digikey.com/en/product-highlight/n/nxp-semi/mbed-lpc1768-development-board

I still had to write the state machine to make the connection, transfer the data and terminate the connection.  Not a big deal...

There are 126 in stock at DigiKey...

I use the online mbed development tools: https://os.mbed.com/

ETA:

This project was created in June 2012 so it's been a while.  It still compiles so I assume the libraries are still available.
« Last Edit: September 05, 2021, 05:18:18 pm by rstofer »
 
The following users thanked this post: Thane of Cawdor

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Ethernet and FPGAs?
« Reply #6 on: September 05, 2021, 06:03:43 pm »
I played around with the ENC28J60 chips several years ago, IIRC they're pretty much crap. They run hot, consume a lot of power, and are very buggy. I didn't think people were using them much these days, all of the consumer stuff has switched to wifi.
 
The following users thanked this post: Thane of Cawdor

Online nctnico

  • Super Contributor
  • ***
  • Posts: 26684
  • Country: nl
    • NCT Developments
Re: Ethernet and FPGAs?
« Reply #7 on: September 05, 2021, 06:38:07 pm »
For an external ethernet chip the Wiznet chips are a much better choice nowadays but it is still good to have some kind of processor inside the FPGA to deal with handling connections.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 
The following users thanked this post: Thane of Cawdor

Offline Bassman59

  • Super Contributor
  • ***
  • Posts: 2501
  • Country: us
  • Yes, I do this for a living
Re: Ethernet and FPGAs?
« Reply #8 on: September 06, 2021, 02:16:08 am »
Thanks for the information  :-DMM I am interested in using a lower cost Actel part like the IGLOO series, hence the interest in the resources. I imagine it would be difficult to achieve greater than 10Mbps due to the reason you mentioned and unlike the higher end IGLOO2 series, there is no ethernet MAC IP for the device. Thanks for the links, I'll have a look through them now.

I'm with nctnico on this -- if you need to put Ethernet into an Igloo FPGA, use the WizNet WZ5500. It interfaces to the FPGA over SPI. But as he notes you still need something smart inside the FPGA.

Perhaps you can use the Igloo M1 variant, which lets you embed an ARM Cortex-M1 in the FPGA? Then you can use some standard driver software (WizNet has code!) to handle your data.
 
The following users thanked this post: Someone, Thane of Cawdor

Offline rstofer

  • Super Contributor
  • ***
  • Posts: 9885
  • Country: us
Re: Ethernet and FPGAs?
« Reply #9 on: September 06, 2021, 03:12:02 pm »
For an external ethernet chip the Wiznet chips are a much better choice nowadays but it is still good to have some kind of processor inside the FPGA to deal with handling connections.

The Wiznet 6100 seems like a good place to start.  It handles all of the protocol details and the SPI interface is easy to implement on the FPGA.  Packet buffering is provided on the 6100 and it supports 8 sockets.

https://www.mouser.com/ProductDetail/WIZnet/W6100-MKR-Ethernet-Shield?qs=PzGy0jfpSMsWeVRjaTiNjQ%3D%3D

So, I ordered one!  There should be 3 left in stock...


 
The following users thanked this post: Thane of Cawdor

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Ethernet and FPGAs?
« Reply #10 on: September 08, 2021, 03:30:43 am »
A friend of mine used a Wiznet ethernet part in a project a while back, must have been around 15 years ago. I remember him saying it worked really well, though at the time at least it was an expensive part.
 
The following users thanked this post: Thane of Cawdor

Offline SiliconWizard

  • Super Contributor
  • ***
  • Posts: 14230
  • Country: fr
Re: Ethernet and FPGAs?
« Reply #11 on: September 08, 2021, 04:59:02 pm »
The Wiznet chips seem to be pretty good indeed. Now, don't expect very high data throughput with them, of course. If you need the throughput you can get with 1Gbps Ethernet, look elsewhere.
 
The following users thanked this post: Thane of Cawdor

Online ejeffrey

  • Super Contributor
  • ***
  • Posts: 3669
  • Country: us
Re: Ethernet and FPGAs?
« Reply #12 on: September 08, 2021, 07:50:18 pm »
I've used the wiznet 5500 with a cortex M0+ using their provided "almost BSD socket" library and DHCP client.  They work pretty well for what they are.  You won't get high performance of course, but good enough for the intended applications. 

The fixed socket table is kind of annoying for TCP server applications, but I wouldn't recommend that on a microcontroller anyway.  A TCP client would be fine, or UDP applications if you can tolerate its limitations.  It doesn't support HTTPS/TLS or any sort of serious authentication and you probably aren't going to implement that on a simple microcontroller either, so it is best used on a private network in most cases.

« Last Edit: September 08, 2021, 08:07:01 pm by ejeffrey »
 
The following users thanked this post: Thane of Cawdor

Offline AaronLee

  • Regular Contributor
  • *
  • Posts: 229
  • Country: kr
Re: Ethernet and FPGAs?
« Reply #13 on: September 09, 2021, 12:10:55 am »
Another vote for Wiznet. That solution has worked well for me, as well as Zynq FPGAs with the PS side controlling the Ethernet and using LWIP.
 
The following users thanked this post: Thane of Cawdor

Offline laugensalm

  • Regular Contributor
  • *
  • Posts: 104
  • Country: ch
Re: Ethernet and FPGAs?
« Reply #14 on: September 10, 2021, 05:31:06 pm »
Wiznet W5500 is fine for only up to 4 concurrent TCP streams (aka sockets). However, malicious users on the network can cause those chips to stall (requiring reboot), so for more robustness I went for a Ethernet core, see also https://www.eevblog.com/forum/fpga/1gb-ethernet-core/. Logic consumption isn't that bad, porting a proper stack is most of the work though (which means, you'll need to have the resources for a compact CPU core).

 
The following users thanked this post: Thane of Cawdor

Offline Scrts

  • Frequent Contributor
  • **
  • Posts: 797
  • Country: lt
Re: Ethernet and FPGAs?
« Reply #15 on: September 10, 2021, 07:22:23 pm »
For Altera it's easy to instantiate their NIOSII/e and ethernet MAC core (there's a tri-speed 10/100/1000Mb base-T but for 10Mb/s only maybe there is a smaller one) and use a NIOSII supported IP stack nichestack etc.

Yes, I've done this with Cyclone III utilizing Altera Tri-Speed MAC, Nios II without RTOS & LwIP 1.4.0. This was about 10 years ago...

 
The following users thanked this post: Thane of Cawdor

Offline zkf0100007

  • Contributor
  • Posts: 18
  • Country: cn
Re: Ethernet and FPGAs?
« Reply #16 on: October 13, 2021, 05:21:57 am »
 

Offline radiolistener

  • Super Contributor
  • ***
  • Posts: 3227
  • Country: ua
Re: Ethernet and FPGAs?
« Reply #17 on: October 14, 2021, 02:20:07 am »
Some time ago I was used cheap Chinese LAN8720 Ethernet PHY 10/100 module.
https://www.aliexpress.com/item/33037526970.html

It is cheap, very simple and provides 10/100 RMII interface. Works very good and stable, almost no heating. The advantage of this module is that it doesn't requires a lot of signal wires. You're needs just 7 wires to use PHY (+2 for GND and VCC) and 2 additional wires for MDIO bus to configure it's registers. It works from 3.3V power supply.

The only con is that it doesn't supports 1 gigabit speed, the max ethernet speed for LAN8720 is just 100 megabit.
Since I need high speed transfer, later I switched to QMTECH board with RTL8211EG, it needs much more signals than LAN8720, but allows to use 10/100/1000 M speed.


So, if 10/100 M ethernet speed is good enough for your needs, then that LAN8720 module will be the best choice. But try to find some FPGA starter kit board which already has ethernet PHY on the board, it will be much more convenient when you don't have extra wires and modules :)
« Last Edit: October 14, 2021, 02:39:55 am by radiolistener »
 

Offline asmi

  • Super Contributor
  • ***
  • Posts: 2728
  • Country: ca
Re: Ethernet and FPGAs?
« Reply #18 on: October 14, 2021, 04:06:05 am »
Actually the most pin-efficient solution is SGMII. But it requires FPGA which can do 1.25Gbps over differential pair. Something like 7 series speed grade 2 or higher. Or slower one, but with gigabit transceiver.

Offline radiolistener

  • Super Contributor
  • ***
  • Posts: 3227
  • Country: ua
Re: Ethernet and FPGAs?
« Reply #19 on: October 14, 2021, 05:14:39 am »
Actually the most pin-efficient solution is SGMII. But it requires FPGA which can do 1.25Gbps over differential pair. Something like 7 series speed grade 2 or higher. Or slower one, but with gigabit transceiver.

for GMII PHY you're needs to be very careful with transmission lines layout and length. For SGMII it will be even more important.
 

Offline jeremy

  • Super Contributor
  • ***
  • Posts: 1079
  • Country: au
Re: Ethernet and FPGAs?
« Reply #20 on: October 14, 2021, 08:18:29 am »
Actually the most pin-efficient solution is SGMII. But it requires FPGA which can do 1.25Gbps over differential pair. Something like 7 series speed grade 2 or higher. Or slower one, but with gigabit transceiver.

for GMII PHY you're needs to be very careful with transmission lines layout and length. For SGMII it will be even more important.

SGMII is actually easier than GMII; your only problem is really just routing a single diff pair. And it is only 1.25Gbps, so as long as you use a calculator for the impedance matching, you should be able to make some fairly long traces without much effort.

As for the original post, you don't need to use a full MAC if you just want to get data from FPGA to PC as a starter project and can plug the device straight into the PC, you can just write the raw ethernet frame for a UDP packet straight to the PHY and it will work (though the OS may force you to assign a static IP to the PC).
 

Online ejeffrey

  • Super Contributor
  • ***
  • Posts: 3669
  • Country: us
Re: Ethernet and FPGAs?
« Reply #21 on: October 14, 2021, 08:44:42 am »
Actually the most pin-efficient solution is SGMII. But it requires FPGA which can do 1.25Gbps over differential pair. Something like 7 series speed grade 2 or higher. Or slower one, but with gigabit transceiver.

for GMII PHY you're needs to be very careful with transmission lines layout and length. For SGMII it will be even more important.

Sgmii is actually pretty easy.  There is a single differential pair in each direction and length matching between tx and rx is not critical. Length matching withing the diff pairs is important but not hard to accomplish as they will be routed together from adjacent pins.  You can invert the polarity in the fpga if you need to.
 

Offline jeremy

  • Super Contributor
  • ***
  • Posts: 1079
  • Country: au
Re: Ethernet and FPGAs?
« Reply #22 on: October 14, 2021, 09:49:42 am »
If I recall the tx and rx pair don’t have any length matching requirements at all (between tx and rx, you still need to length match the pairs + and -). More of the issue is ensuring that clocks are stable on both ends with low jitter.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf