Skip to content

Feature request: Add SystemVerilog support #843

Open

Description

@henry-hsieh

Description

I’d like to contribute first-class SystemVerilog support to AFT. I’d like to align on the architecture and feature scope first.

The proposal is to extend AFT’s existing tools with complementary source-structural and compiler-backed views of HDL projects.

Architecture

Two complementary frontends

  • Use tree-sitter-systemverilog for written-source structure: symbols, outlines, source zoom, structural search, and AST-based edits. These capabilities should remain available without a configured or successfully compiling design.
  • Use Slang, through Rust bindings, for configured-design semantics: resolved declarations, types, references, package imports, procedural calls, argument bindings, and elaborated hierarchy.

Tree-sitter describes the source as written; Slang explains its meaning within a selected build. Physical declarations and elaborated instances should remain distinct in the tool results.

A shared compiler service in the Rust engine

Keep compiler integration in the engine so OpenCode, Pi, standalone, and Subc share the same behavior. Run native Slang compilations in a supervised helper process and return bounded, owned compiler facts rather than sharing native compiler objects across engine threads.

Analyze captured source snapshots, with filelists, includes, and library loading mediated by AFT’s file-access policy. Cache analysis per checkout and selected build, invalidating it when source files, configuration, or dependencies change.

Explicit build context

Support named build profiles containing source files and filelists, include directories, macro definitions, library files/directories, top modules, and compiler options. Compiler-backed tools should consistently use the selected profile, while structural tools remain independent of build configuration.

Complementary LSP integration

Integrate slang-server through AFT’s existing LSP infrastructure for diagnostics, definition/reference navigation, and rename proposals. Use the compiler service for captured build analysis and validation of proposed changes.

Features

Area Proposed capabilities
Reading Structural outline and zoom; compiler-resolved declaration/type views; a separate elaborated hierarchy view.
Navigation Definitions, references, and compiler-resolved procedural callgraph queries based on declaration identity.
Imports Scope-aware package import add/remove/organize, with compiler-backed checks that existing bindings are preserved.
Editing Selected-build compilation validation for writes, text edits, symbol edits, and coordinated AST replacements.
Rename Reference-aware rename with compiler validation of proposed edits and affected bindings.
Tracing Procedural value flow through assignments and function/task arguments, accounting for argument directions.
Refactoring Compiler-validated extract, inline, and top-level declaration moves, introduced incrementally through explicitly supported cases.

Compilation acceptance and binding preservation are different checks: an edit can compile while changing which declaration a name refers to. Tools should make that distinction clear and report partial coverage when errors or unsupported constructs prevent a complete answer.

Integration approach

Extend the existing AFT tools rather than introduce a separate HDL tool suite. Keep harness adapters thin and preserve shared preview, backup, undo, cancellation, and path-policy behavior.

Would this dual-frontend architecture fit AFT’s direction? If so, I’d propose incremental contributions: structural support and LSP integration, then the shared compiler service and semantic tools, followed by validated editing and refactoring.

Use case

SystemVerilog projects commonly depend on filelists, include paths, macros, packages, libraries, and selected top-level modules. Understanding a file in isolation is often insufficient to resolve a reference or determine the effect of an edit.

This would let coding agents use AFT’s existing workflow to:

  • Explore source structure immediately, even before the design builds successfully.
  • Resolve references and procedural calls using the actual build context instead of matching names alone.
  • Inspect elaborated instances while retaining links to their physical source definitions.
  • Follow procedural data flow across assignments and function/task boundaries.
  • Edit imports, rename declarations, and perform supported refactors with compiler-backed checks before applying changes.
  • Validate coordinated edits against the selected design and use the existing preview/undo workflow.

Keeping these capabilities in AFT’s shared engine would make them available consistently across supported harnesses, including mixed-language repositories containing HDL alongside software and build tooling.

Activity

  1. aft-alfonso commented on Oct 24, 2026

    @aft-alfonso

    Thanks for the detailed proposal, @henry-hsieh.

    The first two parts fit how AFT supports other languages, and we would welcome contributions for them:

    1. Structural support with tree-sitter-systemverilog: symbols, outline, zoom, structural search and replace, and syntax checks after edits. A new language plugs in through crates/aft/src/language.rs and parser.rs. Import editing would be a SystemVerilog engine under crates/aft/src/imports/.
    2. slang-server through the existing language-server layer (crates/aft/src/lsp/): diagnostics in aft_inspect and after edits, plus definition and reference navigation.

    We would like to hold off on the embedded Slang compiler service for now. AFT gets semantic answers from language servers rather than embedding compilers. A native C++ dependency would also have to build and ship in the release binaries for macOS, Linux and Windows. Once structural support and slang-server are in, we can look at which answers slang-server cannot give and decide then whether a compiler service is worth it. Build profiles (filelists, include paths, defines, top modules) are probably best left to slang-server's own project configuration rather than new AFT settings.

    For a first PR, please keep it to the tree-sitter support, with tests on a small real design that uses packages, interfaces and includes. A draft PR early is welcome, so we can agree on the shape before it grows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions