How to couple a FPGA and a MPU? - Page 1
Forum section: electronics / general

author: technix
author_rank: Super Contributor
timestamp: July 24, 2017, 08:17:44 pm
content: The two pals I want to couple in question: AT91SAM9260 and EP4CE15E22C8N. The former is an ARM926EJ-S SoC that runs a Linux-based host system. The latter is a FPGA that I want it to do things with the processor. Questions:* Can I hold the FPGA in reset until the ARM boots and loads the FPGA with its configuration?* If so, can the FPGA configuration loading channel be used as a channel of communication between the FPGA and the SoC after the FPGA is loaded?* What is the best communication channel - parallel system bus, or some kind of serial interface?* For AT91SAM9260, how to DMA into and out of the FPGA given the communication channel?Also is this a reasonable system spec?* SoC subsystem: AT91SAM9260 ARM926EJ-S @180MHz, 128MB (32M x32) SDRAM, 512MB SLC NAND, microSD card slot, Wi-Fi over SDIO, BT over UART, 10/100 Ethernet, 800x480 LCD with capacitive touch over RA8875* FPGA subsystem: EP4CE15E22C8N, 32MB DDR SDRAM (32M x8), some kind of host interface, shared pins to LCD, some other exported pins, hopefully no external configuration device neededAnd finally, given the connections (FPGA have access to LCD interface,) can I program the system to shut down RA8875 LCD interface after the FPGA booted, and let it function as a soft GPU?

author: nctnico
author_rank: Super Contributor
timestamp: July 24, 2017, 08:32:27 pm
content: I'd go for a solution which allows to use PCI express. That gets rid of a whole bunch of problems.

author: nctnico
author_rank: Super Contributor
timestamp: July 24, 2017, 08:59:51 pm
content: Quote from: blueskull on July 24, 2017, 08:39:51 pmThat depends on whether you factor in engineering costs. Too many people start with cheap parts and then spend months to get these to do what they want while a different solution can be brought up in days and likely doesn't run into bandwidth limits as a bonus.

author: nctnico
author_rank: Super Contributor
timestamp: July 24, 2017, 09:36:24 pm
content: PCIe is a (standard) free core for Xilinx devices. But again: it all depends on engineering costs. Sure you can make cheap parts do what you want as well but is it (financially) worth the extra effort? The Zync solution may not be a bad one either.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: July 24, 2017, 09:52:23 pm
content: Quote from: technix on July 24, 2017, 08:17:44 pmYes. There isn't really such a thing as "Reset" on an FPGA.QuotePossibly but probably may or may not be a very sensible way to do it. JTAG would be the most flexible way to do it, but FPGAs usually have slave serial modes- you'll need to check the data to see to what extent & which config pins can be used as normal I/Os after configuration - this will vary between manufacturers and probably between families.QuoteTotally unanswerable question without more info - depends entirely on your application's needs - speed, latency, pin count etc.The beauty of an FPGA is you can implement whatever interface(s) you want.SPI (including enhancements like QSPI, DDR QSPI,SDIO etc,.) is very easy to implement and can offer tens of MBytes/sec transfers over a few wires.QuoteRead the AT91 documentation. DMA just gives faster access to the peripheral, so is a secondary considerationQuoteAgain it depends entirely what you want to do.

author: legacy
author_rank: Super Contributor
timestamp: July 24, 2017, 10:16:00 pm
content: - "I have no idea about what I am doing"- "but I want to couple a complex fpga chip to a super complex SoC"- because scienceLOL

author: technix
author_rank: Super Contributor
timestamp: July 25, 2017, 06:16:29 am
content: Quote from: nctnico on July 24, 2017, 09:36:24 pmBoth chips I mentioned above are not BGA.If I want to use PCIe I would go straight for iMX6Q + Cyclone V, or go with straight AXI with Cyclone V SoC, all in BGA packages. Here I am restricting myself to QFP only, hence the older ARM9 and Cyclone IV, as well as no PCIe.

