llvm / llvm/circt

[ExportVerilog] Omit bitwidth of constant array index

Open
#2,593 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

hw.module @Foo(%a: !hw.array<1xi1>) -> (b: i1) {
  %false = hw.constant false
  %0 = hw.array_get %a[%false] : !hw.array<1xi1>
  hw.output %0 : i1
}
module Foo(	// foo.fir:2:10
  input  [0:0] a,
  output       b);

  assign b = a[1'h0];	// foo.fir:2:10, :5:12
endmodule

I'm not 100% sure it is always legal but can't we just emit assign b = a[0] ?

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 with the ExportVerilog path for the constant-indexed hw.array_get shown in the issue, using the provided MLIR input to reproduce the generated SystemVerilog. Verify whether the index width is required, then confirm that the completed output uses a widthless constant index such as a[0] and remains valid for the example.

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
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.