John Gabriel
Posts: 3
Joined: Fri Jan 17, 2020 1:00 pm

Raspberry and FPGA

Fri Jan 17, 2020 1:13 pm

Hello everyone!

I am new to forum. I have been assigned task to check whether the Raspberry PI can be used to program an FPGA, I have tried searching on the internet but could not find satisfactory answers. I have looked into the datasheet into the FPGAs and almost every FPGA supports the standard peripherals. My friend asked me to try the forum. So my question is can we program FPGA using the SPI or UART or I2C of the raspberry PI.

Heater
Posts: 17421
Joined: Tue Jul 17, 2012 3:02 pm

Re: Raspberry and FPGA

Fri Jan 17, 2020 2:13 pm

Typically people us FPGA from the tow major vendors Alter (now Intel) and Xilinx. Both of these vendors supply applications to allow one to write HDL for their FPGA in Verilog and VHDL. They compile your code to the required logic connectivity of your FPGA. The allow to download that configuration to the FPGA.

Neither of these will work on the Pi. Alter and Xilinx supply their tools for Windows and Linux but not for the ARM processor of the Pi.

But the good news is you can program FPGA from Lattice Inc using free and open source tool that compile Verilog and download to FPGA.
See Yosys: http://www.clifford.at/yosys/

There is a nice description if install the Yosys tools here: http://chiphack.org/chiphack-2017-install-linux.html
Memory in C++ is a leaky abstraction .

drgeoff
Posts: 11541
Joined: Wed Jan 25, 2012 6:39 pm

Re: Raspberry and FPGA

Fri Jan 17, 2020 2:21 pm

There are two aspects - hardware and software.

There is a very good possibility that a RPI can provide the required programming waveforms but some additional interfacing circuitry such as buffers/level-shifters may be needed.

FPGAs are usually programmed using software provided by the FPGA maker. Typically they only provide software which runs on Windows or x86/x64 Linux.

The fact you and colleague need to ask the question makes me think that you will be out of your depth trying to use a RPi for this but happy to be proven wrong.
Quis custodiet ipsos custodes?

Heater
Posts: 17421
Joined: Tue Jul 17, 2012 3:02 pm

Re: Raspberry and FPGA

Fri Jan 17, 2020 2:45 pm

If you have a Lattice iCEstick FPGA evaluation board it plugs straight into a USB port.
http://www.latticesemi.com/icestick

You can program it using open source tools from the IceStorm project:
http://www.clifford.at/icestorm/

Like so:

Code: Select all

# Verilog synthesis
yosys -p "synth_ice40 -blif rot.blif" rot.v

# place & route
arachne-pnr -d 1k -p rot.pcf rot.blif -o rot.asc

# Create bit stream file for progrmming
icepack rot.asc rot.bin

# Progrsm the FPGA.
iceprog rot.bin
Other boards can be used. For example the iCE40HX8K Breakout Board: https://www.latticestore.com/default.as ... hx8k-b-evn and there are some other designs people have made.

There is also the new open source Symbiflow project https://symbiflow.readthedocs.io/en/lat ... ction.html that allows programming of Xilinx 7-Series, Lattice iCE40 and Lattice ECP5 FPGAs
Memory in C++ is a leaky abstraction .

crossbar
Posts: 61
Joined: Mon May 19, 2014 9:45 am

Re: Raspberry and FPGA

Fri Jan 17, 2020 4:32 pm

As a side note and maybe a bit offtopic (especially if we take into account the interests and experiences of the thread starter):

In addition to using the Pi4-4 for FPGA development, it can also be used for mask design / custom chips. Sounds crazy? Yes .. it sounds crazy ... but it can be done. With a little help from DARPA.

If you're interested, check out these open source development tools (sponsored by DARPA with Millions of Dollars):

https://github.com/The-OpenROAD-Project .

It is currently in a very early alpha stage, based on CentOS and a "fast moving target", but it is open source so you can make your own contribution.

BTW. No1: yosys-abc is used as a front-end tool. This post therefore deals with the topic of this thread about FPGA to a small extent

BTW. No2: Andreas Olofsson referred me to TheOpenRoadProject. He was previously a designer at Analog Devices, and may be known to the general public as the father of the Epiphany multicore. He is currently a project manager at DARPA.

BTW. No3: Pi4-4 is the Minimum.

mic_s
.

chipace
Posts: 164
Joined: Sat Jun 29, 2019 2:56 am
Location: brown paper bag in a septic tank

Re: Raspberry and FPGA

Fri Jan 17, 2020 11:33 pm

My FPGA board (CMOD A7) has a on-board USB to JTAG. Theoretically you can just send the same USB payload as you would do in Windows with the RPi. I believe this app note can help for Xilinx products.
https://www.xilinx.com/support/document ... app058.pdf

https://store.digilentinc.com/cmod-a7-b ... ga-module/

