2022-02-13 15:35:16 -05:00
|
|
|
.. _Building-Custom-Designs:
|
|
|
|
|
2022-08-03 23:35:52 -04:00
|
|
|
Building custom designs
|
2022-02-13 15:35:16 -05:00
|
|
|
=======================
|
2021-06-07 19:43:08 -04:00
|
|
|
|
2022-02-13 15:35:16 -05:00
|
|
|
This section describes how to compile and download your own designs to an FPGA using only
|
2022-02-18 12:15:44 -05:00
|
|
|
the F4PGA toolchain.
|
2021-06-07 19:43:08 -04:00
|
|
|
|
2022-02-13 15:35:16 -05:00
|
|
|
Before building any examples, you will need to first install the toolchain. To do this, follow the steps in :ref:`Getting`.
|
|
|
|
After you have downloaded the toolchain, follow the steps in :ref:`Building-Examples` by seting the installation
|
|
|
|
directory to match what you set it to earlier, assigning the path and source for your conda environment, and activating
|
|
|
|
your env.
|
2021-06-07 19:43:08 -04:00
|
|
|
|
2022-02-13 15:35:16 -05:00
|
|
|
Preparing Your Design
|
|
|
|
---------------------
|
2021-07-05 16:54:44 -04:00
|
|
|
|
2022-02-18 12:15:44 -05:00
|
|
|
Building a design in F4PGA requires three parts: the HDL files for your design, a constraints
|
2021-06-30 11:06:12 -04:00
|
|
|
file, and a Makefile. For simplicity, all three of these design files should be moved to a single
|
2022-02-13 15:35:16 -05:00
|
|
|
directory. The location of the directory does not mater as long as the three design elements are all
|
2021-06-30 11:06:12 -04:00
|
|
|
within it.
|
2021-06-08 14:12:42 -04:00
|
|
|
|
2021-06-19 20:20:14 -04:00
|
|
|
HDL Files
|
2022-02-13 15:35:16 -05:00
|
|
|
+++++++++
|
2021-07-05 16:54:44 -04:00
|
|
|
|
2022-02-13 15:35:16 -05:00
|
|
|
F4PGA provides full support for Verilog. Some support for SystemVerilog HDL code is also
|
|
|
|
provided, although more complicated designs written in SystemVerilog may not build properly under
|
|
|
|
Yosys. Use whichever method you prefer, and add your design files to the directory of choice.
|
|
|
|
If you are using the provided Makefiles to build your design, the top level module in your HDL
|
|
|
|
code should be declared as ``module top (...``. Failure to do so will result in an error from
|
|
|
|
symbiflow_synth stating something similar to ``ERROR: Module 'top' not found!`` If you are using
|
|
|
|
your own makefiles or commands, you can specify your top level module name using the -t flag in
|
|
|
|
``symbiflow_synth``.
|
2021-06-08 22:49:58 -04:00
|
|
|
|
2021-06-19 20:20:14 -04:00
|
|
|
Constraint File
|
2022-02-13 15:35:16 -05:00
|
|
|
+++++++++++++++
|
2021-07-05 16:54:44 -04:00
|
|
|
|
2022-02-13 15:35:16 -05:00
|
|
|
The F4PGA toolchain supports both .XDC and .PCF+.SDC formats for constraints.
|
|
|
|
You can use XDC to define IOPAD, IOSETTINGS, and clock constraints. SDCs can be used to
|
|
|
|
define clock constraints and PCFs can be used to define IOPAD constraints only. Use whichever
|
2021-06-30 11:06:12 -04:00
|
|
|
method you prefer and add your constraint file(s) to your design directory.
|
2021-06-08 14:12:42 -04:00
|
|
|
|
2022-02-13 15:35:16 -05:00
|
|
|
Note that if you use an XDC file as your constraint and neglect to include your own SDC, the
|
2021-07-02 17:50:12 -04:00
|
|
|
toolchain will automatically generate one to provide clock constraints to VTR.
|
2021-06-08 14:12:42 -04:00
|
|
|
|
2021-07-05 16:54:44 -04:00
|
|
|
|
2021-06-08 14:12:42 -04:00
|
|
|
Makefile
|
2022-02-13 15:35:16 -05:00
|
|
|
++++++++
|
2021-07-05 16:54:44 -04:00
|
|
|
|
2022-02-13 15:35:16 -05:00
|
|
|
Visit the `Customizing Makefiles <customizing-makefiles.html>`_ page to learn how to make a simple
|
2021-08-20 14:15:44 -04:00
|
|
|
Makefile for your designs. After following the directions listed there return to this page to
|
|
|
|
finish building your custom design.
|
2021-06-07 19:43:08 -04:00
|
|
|
|
2022-02-13 15:35:16 -05:00
|
|
|
Building your personal projects
|
2021-06-07 19:43:08 -04:00
|
|
|
-------------------------------
|
2021-06-19 20:20:14 -04:00
|
|
|
|
2022-02-13 15:35:16 -05:00
|
|
|
Before you begin building your design, navigate to the directory where you have stored your
|
2021-07-02 17:50:12 -04:00
|
|
|
Makefile, HDL, and constraint files:
|
2021-06-07 19:43:08 -04:00
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
:name: your-directory
|
|
|
|
|
|
|
|
cd <path to your directory>
|
|
|
|
|
2022-02-13 15:35:16 -05:00
|
|
|
Then, depending on your board type run:
|
2021-06-07 19:43:08 -04:00
|
|
|
|
2021-06-08 14:12:42 -04:00
|
|
|
.. tabs::
|
|
|
|
|
|
|
|
.. group-tab:: Arty_35T
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
:name: example-counter-a35t-group
|
|
|
|
|
|
|
|
TARGET="arty_35" make -C .
|
|
|
|
|
|
|
|
.. group-tab:: Arty_100T
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
:name: example-counter-a100t-group
|
|
|
|
|
2021-06-08 22:49:58 -04:00
|
|
|
TARGET="arty_100" make -C .
|
2021-06-08 14:12:42 -04:00
|
|
|
|
|
|
|
.. group-tab:: Nexus4
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
:name: example-counter-nexys4ddr-group
|
|
|
|
|
|
|
|
TARGET="nexys4ddr" make -C .
|
|
|
|
|
|
|
|
.. group-tab:: Basys3
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
:name: example-counter-basys3-group
|
|
|
|
|
|
|
|
TARGET="basys3" make -C .
|
2022-02-13 15:35:16 -05:00
|
|
|
|
2021-08-20 14:15:44 -04:00
|
|
|
.. group-tab:: Nexys Video
|
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
:name: example-counter-nexys_video-group
|
|
|
|
|
|
|
|
TARGET="nexys_video" make -C counter_test
|
|
|
|
|
|
|
|
.. group-tab:: Zybo Z7
|
2022-02-13 15:35:16 -05:00
|
|
|
|
2021-08-20 14:15:44 -04:00
|
|
|
.. code-block:: bash
|
|
|
|
:name: example-counter-zybo-group
|
|
|
|
|
|
|
|
TARGET="zybo" make -C counter_test
|
2022-02-13 15:35:16 -05:00
|
|
|
|
2021-06-07 19:43:08 -04:00
|
|
|
|
2021-06-08 22:45:35 -04:00
|
|
|
If your design builds without error, the bitstream can be found in the following location:
|
2021-06-07 19:43:08 -04:00
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
|
|
|
cd build/<board>
|
|
|
|
|
2022-02-13 15:35:16 -05:00
|
|
|
Once you navigate to the directory containing the bitstream, use the following commands on the
|
2021-09-01 20:47:42 -04:00
|
|
|
**Arty and Basys3** to upload the design to your board. Make sure to change ``top.bit`` to the
|
|
|
|
name you used for your top level module:
|
2021-06-07 19:43:08 -04:00
|
|
|
|
|
|
|
.. code-block:: bash
|
|
|
|
|
2022-06-28 08:49:22 -04:00
|
|
|
openFPGALoader -b arty_a7_35t top.bit
|
2021-06-07 19:43:08 -04:00
|
|
|
|
|
|
|
|
|
|
|
.. tip::
|
2022-02-13 15:35:16 -05:00
|
|
|
Many of the commands needed to build a project are run multiple times with little to no
|
|
|
|
variation. You might consider adding a few aliases or even a few bash functions to your
|
|
|
|
.bashrc file to save yourself some typing or repeated copy/paste. For example, instead of
|
2022-06-28 08:49:22 -04:00
|
|
|
using the command used to upload the bitstream to Xilinx 7 series FPGA every time, you
|
|
|
|
could just add the following lines to your .bashrc file:
|
2022-02-13 15:35:16 -05:00
|
|
|
|
2021-06-07 19:43:08 -04:00
|
|
|
.. code-block:: bash
|
|
|
|
:name: bash-functions
|
|
|
|
|
2022-06-28 08:49:22 -04:00
|
|
|
f4pga_bit() {
|
2021-06-08 22:49:58 -04:00
|
|
|
#Creates and downloads the bitstream to Xilinx 7 series FPGA:
|
2022-06-28 08:49:22 -04:00
|
|
|
openFPGALoader -b $OFL_BOARD top.bit
|
2021-06-07 19:43:08 -04:00
|
|
|
}
|
|
|
|
|
2022-02-13 15:35:16 -05:00
|
|
|
Now whenever you need to download a bitstream to the Xilinx-7 series you can simply type
|
2022-06-28 08:49:22 -04:00
|
|
|
e.g. ``OFL_BOARD=basys3 f4pga_bit`` into the terminal and hit enter.
|
2021-06-07 19:43:08 -04:00
|
|
|
|