Home

Awesome

AutoFPGA - An FPGA Design Automation routine

After now having built several FPGA designs, such as the xulalx25soc, s6soc, openarty, zbasic, icozip, and even a Basys-3 design of my own that hasn't been published, I started recognizing that all of these designs have a lot in common. In particular, they all have a set of bus masters, such as the UART-to-wishbone bridge that I use, the hexbus debugging bus that offers a simpler version of the same, or even the zipcpu. Many of these designs have also started to use (and reuse) many of the peripherals I've developed, such as the generic UART, the QSPI flash controller, the SD-card controller, the block RAM controller, the RMII Ethernet Controller, the Real-Time Clock, the Real-Time Date, the Organic LED controller, Xilinx's Internal Configuration Access Port, the wishbone scope, the GPS controlled clock, or even the PWM Audio Controller. All of these peripherals have a very similar format when included within a top level design, all of these require a certain amount of care and feeding as part of that top level design, but yet rebuilding that top level design over and over just to repeat this information becomes a pain.

Where things were really starting to get annoying is where the C++ information was depending upon Verilog information. A classic example of this is the base address of any bus components. However, if you add clock rate into the mix, you can then also control things such as any default UART configuration, default clock stepping information (for the RTC clock), or even default video clock information--just by knowing the FPGA's clock rate within your C++ environment.

Sharing information between Verilog and C++ then became one of the primary reasons for creating AutoFPGA. While peripheral address decoding is typically done in some main Verilog file, other files depend upon what this peripheral decoding is. These other files include the host register definition file (used for debugging access), the register naming file, the software board definition file used by newlib, the linker script used by the compiler, and even the LaTeX specification for the board. Creating and updating all of these files by hand anytime I create a new board file can get tedious. Further, every time a board is reconfigured, the constraints file, whether XDC or UCF file, needs to be updated to match the current constraints.

Solving this multi-language coordination problem is the purpose of AutoFPGA.

Unlike many of the other tools out there, such as Xilinx's board design flow, AutoFPGA is not built with the clueless beginner in mind, neither is it built to hide the details of what is going within the project it creates. Instead, AutoFPGA is built with the sole purpose of alleviating any burden on the FPGA designer who otherwise has to create and maintain coherency between multiple design files.

That this program facilitates composing and building new designs from existing components ... is just a bonus.

Goal

The goal of AutoFPGA is to be able to take a series of bus component configuration files and to compose a design consisting of the various bus components, linked together in logic, having an appropriate bus interconnect and more.

From a user's point of view, one would run AutoFPGA with a list of component definition files, given on the command line, and to thus be able to generate (or update?) the various design files discussed above:

Specifically, the parser must determine:

Classes

Some peripherals might exist at multiple locations within a design. For example, the WBUART serial component can be used to create multiple serial ports within a design.

To handle this case, the WBUART configuration file may be subclassed within other component configuration files by defining a key @INCLUDEFILE=wbuart.txt. This will provide a set of keys that the current file can then override (inherit from).

Unfortunately, this only works if the included file has only one component defined within it.

Math

Some peripherals need to be able to perform basic integer math on a given value to determine an appropriate setting value. These peripherals need access to variables. The classic examples are the baud rate, which depends upon the clock rate, as well as the step size necessary for the RTC and the GPS clocks, both of which also depend upon the master clock rate. Other examples might include determining the size of the address space to assign to a core based upon the memory size of the component and so forth.

This feature is currently fully supported using integer math.

Legacy Updates

The original version of AutoFPGA supported only one bus master, one bus type, and an interconnect with a known bug in it.

Specifically, the broken interconnect would allow a master to make requests of one peripheral and then another before the first peripheral had responded, while not preventing the requests from returning out of order.

Fixing this bug introduced several incompatible changes, therefore there is an AutoFPGA legacy git tag defined to get back to the older version.

This newer version, however, now supports:

Much to my surprise, the full crossbar support has proved to be simpler, in terms of logic elements used, than the legacy interconnect I had been using.

Status

This project now has several designs built around it. These include the basic AutoFPGA-demo project, OpenArty, ArrowZip (legacy AutoFPGA only), AXI DMA test bench, ICOZip, SDR (a gateware defined radio), ZBasic, ZipStorm-mx (legacy AutoFGPA only), and ZipVersa. There's also a rather nice Nexys Video project that I've used for modifying and delivering to customers, although the current version on github is currently a touch out of date. You can see the autogenerated logic generated for this project in the demo directory.

I've also used AutoFPGA to generate a design for the Cyclone-V on the DE-10 Nano, as well as a design for an Arty Z7-20.

In sum:

Sample component files

Component files now exist for many of the components I've been using regularly. These include: a Flash controller, block RAM, a UART console, a very simple GPIO controller, RMII ethernet controller, MDIO ethernet control interface, a GPS UART and PPS-driven internal clock, a Real-Time (GPS driven) Clock, a PS/2 Mouse, an OLED component, and more. Many of these component cores exist and have their own repositories elsewhere. For example, the wishbone UART core may be found here, and you can find a MIG-based, Wishbone controlled SDRAM component here. You can also find a AXI examples, such as AXI S2MM stream-to-memory data mover, an AXI MM2S memory-to-stream data mover, or an AXM block RAM component in the AXI DMA test repository. Building the cores themselves is not a part of this project, but rather figuring out how to compose multiple cores into a top level design from both cores and component descriptions.

The ZipCPU blog

Several articles have now been written to date about AutoFPGA on the ZipCPU blog. These includes:

  1. A brief introduction to AutoFPGA

  2. Using AutoFPGA to connect simple registers to a debugging bus

    This article is really out of date, in that it describes only the legacy mode (one master, one bus type, etc.)

  3. AutoFPGA's linker script support gets an update

  4. Technology debt and AutoFPGA, the bill just came due

  5. Understanding AutoFPGA's address assignment algorithm

Getting Started

The current best reference for AutoFPGA is the icd.txt file, which describes all of the various tags AutoFPGA understands and how they can be used. I've also started working on an intermediate design tutorial based around AutoFPGA, so you might find that a useful place to start as well.

License

AutoFPGA is designed for release under the GPLv3 license. The AutoFPGA generated code is yours, and free to be relicensed as you see fit.

Commercial Applications

Should you find the GPLv3 license insufficient for your needs, other licenses can be purchased from Gisselquist Technology, LLC. Given that the AutoFPGA generated code is not encumbered by any license requirements, I really don't expect any such requests.

Likewise, please contact us should you wish to guide, direct, or otherwise fund the development of this project. You can contact me at my user name, dgisselq, at the wonderful ieee.org host.