llvm / llvm/circt

[ExportVerilog] Add Emission Option for Unique Case-insensitive Names in Module Scope

Open
#4,561 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement ExportVerilog
Dominant language
C++
Stars
2.2k
Forks
524
Avg merge
3d 2h
Merged PRs (30d)
46

Description

Some lint tools are unhappy if there are any names which conflict ignoring case. See STARC-1.1.1.5 (page 14 of https://picture.iczhiku.com/resource/eetop/WHKEgQWrYgOkYcnv.pdf). While this rule is clearly, clearly intended for human-written Verilog and not compiler-generated Verilog, it is on by default in some lint tools.

Add an emission option for `ExportVerilog`/`PrepareForEmission` that will unique names within a module ignoring case. This should include the module name in the check.

E.g., in the following, everything conflicts when ignoring case:

```mlir
module {
hw.module @Foo(%Foo: i1) -> (foo: i1) {
%FOO = sv.wire : !hw.inout
%0 = sv.read_inout %FOO : !hw.inout
sv.assign %FOO, %Foo : i1
hw.output %0 : i1
}
}
```

Currently this produces:

```verilog
module Foo(
input Foo,
output foo);

wire FOO = Foo;
assign foo = FOO;
endmodule
```

Instead, this should produce something like:

```verilog
module Foo(
input Foo_0,
output foo_1);

wire FOO_2 = Foo_0;
assign foo_1 = FOO_2;
endmodule
```

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the ExportVerilog and PrepareForEmission entry points named in the issue, and trace how module, port, and wire names are emitted. Implement the optional case-insensitive uniqueness behavior, including the module name, and verify that the example produces distinct emitted names while references remain consistent.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
40/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.