Skip to main content

Library for interfacing EDA tools such as simulators, linters or synthesis tools, using a common interface

Project description

Documentation Status Join the chat at https://gitter.im/librecores/edalize PyPI downloads CI status

Edalize

What’s this?

Edalize is a Python Library for interacting with EDA tools. It can create project files for supported tools and run them in batch or GUI mode (where supported).

Award-winning Edalize introduction video

All EDA tools such as Icarus, Yosys, ModelSim, Vivado, Verilator, GHDL, Quartus etc get input HDL files (Verilog and VHDL) and some tool-specific files (constraint files, memory initialization files, IP description files etc). Together with the files, perhaps a couple of Verilog `defines, some top-level parameters/generics or some tool-specific options are set. Once the configuration is done, a simulation model, netlist or FPGA image is built, and in the case of simulations, the model is also executed, maybe with some extra run-time parameters.

The thing is, all these tools are doing this in completely different ways and there’s generally no way to import configurations from one simulator to another.

Dread not! Edalize takes care of this for you. By telling Edalize what files you have, together with some info, what parametrization to use at compile- and run-time (e.g. plusargs, defines, generics, parameters), VPI library sources (when applicable) and any other tool-specific options not already mentioned, it will create the necessary project files and offer to build and run it for you.

This will save you from having to deal with the boring stuff of interfacing the EDA tools yourself, while still have pretty much full power to set up the project the way you want.

It allows you to quickly switch tools, at least when it comes to simulators. This is highly useful to shake out tool-specific bugs, or just to let you work with your weapon of choice.

It can also be used to just get a quick template that you can open up in the tool’s GUI if there is such, and continue working from there.

It can be directly integrated as a library for your existing Python-powered HDL project, or can be used stand-alone (soon anyway) to feed Edalize from projects written in other languages.

Install it

Edalize is a Python module. Find the sources at github.com/olofk/edalize. Once downloaded, we can install it with following Python command:

$ cd edalize
$ python -m pip install -e .

The reporting modules have been made optional due to their use of a number of dependencies for data analysis. These can be installed with:

$ python -m pip install -e ".[reporting]"

How to use it?

Ok, this sounds great. Now, how do I get started? Find the documentation at edalize.rtfd.io.

Assume we have a project that consists of a Verilog source file called blinky.v. Then there’s also a testbench called blinky_tb.v and a constraints file for synthesis called constraints.sdc. You can get those files from blinky and for vlog_tb_utils.v in orpsoc-cores.

For a simulation, we want to use the two Verilog files, build it in a subdirectory called build, and then run it with a parameter to control simulated clock frequency.

Edalize is a Python tool, then we can run it inside a Python script file or directly in the Python console.

First we have to import Edalize objects:

from edalize import *

The os module is also required for this tutorial:

import os

Then register the files to use:

work_root = 'build'

files = [
  {'name' : os.path.relpath('blinky.v', work_root),
   'file_type' : 'verilogSource'},
  {'name' : os.path.relpath('blinky_tb.v', work_root),
   'file_type' : 'verilogSource'},
  {'name' : os.path.relpath('vlog_tb_utils.v', work_root),
   'file_type' : 'verilogSource'}
]

The design has a toplevel Verilog parameter with the name clk_freq_hz that accepts integers. We set its default value to 1000. The testbench also has an option to enable waveform dumping by setting a plusarg called vcd:

parameters = {'clk_freq_hz' : {'datatype' : 'int', 'default' : 1000, 'paramtype' : 'vlogparam'},
              'vcd' : {'datatype' : 'bool', 'paramtype' : 'plusarg'}}

Let Edalize know we intend to use Icarus Verilog for our simulation:

tool = 'icarus'

And put it all into a single data structure together with some info about the toplevel and name for the project:

edam = {
  'files'        : files,
  'name'         : 'blinky_project',
  'parameters'   : parameters,
  'toplevel'     : 'blinky_tb'
}

Now we need to get ourselves a backend object from Edalize:

backend = get_edatool(tool)(edam=edam,
                            work_root=work_root)

Create the directory and the project files:

os.makedirs(work_root)
backend.configure()

At this point, we still haven’t run the actual EDA tool and the files in the work_root directory can be used without Edalize if that is preferred. But let’s continue the example with Edalize.

Build the simulation model:

backend.build()

And finally run it, with our arguments. Some types of parameters (e.g. plusargs) are defined aat runtime, and at this point we can change their value by passing the name and new value to run(). Or we could skip it altogether, and the default value from the configure stage would be used. Let’s run with VCD logging enabled:

args = {'vcd' : True}
backend.run(args)

Tada! We have simulated. As an exercise, try to just change the tool variable to e.g. modelsim, xsim or any of the other simulators supported by Edalize and see if it works without any changes.

Now it’s time to create an FPGA image instead

As you have seen, Edalize is an award-winning tool for interfacing EDA tools, so

Edalize it, don’t criticize it! Edalize it, and I will advertise it!

See source code for further details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

edalize-0.6.5.tar.gz (394.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

edalize-0.6.5-py3-none-any.whl (178.8 kB view details)

Uploaded Python 3

File details

Details for the file edalize-0.6.5.tar.gz.

File metadata

  • Download URL: edalize-0.6.5.tar.gz
  • Upload date:
  • Size: 394.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for edalize-0.6.5.tar.gz
Algorithm Hash digest
SHA256 331fb89854b008f6eebabaff6717197a5f431fca36f7ff21e4e1ff5cc80e9e63
MD5 72339f46c07fd0d0f8286d017874db1b
BLAKE2b-256 d3addc18cf43519d121247a39df91773d3b4a82cbb15832e3b5460dd9a58b3f8

See more details on using hashes here.

File details

Details for the file edalize-0.6.5-py3-none-any.whl.

File metadata

  • Download URL: edalize-0.6.5-py3-none-any.whl
  • Upload date:
  • Size: 178.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for edalize-0.6.5-py3-none-any.whl
Algorithm Hash digest
SHA256 83da3654f85cc1e86af0a70ae21f25a71eabfe24b0d3b7a37b99df423ff45e31
MD5 eef73f808caab22851558cd5068b659c
BLAKE2b-256 c9c1203bd4e21286556770597cfb2fbf60dbeac39deb940eb3f5adf741d6e75d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page