llvm / llvm/circt

[PrettifyVerilog] Transform (some) array_create/get pairs into cases

Open
#1,545 0 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

As discussed in the design meeting it would make sense to lower certain array_create/get pairs into case statements (potentially in an always_comb block):

  1. When the expression feeding the elements is large, complicated, and single use it would make sense to generate case statements.
  2. When multiple array_get's exists that use the same index condition it makes sense to fold them together into a single larger case. It is possible that this is just a "case folding" peephole that triggers after the first one.

We need to be careful not to go overboard here though, because the array_create syntax is nice for simple inline expressions. The example in the rationale docs should stay inline for example.

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

Read the linked design-meeting discussion and the array operation rationale in docs/RationaleHW-SV.md first. Then locate the PrettifyVerilog implementation and its existing tests; completion should selectively lower suitable array_create/get pairs while keeping simple inline expressions, including the rationale example, unchanged.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.