crossbar
Posts: 61
Joined: Mon May 19, 2014 9:45 am

Re: Raspberry and FPGA

Sat Jan 18, 2020 2:14 pm

Back from VLSI design with Pi4 to the beautiful FPGA world.

Yes ... most FPGA boards are programmable via something like USB ...
If not, you can use a commercially available JTAG probe (about $20) or make your own JTAG probe (about $5).

But the question is: Is it possible to do development for fpgas with your pi? Yes, that's what this thread points out.

btw: This is not only possible for the FPGAs mentioned, but also for less well-known FPGAs (e.g. Trion T120FXXX with 112,000 LUTs, the development system is based on VPR, an open source project (MIT license) from University of Toronto, recompilation for ARM required).

Have a nice time with our FPGAs.

mic_s
.

Heater
Posts: 17421
Joined: Tue Jul 17, 2012 3:02 pm

Re: Raspberry and FPGA

Sat Jan 18, 2020 2:31 pm

Wow, I have been looking around FPGA for a while now. Never heard of Trion FPGA or even Efinix Inc.
https://www.efinixinc.com/products-trion.html
Memory in C++ is a leaky abstraction .

chipace
Posts: 164
Joined: Sat Jun 29, 2019 2:56 am
Location: brown paper bag in a septic tank

Re: Raspberry and FPGA

Sat Jan 18, 2020 4:31 pm

I would think that just programming the Flash rom (which the FPGA loads from) would be the only requirement to "program the FPGA". To address the parents original question, yes a SPI or I2C interface on the RPi could program a FPGA's Flash rom memory.
For my board that would not be possible as the USB -> JTAG is the only external method to reach my Flash rom pins.

The next question is why you would only want to use a RPi to program your FPGA? Vivado has a full feature systemverilog simulator and waveform viewer in the free version. That runs on linux x86 and it programs my board with no issues. I need the x86 computing power with my FPGA designs, a single turn takes 25 minutes... that could be hours on a RPi.

If I needed to program the FPGA with the RPi, I think that would be very possible... but developing on the RPi when there are awesome free tools on x86 linux, I think only a religious person (church of raspberry pi) would do that.

cleverca22
Posts: 2888
Joined: Sat Aug 18, 2012 2:33 pm

Re: Raspberry and FPGA

Sat Jan 18, 2020 5:45 pm

if i was making an fpga based project using the rpi, i would mainly aim for the rpi to be able to re-flash the fpga by itself

so i could package an update for the whole system onto an SD card, and just swap it, and the rpi can deal with updating the fpga on its own

leave the actual compiling and development to a more capable/compatible machine

User avatar
mark3112
Posts: 46
Joined: Mon Apr 09, 2018 10:39 am

Re: Raspberry and FPGA

Sat Jan 18, 2020 5:59 pm

As chipace said, much depends on what you mean by "program the FPGA".
I worked on a project where a STM32 held the configuration information and used this to create the VHDL file that was uploaded to the FPGA’s configuration EEPROM. Normally this would be done via JTAG but the configuration EEPROM is only a SPI device, so diverting the signals isn’t a significant problem.
You can make a real CPU in a FPGA, but you can’t make a real FPGA in a CPU.

Heater
Posts: 17421
Joined: Tue Jul 17, 2012 3:02 pm

Re: Raspberry and FPGA

Sat Jan 18, 2020 6:12 pm

chipace,
I think only a religious person (church of raspberry pi) would do that.
Putting religion and the "church Raspberry Pi" aside for a while there are many good practical reasons for wanting Free and Open Source tools to configure FPGAs:

1) FPGA vendor tools are invariably huge, complex, clunky and slow.

2) An open source solution saves you from becoming dependent on an FPGA vendor.

3) An open source solution saves you from becoming dependent on whatever architecture and platform the vendor supports.

4) This is a bit long....

I was amazed to find that I could hack up some Verilog and check it out Icarus Verilog http://iverilog.icarus.com/ or the Verilator https://www.veripool.org/wiki/verilator with a much shorter edit, check, edit, development cycle than using any vendor tool like Quartus.

Not only that one can turn that Verilog into a working FPGA config much faster using Yosys.

In short, writing Verilog becomes as simple as writing Python!

I believe this kind of simplicity is just what we need to get youngsters motivated to investigate doing their own hardware designs.

So, as much as there is a "Pi religion" which is all about making it cheap and easy for kids to play with software, why not also make it cheap and easy for kids to dabble in hardware?
Memory in C++ is a leaky abstraction .

Heater
Posts: 17421
Joined: Tue Jul 17, 2012 3:02 pm

Re: Raspberry and FPGA

Sat Jan 18, 2020 6:20 pm

