Apache License 2.0

技术解读

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

GitHub 仓库 “tymonx/logic” 深度技术分析

项目背景与痛点

tymonx/logic 是一个针对 FPGA 与 ASIC 项目设计的 CMake 工具集,它利用了 SystemVerilog 和 SystemC 这两种硬件描述语言,为开发者提供了统一的数据流和工具链来创建、构建、以及测试 RTL(寄存器传输级)项目。它解决了当下硬件设计流程中常见的痛点:复杂的构建系统及其带来的不一致性和可移植性问题。使用 CMake 作为构建系统,使得跨平台开发更为简便,同时能够加速设计流程,提升开发效率。

为什么我们需要这样的工具?在现代集成电路设计中,规模越来越大,复杂度越来越高,传统的构建系统已经无法满足需求。使用统一的构建和测试框架,能够减少设计流程中的不一致性和冗余操作,显著提高项目交付速度和质量。此外,FPGA 和 ASIC 之间的转换也变得更加便捷和高效。

核心技术揭秘

tymonx/logic 的核心在于其构建流程和测试框架的设计。它采用了 CMake 作为构建系统,因为 CMake 是一个非常流行的跨平台构建工具,广泛应用于多个行业领域。其主要技术堆栈包括:

  • CMake:跨平台构建系统,提供一致的构建配置。
  • SystemVerilog 和 SystemC:用于硬件描述和仿真。
  • 自动化测试:集成测试框架,确保每个模块符合要求。

其架构可以概括为以下几点:

  1. 项目初始化:使用 CMake 创建必要的配置文件,定义项目依赖和编译规则。
  2. 构建系统集成:支持多种编译器和 HLS(高阶综合)工具,通过配置文件动态切换编译选项。
  3. 测试框架:集成验证和单元测试模块,确保 RTL 代码符合预期。

以下是该项目核心数据流的 Mermaid 架构图:

graph TD A[项目初始化] --> B{"配置检测"} B -->|"配置文件存在"| C[创建工程目录结构] B -->|"配置文件不存在"| D[生成默认配置] C --> E[读取编译选项] D --> E E --> F[编译 RTL 项目] F --> G{"编译结果"} G -->|"成功"| H[执行单元测试] G -->|"失败"| I[输出错误信息] H --> J[测试覆盖率] H --> K[生成报告]

功能亮点与差异

tymonx/logic 有着明显的功能亮点和技术优势:

  • 高度可配置性:支持灵活的编译选项和测试策略。
  • 跨平台兼容性:使用 CMake 作为关键构建工具,可轻松移植到不同的开发环境。
  • 无缝集成测试:模块化的测试框架可以与主流自动化测试工具组合使用。
  • 无缝跨越 FPGA 与 ASIC:支持多种硬件平台上的高效开发和优化。

与其他类似的工具包相比,tymonx/logic 在构建系统上更为集成化和自动化,大大减少手动配置的时间和错误率。其优异的测试框架确保每一个阶段的输出都经过严格验证,从而提高整体设计质量。

应用场景与落地建议

使用 tymonx/logic 在生产环境中需要留意以下几点:

  1. 依赖项管理:确保护存下所有必要的依赖项配置,避免因为环境变量导致的兼容性问题。
  2. 测试覆盖率:确保每个模块都被充分测试,达到足够的覆盖度,避免潜在的未验证问题。
  3. 团队协作:提供完善的文档、配置体验,确保多个开发者能够无缝协作,提高团队开发效率。

适合的应用场景包括:

  • 项目应用于复杂 FPGA 设计和 ASIC 验证。
  • 大规模、长期维护的硬件开发项目,可以利用 tymonx/logic 的自动化优势来提高生产力和整体质量。

综合评价

tymonx/logic 无疑是现代硬件设计中跨越平台的重要工具之一。它的亮点在于将通用构建工具与硬件描述语言相结合,为开发者提供了高度标准化的开发体验。然而,其依赖和配置项较多,可能会增加新人上手的学习成本。

总得来说,如果你正在寻找一个强大的工具来简化你的 FPGA 和 ASIC 项目开发工作,tymonx/logic 绝对值得考虑。

关于

GitHub 原始描述(英文)

CMake, SystemVerilog and SystemC utilities for creating, building and testing RTL projects for FPGAs and ASICs.

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

语言占比

C++
CMake
Python
Shell
SystemVerilog
Tcl
Vim Script

贡献者

README

Logic

Language Standard Language License Apache-2.0 Build Status Join the chat at https://gitter.im/tymonx/logic

CMake, SystemVerilog and SystemC utilities for creating, building and testing RTL projects for FPGAs and ASICs.

Includes:

  • CMake utilities for rapid building and testing RTL projects
  • SystemVerilog modules for creating high quality RTL projects
  • Modern C++ framework for UVM with SystemC for creating high quality and performance efficient tests for RTL projects