author: technix
author_rank: Super Contributor
timestamp: July 25, 2017, 06:22:32 am
content: Quote from: evb149 on July 24, 2017, 10:17:17 pmIn my system there is no spare SDIO available - the microSD card slot and the SDIO Wi-Fi adapter have occupied them. I would prefer hooking the FPGA to the main CPU using parallel EBI, especially if the same EBI can be used to both load the FPGA with configuration, as well as communicate between the SoC and FPGA.

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: July 25, 2017, 07:34:16 am
content: Quote from: technix on July 25, 2017, 06:22:32 amYou could pass the SDIO through the FPGA and have a select line to multiplex an internal interface with the external port, so you could do comms when not accessing the SDIO peripheral.If the EBI can be muxed with general purpose IO, you could probably combine config and data interfacing, by configuring as GPIO to config the FPGA via SPI (hardware or bit-bashed), then switch to bus mode once the FPGA is configured/But if you have enough GPIOs (or a spare SPI port) to dedicate to FPGA config that will probably make your life easier.It certainly used to be that FPGAs could be configged via a parallel MCU bus type interface - I don't know if this is still the case for more recent parts. If so, I would assume that most of the pins become general purpose after configuration and could be used as a bus interface. Read the configuration guide for your FPGA.

author: dgtl
author_rank: Regular Contributor
timestamp: July 25, 2017, 08:33:08 am
content: For the Cyclone 4 line, check out the configuration guide:https://www.altera.com/en_US/pdfs/literature/hb/cyclone-iv/cyiv-51008.pdfThe FPGA can be configured (booted) in multiple different ways, either it is active part (loads the configuration itself) or passive (waits for data). In your case, you want the passive mode, either passive serial or passive parallel. For example, connect the passive serial mode to the SPI bus.For communications, you can use whatever interface you want and implement the same in FPGA. For example, connect the FPGA to the parallel memory bus and give it a chip select. Then it is visible in the memory space to the CPU.Beware of the issues in the older SAM9 parts. The DMA for SDIO and SPI can underrun and the software can't do anything about it. Starting from 9263, the SDIO implemented a configuration bit, that stalls the SDIO clock when no data is available. I've had too many headaches with SAM9261.

author: technix
author_rank: Super Contributor
timestamp: July 25, 2017, 08:37:14 am
content: Quote from: mikeselectricstuff on July 25, 2017, 07:34:16 amThe EBI is not MUX'd with GPIO, instead it is shared by SDRAM, LCD interface and NAND through CS lines on EBI. The SPI signals are shared too with the touch screen controller and I can only find one extra CS line at most.The FPGA supports passive parallel configuration mode though - can that be used in conjunction with EBI to load the configuration data? The parallel configuration pins are also used to make the FPGA talk to the SoC during normal operation on EBI using a SRAM-like interface. If the parallel loading would work I can just load the configuration file in the SoC straight into the FPGA using the parallel configuration pins, and the kernel would simply DMA the entire thing from NAND right into FPGA.

author: tszaboo
author_rank: Super Contributor
timestamp: July 25, 2017, 08:37:53 am
content: I've worked with boards, where the FPGA and the MCU was connected with the memory interface on the MCU. There was a memory slave controller in the FPGA, so the communication with it was basically reading/writing to the memory space. It was probably the most fluent way of solving this, because the FPGA acted very similarly to a peripheral of the MCU.

author: legacy
author_rank: Super Contributor
timestamp: July 25, 2017, 08:52:25 am
content: Quote from: nctnico on July 24, 2017, 08:32:27 pmWell not so sure if it really gets ride a whole bunch of problems, especially on the HDL side. Also the linux side is not a piece of cake when you have to deal with bad beast like PCI and ePCI.Indeed, in our business stuff, every ePCI-project involves three guys- a PCB expert guy- a linux expert guy- a fpga expert guy

author: mikeselectricstuff
author_rank: Super Contributor
timestamp: July 25, 2017, 08:54:20 am
content: Quote from: legacy on July 25, 2017, 08:52:25 amAnd what sort of expensive-ass scope are you going to need to debug PCIe ?

author: technix
author_rank: Super Contributor
timestamp: July 25, 2017, 08:56:51 am
content: Quote from: dgtl on July 25, 2017, 08:33:08 amI would prefer the FPP mode since the pins can be shared for normal EBI operation. I wonder if the problem is fixed in recent QFP SAM9260, and whether the Linux kernel contained a workaround or not.