mark3112,
...much depends on what you mean by "program the FPGA".
Yes, there is room for confusion here. Are we just wanting to blast an existing binary configuration file to an FPGA? Or are we talking about developing, "programming", and HDL design from scratch in Verilog or VHDL or whatever?
I worked on a project where a STM32 held the configuration information and used this to create the VHDL file that was uploaded to the FPGA’s configuration EEPROM.
No, you did not.

FPGA chips don't know anything about VHDL.

Likely you were loading a binary configuration file to the FPGA from the STM32. That binary file will have been synthesized from VHDL or Verilog using vendor tools on a PC first.
Memory in C++ is a leaky abstraction .

crossbar
Posts: 61
Joined: Mon May 19, 2014 9:45 am

Re: Raspberry and FPGA

Sat Jan 18, 2020 7:07 pm

chipace wrote:I would think that just programming the Flash rom (which the FPGA loads from) would be the only requirement to "program the FPGA".
As long as you are only interessed to transfer (elsewere generated) bitstreams to your FPGA / FPGAboard … even a 5$ pi zero is more than enough. So this question is answered.
chipace wrote:The next question is why you would only want to use a RPi to program your FPGA?
„only“ ?? It's an option. It may be an interesting option. And it is a challange, an ingeneering challange. I like challanges. That's all. Besides this, this forum is … surprise, suprise … about raspberry pi. Question like „Can I do it with my pi?“ or „How can I do it with my pi?“ are valid questions and should be answered.

Don't take me wrong. No problem with vivado / quartus / diamond/radon / … you name it ...
As a sidenote: Most of this closed tools started as (or are based on) open CLI tools.

There is a very, very good reason DARPA is sponsering open source tools on VLSI-design with Millions of Dollars. I mentioned „TheOpenROAD“ project, One part of this project is the OpenSTA (Open Static Timing Analyzer). OpenSTA was the base for a lot of commercial fpga tools and vlsi tools.

Anyway, have fun with your FPGA. With OPEN and CLOSED tools. I'm using both of them.

mic_s
.

John Gabriel
Posts: 3
Joined: Fri Jan 17, 2020 1:00 pm

Re: Raspberry and FPGA

Sun Jan 19, 2020 10:15 am

Hello Everyone!

thank you for such great response.

Actually I have an SOM ADRV 9361-Z7035 and due to unknown reason my BOSS wants me to design hardware based on Raspberry PI to program / configure the FPGA.

Heater
Posts: 17421
Joined: Tue Jul 17, 2012 3:02 pm

Re: Raspberry and FPGA

Sun Jan 19, 2020 11:07 am

Wow, what is your boss wanting to build with that? I has Analog Devices AD9361-BBCZ Integrated RF Agile Transceiver and a Xilinx Zynq XC7Z035-2L FBG676I AP SoC on board.

I get the feeling that one should be able to program that by direction connection to the Raspberry Pi GPIO pins and some bit banging software.
Memory in C++ is a leaky abstraction .

chipace
Posts: 164
Joined: Sat Jun 29, 2019 2:56 am
Location: brown paper bag in a septic tank

Re: Raspberry and FPGA

Mon Jan 20, 2020 6:04 am

I looked at rev E and rev F of the board schematics, and the QSPI Flash only connects to the Zynq. I believe boundary scan is your only option. It looks like JTAG is available on one of the pin headers.
As Zynq is Xilinix, the app note I listed earlier should help. If I had to program the Flash with a RPi I would bit bang the JTAG signals.
If I were in your shoes, I would punt on the RPi programming requirement and wow your boss with a cool FPGA design.
My $0.02

crossbar
Posts: 61
Joined: Mon May 19, 2014 9:45 am

Re: Raspberry and FPGA

Mon Jan 20, 2020 2:25 pm

Not in connection with SOM ADRV 9361-Z7035, but for "programming" FPGAs :

https://github.com/trabucayre/openFPGALoader

(basically it is the basis of a general and open FPGA programmer / loader)

mic_s
.

mithro
Posts: 1
Joined: Tue Jan 05, 2021 5:45 pm

Re: Raspberry and FPGA

Tue Jan 05, 2021 5:55 pm

A lot of the Fomu.im bootloader (https://github.com/im-tomu/foboot) was done with an Raspberry Pi. The Fomu is an FPGA development board based around iCE40UP5K FPGA which fits *inside* your USB port. See https://www.crowdsupply.com/sutajio-kos ... es-to-camp for more details.

The "EVT (Electrical Verification Test)" design for the Fomu was done as an RPi Hat, you can find some information at https://www.crowdsupply.com/sutajio-kos ... d-shipping , https://www.crowdsupply.com/sutajio-kos ... -locked-in and https://www.crowdsupply.com/sutajio-kos ... -and-delay

The SPI RPi peripheral was used as a debug and programming with a tool to allow single stepping the RISC-V soft process and controlling peripherals directly.

The Raspberry Pi was also used for manufacturing testing - see https://github.com/im-tomu/fomu-flash

Return to “General discussion”