intel / intel/rohd

Dart code generation for common automation

Open
#511 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Dart
Stars
489
Forks
88
Avg merge
3d 23h
Merged PRs (30d)
10

Description

### Motivation

There are some things in ROHD that can be a bit verbose/redundant. For example, a simple port whose variable name and String port name are the same, and which needs a public `get`ter, could required this kind of boilerplate:

```dart
Logic get _myPort => input('myPort');

MyClass({Logic myPort}) {
myPort = addInput('myPort', myPort);
// ...
}
```

Note the word "myPort" is written 6 times, when the intent is really "add an input port named myPort".

Dart's static metaprogramming feature (upcoming, currently experimental) could potentially help automate a lot of this so that a simple annotation, something like `input('myPort')` could generate all the boilerplate.

A similar strategy could apply for ports on modules and interfaces, and perhaps many other places where things are a bit verbose in the "simple common" case.

The APIs themselves are very flexible, offering more capabilities than the simple case, which is why there is repetition in simple cases.

### Desired solution

Implement code generation features in ROHD to handle the simple cases, while keeping the existing APIs for less simple cases (and backwards compatibility, or for those who don't want to use the new features).

### Alternatives considered

_No response_

### Additional details

Information on Dart's static metaprogramming features:
https://github.com/dart-lang/language/issues/1482
https://github.com/dart-lang/language/blob/main/working/macros/feature-specification.md
https://dart.dev/language/macros

Contributor guide

Open the contributing guide

Research direction

Start with the linked Dart static metaprogramming and macros documentation, then review ROHD's existing APIs for ports on modules and interfaces. Define which simple cases code generation should cover, while preserving the current flexible APIs and backwards compatibility; completion should include working generation for those cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.