author: technix
author_rank: Super Contributor
timestamp: July 25, 2017, 09:02:37 am
content: Quote from: mikeselectricstuff on July 25, 2017, 08:54:20 amI am definitely not touching any FPGA DIY PCIe stuff - just sending traces from a module to a M.2 slot is already scaring me. (The M.2 slot implementation itself is also scary, with the PCIe lane, USB Hub and USB to SATA adapter involved. The upstream chip is MT7688 which provides only one USB host port and the PCIe lane. I do intend to allow the M.2 slot accept PCIe WI-Fi card, NVMe SSD or SATA SSD.)

author: legacy
author_rank: Super Contributor
timestamp: July 25, 2017, 09:07:54 am
content: Quote from: technix on July 25, 2017, 09:02:37 amJust a few weeks ago you wrote you were in troubles with a simple CPLD, now you have magically increased your skills so much that you are able to handle a GPU. LOL!

author: technix
author_rank: Super Contributor
timestamp: July 25, 2017, 09:11:58 am
content: Quote from: legacy on July 25, 2017, 09:07:54 amI am learning, okay?The trouble in both projects lies in the hooking up chips phase - once I make my way past that the HDL and software part can be much easier for me. Also this board serves as a experimenting kit for me with FPGA tightly interacting with the SoC.

author: CM800
author_rank: Frequent Contributor
timestamp: July 25, 2017, 09:45:55 am
content: I'd suggest buying yourself an FPGA or CPLD kit, then buy a microcontroller board (e.g. Arduino Due, STM32F7... something like that)Then just use headers to pass comms through, I doubt you will be playing with anything high speed enough to be an issue over header cables.Try single or even quad SPI, you should learn a lot playing with that alone.

author: dgtl
author_rank: Regular Contributor
timestamp: July 25, 2017, 09:49:32 am
content: Quote from: technix on July 25, 2017, 08:56:51 amAfaik, not. Atmel seemed to fix things in newer chips and not re-spin old stuff. They did not do any workarounds in kernel drivers either (last checked ~5 years ago). Once I asked them at Embedded World, they said that 926x is too old and they focus their developments on supporting new stuff and not working around old hw bugs and too bad that I had things that did not work, I should respin the boards with newer ICs. As I had to get the problems patched with a lot of devices already sold, I had to do some crazy workarounds. The SDIO controller had some other issues as well, sometimes it got stuck and sometimes it did not handle the busy signal from SD card properly. I had to mux the SDIO pins to SPI and do all the SD card communication over SPI to finally get it stable enough to avoid data corruptions on SD cards. Then I did DMA SPI through SRAM to avoid underruns due to high SDRAM usage.For the SPI, the linux driver used any gpio as cs via gpio framework (not the controllers cs output).As the SPI driver in linux is already DMA-accelerated, it is much simpler to write peripheral driver that uses SPI. Otherwise, you would have to mess with memory-to-memory dma yourself. If the bandwidth is sufficient, start with SPI. In future projects you can move on to either parallel bus or PCIe or whatever is faster.Trying things out with eval kits and jumper wires is a good advice. Later as everything is worked out, you can spin your own board. There are plenty of FPGA boards, find one with similar FPGA (it may be larger, you can downscale to smaller FPGA quite easily). Then get yourself a SAM9260 EVK and wire up the two.

author: AndyC_772
author_rank: Super Contributor
timestamp: July 25, 2017, 09:57:00 am
content: Downloading a Cyclone IV is really, really easy. Just:- compile your design in Quartus, and enable generation of a raw binary (.rbf) file- embed the .rbf in your source code- pulse NCONFIG and check NSTATUS, as per the instructions in the Configuration Handbook- download the binary using DCLK and D0. An SPI interface using DMA is the fastest way, but you can bit-bang too if you don't mind configuration taking a few hundred milliseconds- pulse DCLK a couple more times and you're done.Passing data between CPU and FPGA might be a bit more difficult; it really depends how much bandwidth you need, and what built-in peripherals your CPU has which can be pressed into service. Few processors have anything designed specifically as an "FPGA interface", but there's usually something you can hijack.The simplest is probably SPI, which is fine for a few 10's of MHz, depending on the capability of the CPU.For more bandwidth, you may need to program your FPGA to have an interface which emulates an Ethernet PHY (use MII or RMII as your link), or a QSPI Flash memory device, or perhaps a camera. Some processors have an external memory interface, which may be suitable.PCI-e... not unless there's absolutely no alternative.

