intel / intel/rohd

Make it easier to flop `LogicArray`s and `LogicStructure`s

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

Description

### Motivation

The `flop` function and `FlipFlop` module flatten structures and arrays to a single packed `Logic`. If you want to flop an array or a structure, you may often want it to be an array or structure on the way out as well.

### Desired solution

For API consistency, we could keep `flop` and `FlipFlop`, but update the input and output port creation to use `LogicArray`s when possible. However, this still would require a cast `as LogicArray` on the outputs.

Another new API might be a good idea: adding a `.flop` API onto `Logic` itself. Then, you could do things like

```dart
myLogic.flop(clk, ...) // returns a Logic
myStruct.flop(clk, ...) // returns a LogicStructure
myArray.flop(clk, ...) // returns a LogicArray
```

This way, the type could be maintained. Under the hood, it can just use the `clone` method, which already may be properly overridden by users with custom types of structures.

### Alternatives considered

Currently, users have to do something like
```dart
myArray.clone()..gets(flop(clk, myArray,...));
```

### Additional details

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.