lowRISC / lowRISC/opentitan

[reggen] Feature request: Add enum for window id

Open
#23,060 0 comments 0 reactions 0 assignees View on GitHub
Tool:reggen Type:Enhancement
Dominant language
SystemVerilog
Stars
3.6k
Forks
1.1k
Avg merge
2d 22h
Merged PRs (30d)
141

Description

### Description

Reggen generates a helpful enum in reg_pkg.sv.tpl with numeric identifiers for the various registers (even though they'll probably be addressed by name within reg2hw and hw2reg):
```sv
// Register index
typedef enum int {
MYMODULE_CFG,
MYMODULE_STATUS,
MYMODULE_INTERRUPTS
} mymodule_id_e;
```
It would also be useful that the same were done for windows, especially since they have to be referenced by index (there's no fancy struct definition with one member per window as it is the case for registers):
```sv
// Window index
typedef enum int {
MYMODULE_INPUTDATA,
MYMODULE_OUTPUTDATA
} mymodule_win_id_e;
```
Right now, there's no way to figure out which index corresponds to which window other than by counting window entries in the hjson file.

(And, on a partially related note, do you think it would make sense to add a dummy `MYMODULE_NUMBER_OF_REGS`/`MYMODULE_NUMBER_OF_WINS` entry at the end of both enums, to know how many elements are in each enum, so that they can be used for array dimensions and the like? For example, `reg_req_t [MYMODULE_NUMBER_OF_WINS-1:0] reg_req_win_o;`)

Contributor guide

Open the contributing guide

Research direction

The register enum is generated from reg_pkg.sv.tpl; start by locating that template and the reggen handling of window entries in the HJSON input. Confirm the generated window enum preserves window order and includes every window, then verify the generated SystemVerilog output against the requested examples.

Written by the indexing model from the issue text.

Assessment

Domain
embedded-iot, tooling
Issue type
Feature
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.