author: nctnico
author_rank: Super Contributor
timestamp: July 25, 2017, 11:51:00 am
content: Quote from: technix on July 25, 2017, 06:16:29 amAha, you didn't mention that before. Does the MPU you have selected a synchronous parallel memory bus? That would be an easy way to connect it to the FPGA. The biggest problem with connecting parallel memory busses to an FPGA is that you have no real clock available for the memory I/O and you need to re-sample the signals into the FPGA's clock domain. I'm not saying it can't done but it is a nuisance to get right.

author: legacy
author_rank: Super Contributor
timestamp: July 25, 2017, 02:40:49 pm
content: Quote from: technix on July 25, 2017, 09:11:58 amDude the problem with you is

author: legacy
author_rank: Super Contributor
timestamp: July 25, 2017, 02:43:09 pm
content: e.g.what the fsck is the final application?what the fsck are constrains and requirements?what the fsck is written in the customer working table? (which means budget and deadline)You are blathering a lot of bullshit as usual to waste people time.

author: technix
author_rank: Super Contributor
timestamp: July 25, 2017, 04:01:55 pm
content: Quote from: legacy on July 25, 2017, 02:43:09 pmThere is no final application other than playing with things. I have a budget cap and an ability cap but no real constrain otherwise. And there is no customer in question.I am still trying to learn stuff, and there is absolutely no fscking business involved. If you feel that this forum is for the business talk, if you don't appreciate exploring and experimenting and the general idea of playing with items, you should really keep clear of most of my threads. Yes I may lack a clear idea what items I am talking about is or how it works, but the big idea is to find out those questions through experimenting. I don't have the experience you have accumulated in your years - heck I don't even have a true EE background.Admins, if you mostly agree with the idea that this forum is for business and business only, ban me.

author: technix
author_rank: Super Contributor
timestamp: July 25, 2017, 04:11:41 pm
content: Quote from: nctnico on July 25, 2017, 11:51:00 amThere is a parallel memory bus but I don't think it is synchronous. However the FPGA can request wait states so I can insert an asynchronous buffer in the bus interface (holding the processor in wait until the main logic can respond.)

author: technix
author_rank: Super Contributor
timestamp: July 25, 2017, 04:22:41 pm
content: Quote from: dgtl on July 25, 2017, 09:49:32 amSo how useable is the SDIO controller? Can I run Wi-Fi off it?As of the SDRAM, I wonder if additional memory bandwidth can help, since I have 32-bit memory bus it should be able to move data across faster. Also since I don't have any AT91SAM9260 eval kit (the existing ones won't really help either, with either no EBI access, 16-bit memory, or too high a price tag) so I have to cook it up with my own board anyway.

author: NorthGuy
author_rank: Super Contributor
timestamp: July 25, 2017, 04:59:44 pm
content: Quote from: technix on July 25, 2017, 04:01:55 pmI think what your opponent is trying to say is that it is impossible to design without goals. Engineering is about creating things. If you don't know what you want to create, how can you create it? And if you don't create anything, how can you possibly learn something? Engineering without a goal is about as stupid as shooting without a target.There are lots of people who buy Arduinos (or whatever), daughter boards, put them all together, observe motors runnings, LEDs blinking (or whatever). They may have fun doing this, but they don't really learn anything. There's no goal in what they're doing and everything is good with their designs as soon as they have fun. You're trying to assume the same attitude at the higher level. But the level doesn't matter much. If having fun is your goal then anything goes, and anything is reasonable. How can anyone possibly tell you if your design is reasonable (or not reasonable) for having fun with?If you really want to learn something, first learn how to set goals. This is where engineering starts.