Benefits

  • Quick setup
  • Cross platform, cross IDE
  • No need to create separate scripts for simulation and synthesis
  • No need to create separate scripts for different tools (Intel Quartus, Xilinx Vivado, Verilator, ModelSim, …)
  • Supports incremental compilation, run slow vendor IP core regeneration and different simulation and synthesis tools only if input source file changes
  • Supports parallel compilation, run slow vendor IP core regeneration and different simulation and synthesis tools in parallel
  • Maintain the same file consistency between simulation and synthesis for different tools
  • Share the same HDL source code base and IP cores for various FPGA projects
  • Integration with Continuous Integration (CI) and Continuous Deployment (CD) like Jenkins, Hudson, GitLab, etc.
  • Run RTL unit tests under ctest: pass/fail, time execution, timeout, parallel execution, tests selection
  • Run the same unit tests with different parameters
  • Easy to integrate with other projects as git submodule
  • Custom UVM printers: JSON
  • Modern HDL testing library written in C++11 using UVM-SystemC
  • Support for Clang 3.5 and later
  • Support for GCC 4.9 and later

Documentation

Examples

FPGA projects that use Logic utilities for creating, building and testing:

  • Virtio - Virtio implementation

Requirements

These 3rd party tools and libraries are required. They must be installed to build logic library:

These 3rd party tools and libraries are optional. They must be installed to build and run tests:

  • Verilator - simulator, lint and coverage tool
  • GoogleTest - C++ unit test framework
  • SVUnit - SystemVerilog unit test framework

These 3rd party tools and libraries are optional:

Workspace

  • README.md - this read me file in MarkDown format
  • LICENSE - license file
  • CMakeLists.txt - CMake root script for building and testing project
  • doc - configuration files for code documentation generator
  • rtl - RTL source files
  • src - C++ source files
  • include - C++ include headers
  • tests - unit tests and verification tests in SystemC using Google Test or UVM and SystemVerilog using SVUnit
  • cmake - additional CMake scripts for building project
  • scripts - additional scripts in TCL or Python for building project

Build

Clone project repository:

git clone [email protected]:tymonx/logic.git

Change current location to project directory:

cd logic

Create build directory:

mkdir build

Change current location to build directory:

cd build

Create build scripts using CMake:

cmake ..

Build project using CMake (generic):

cmake --build . --target all

Or build project using make:

make -j`nproc`

It is much faster to recompile project using Ninja rather than Unix makefiles:

cmake -G Ninja ..
cmake --build . --target all

Documentation

To build documentation:

cmake --build . target doc

Built HTML documentation can be found in:

doc/html

To view HTML documentation, open it using web browser:

<WEB_BROWSER> doc/html/index.html

Tests

Run all unit tests:

ctest

Run only unit tests for AXI4-Stream:

ctest -R axi4_stream

Waveforms from unit tests run under ModelSim are stored in:

modelsim/unit_tests/<unit_test_name>

Waveforms from unit tests run under Verilator are stored in:

verilator/unit_tests/<unit_test_name>

All unit tests logs are stored in:

Testing/Temporary/LastTest.log

Verilator Coverage

Run Verilator coverage after running all tests:

cmake --build . --target verilator-coverage

Verilator analysis

Enable Verilator analysis:

add_hdl_source(<hdl-module-filename>
    ANALYSIS
        TRUE
)

Run Verilator analysis for <hdl-module-name>:

make verilator-analysis-<hdl-module-name>

Run Verilator analysis for all HDL modules:

make verilator-analysis-all

Creating Intel FPGA Quartus project

Use add_quartus_project() function to create Quartus project:

add_quartus_project(<top_level_entity>)

Quartus project will be created under:

quartus/<top_level_entity>

RTL analysis and elaboration in Intel FPGA Quartus for top level entity:

cmake --build . --target quartus-analysis-<top_level_entity>

RTL compilation in Intel FPGA Quartus for top level entity:

cmake --build . --target quartus-compile-<top_level_entity>

RTL analysis and elaboration in Intel FPGA Quartus for all top level entities:

cmake --build . --target quartus-analysis-all

RTL compilation in Intel FPGA Quartus for all top level entities:

cmake --build . --target quartus-compile-all

Creating Xilinx Vivado project

Use add_vivado_project() function to create Vivado project:

add_vivado_project(<top_level_entity>)

Vivado project will be created under:

vivado/<top_level_entity>

RTL analysis and elaboration in Xilinx Vivado for top level entity:

cmake --build . --target vivado-analysis-<top_level_entity>

Using with other CMake projects

Change current location to another RTL project root directory:

cd <rtl_project_root_directory>

Clone and add logic repository to RTL project as git submodule:

git submodule add [email protected]:tymonx/logic.git

Add these lines to CMakeLists.txt root file:

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
    ${CMAKE_CURRENT_LIST_DIR}/logic/cmake
)

include(AddLogic)

enable_testing()

add_subdirectory(logic)

评论

暂无评论