BSD 2-Clause "Simplified" License

技术解读

以下内容由 GitRead 中文社区 编辑团队基于项目 README 与官方资料整理, 结合中文开发者的常见使用场景补充技术选型建议。具体以项目官方文档为准。

深度技术分析:olofk/edalize

项目背景与痛点

在电子设计自动化(Electronic Design Automation, EDA)工具的开发过程中,存在多样的软件工具,每个工具都有自己的特点甚至是较为繁复的接口。这使得开发者在集成和自动化这些工具时面临不少挑战。正是在此背景下,olofk/edalize 应运而生,成为了一个连接 EDA 工具的桥梁,简化了 EDA 工具链的集成和自动化过程。

该项目不仅提供了一种统一的接口来访问不同的 EDA 工具,还极大提升了工程中的自动化能力,使得开发者可以更快地完成设计、仿真、综合、布局布线等各种与 EDA 工具交互的工作。对于希望提高电子系统设计与验证效率的研发团队而言,它是不可或缺的利器。

核心技术揭秘

olofk/edalize 的核心技术在于其抽象库的设计,通过一系列 Python 脚本和配置文件,实现与各种 EDA 工具的对接。核心功能通过提供的 API 层来访问,从而提供了一种一致的方式来触发和控制这些工具。以下是该项目的架构设计图,展现了其技术核心:

graph TD A[用户命令] --> B[API 调用] B --> C[F("工具配置文件")] C --> D[{"解析配置"}] D -->|"成功"| E[{"检测工具"}] D -->|"失败"| F[返回错误] E --> G[{"执行任务"}] G --> H[结果输出]

在实现原理中,配置文件扮演着关键角色,它描述了每一个 EDA 工具的特定参数及其使用方式。通过解析这些配置文件,olofk/edalize 可以透明地调用和管理所涉及的每一个工具链组件。

功能亮点与差异

与同类工具相比,olofk/edalize 最突出的特点在于其广泛的工具支持和灵活的配置机制。它能够轻松集成多种 EDA 工具,并通过统一的 API 接口来调用,有效节省了开发时间,提升了系统的可维护性和扩展性。尤其是配置文件的设计,在保持代码简洁性的同时,极大增强了工具的灵活性,使得复杂度高的 EDA 工具链可以更加便于管理和控制。

应用场景与落地建议

对于实际生产环境的使用,开发者需注意以下几点:

  • 确保 EDA 工具链中的每一部分已被正确安装并且是否存在于系统的 PATH 中。
  • 仔细校验证据配置文件,避免因配置错误引起的功能异常。
  • 考虑选用适当的 EDA 工具,根据实际需求和资源利用情况进行最佳选择。

此项目特别适用于高频重复使用的 EDA 工具链,例如在日常设计验证流程中的自动化任务,以及需要高度可定制的多工具集成场景。通过引入 olofk/edalize,团队可以显著提高项目交付效率和质量。

综合评价

综上所述,olofk/edalize 项目的贡献在于简化了 EDA 工具链的集成过程,提供了更加友好的工具访问接口,帮助开发团队减少繁琐的集成步骤,专注于核心设计本身。但项目作为一个广泛的工具链管理者,本身也存在工具依赖性和复杂配置的需求,可能成为新手的入门障碍。总体而言,该项目是电子系统设计和验证领域值得深入研究和实践的宝藏项目。

关于

GitHub 原始描述(英文)

An abstraction library for interfacing EDA tools

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

语言占比

Batchfile
Filebench WML
Forth
Fortran
Jinja
Makefile
Python
Shell
Tcl
VHDL
Verilog

Release

README

… image:: https://img.shields.io/readthedocs/edalize?longCache=true&style=flat-square&label=edalize.rtfd.io&logo=ReadTheDocs&logoColor=e8ecef :target: https://edalize.readthedocs.io/en/latest/?badge=latest :alt: Documentation Status

… image:: https://img.shields.io/badge/Chat-on gitter-4db797.svg?longCache=true&style=flat-square&logo=gitter&logoColor=e8ecef :alt: Join the chat at https://gitter.im/librecores/edalize :target: https://gitter.im/librecores/edalize?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge

… image:: https://img.shields.io/pypi/dm/edalize.svg?longCache=true&style=flat-square&logo=PyPI&logoColor=e8ecef&label=PyPI downloads :target: https://pypi.org/project/edalize/ :alt: PyPI downloads

… image:: https://img.shields.io/github/actions/workflow/status/olofk/edalize/ci.yml?branch=main&longCache=true&style=flat-square&label=CI&logo=github actions&logoColor=e8ecef :target: https://github.com/olofk/edalize/actions/workflows/CI.yml :alt: 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 <https://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 <https://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 <https://github.com/fusesoc/blinky>_ and for vlog_tb_utils.v in orpsoc-cores <https://github.com/fusesoc/vlog_tb_utils/blob/master/vlog_tb_utils.v>_.

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.

… _Edalize introduction video: https://www.youtube.com/watch?v=HuRtkpZqB34

评论

暂无评论