llvm / llvm/circt

[ExportVerilog] Initial statement needs begin/end for single declaration

Open
#3,454 3 comments 0 reactions 0 assignees View on GitHub
bug ExportVerilog
Dominant language
C++
Stars
2.2k
Forks
524
Avg merge
3d 2h
Merged PRs (30d)
46

Description

Input:
```mlir
hw.module private @Foo() -> (){
sv.initial {
%param_x = sv.localparam : i42 { value = 11: i42 }
}
}
```
`$ circt-opt -export-verilog` produces:
```verilog
module Foo();
initial
localparam [41:0] param_x = 42'd11;

endmodule
```

At least Verilator and Yosys produce a syntax error. When I added "begin" and "end" around initial statement, it parses.
```verilog
initial begin
localparam [41:0] param_x = 42'd11;
end
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the issue with the shown MLIR input and `circt-opt -export-verilog`, then inspect the ExportVerilog handling of `sv.initial`. Compare the generated output with Verilator or Yosys parsing; done means a single declaration is emitted inside `begin` and `end` and the result parses successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.