Skip to content

Go to Definition does not resolve macro usages to define declarations #137

@FukangZ

Description

@FukangZ

Summary

Go to Definition does not navigate from a preprocessor macro usage to the corresponding `define declaration, even when the macro definition file is included and explicitly loaded by vizsla.toml.

This affects common Verilog/SystemVerilog code reading workflows. For example, users cannot jump from `IRQ_IAR in RTL code to the register address definition in an included header file.

Environment

  • OS: Windows
  • VS Code version: 1.120.0
  • Vizsla extension version: 0.1.4

Minimal Reproduction

Create a workspace with these three files:

macro-goto-definition/
  vizsla.toml
  top.v
  defs.vh

vizsla.toml:

#:schema https://pascal-lab.github.io/vizsla/schemas/v1/vizsla.schema.json

top_modules = ["macro_jump_top"]

sources = [
  "top.v",
  "defs.vh",
]

include_dirs = [
  ".",
]

defs.vh:

`ifndef MACRO_JUMP_DEFS_VH
`define MACRO_JUMP_DEFS_VH

`define IRQ_IAR 8'h0c
`define IRQ_IAR_ACK_DEFAULT 8'h00
`define IRQ_IAR_ACK_R 7:0

`endif

top.v:

`include "defs.vh"

module macro_jump_top
(
    input        clk_i,
    input        rst_i,
    input        write_en_i,
    input  [7:0] addr_i,
    input  [7:0] data_i,
    output [7:0] ack_o
);

reg [7:0] ack_q;

assign ack_o = ack_q;

always @(posedge clk_i or posedge rst_i)
begin
    if (rst_i)
        ack_q <= `IRQ_IAR_ACK_DEFAULT;
    else if (write_en_i && addr_i == `IRQ_IAR)
        ack_q <= data_i[`IRQ_IAR_ACK_R];
end

endmodule

Reproduction Steps

  1. Open the macro-goto-definition/ directory in VS Code.
  2. Wait until Vizsla is ready.
  3. Open top.v.
  4. Put the cursor on `IRQ_IAR in this line:
else if (write_en_i && addr_i == `IRQ_IAR)
  1. Run Go to Definition.
  2. Repeat the same operation on `IRQ_IAR_ACK_DEFAULT and `IRQ_IAR_ACK_R.

Expected

Vizsla should navigate to the corresponding macro definitions in defs.vh:

`define IRQ_IAR 8'h0c
`define IRQ_IAR_ACK_DEFAULT 8'h00
`define IRQ_IAR_ACK_R 7:0

Actual

No definition location is returned for these macro usages.

The project configuration appears to be valid:

  • top.v is listed in sources.
  • defs.vh is listed in sources.
  • include_dirs = ["."] allows `include "defs.vh" to resolve.
  • Regular HDL symbol navigation works in configured projects.

Related Issues

This is related to macro support, but it appears to cover a different LSP feature from existing open issues:

This issue is specifically about textDocument/definition: navigating from a macro usage such as `IRQ_IAR to its `define IRQ_IAR declaration.

Metadata

Metadata

Assignees

No one assigned

    Labels

    known-limitThis is a known limit and may be implemented in future.macros

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions