Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
e6cfe51
refactored synthesizers to be more modular, passing tests
mkorbel1 Nov 26, 2024
ccbd415
minor tweaks
mkorbel1 Dec 16, 2024
2262dfe
refactor to return multiple file contents
mkorbel1 Dec 27, 2024
8dc3c9c
add a reminder todo for issue
mkorbel1 Dec 30, 2024
231a4c4
initial work on LogicEnum
mkorbel1 Jun 24, 2025
f170ef1
Merge branch 'main' of github.com:intel/rohd into logic_enum
mkorbel1 Jun 24, 2025
6e4e297
Merge branch 'main' of github.com:intel/rohd into synth_modularity
mkorbel1 Jun 24, 2025
b2834f5
deprecate ane make new names, to preserve backwards compatibility
mkorbel1 Jun 24, 2025
0157952
adjust apis a bit
mkorbel1 Jun 24, 2025
97790a9
tested that multi top works in synth builder
mkorbel1 Jun 24, 2025
dda9399
test more stuff about synthfilecontents
mkorbel1 Jun 25, 2025
4e9c373
cleanup and docs
mkorbel1 Jun 25, 2025
fd6c0cb
update docs a bit
mkorbel1 Jun 25, 2025
bc93467
tweaks to docs
mkorbel1 Jun 25, 2025
748d652
Merge branch 'synth_modularity' into logic_enum
mkorbel1 Jun 25, 2025
0fa161f
wip enum sv gen
mkorbel1 Jun 25, 2025
d8c9fab
try a new runner
mkorbel1 Jun 25, 2025
64fb5e3
Merge branch 'main' of github.com:intel/rohd into logic_enum
mkorbel1 Jun 25, 2025
2d1b65e
wip implementing enum stuff
mkorbel1 Jun 27, 2025
8177d88
first basic test passing with enum sorta
mkorbel1 Jun 30, 2025
d51be81
basic sv gen testing
mkorbel1 Jun 30, 2025
09c11cf
got enum and const merging working better
mkorbel1 Jun 30, 2025
b645199
got some basic cond type passing working
mkorbel1 Jul 1, 2025
7ca82de
got basic case and condassign working with type matching
mkorbel1 Jul 1, 2025
97a8926
added actual logicenum type support for conds
mkorbel1 Jul 1, 2025
0b39f1d
got cases special case for enum
mkorbel1 Jul 2, 2025
0c451d6
wip enum stuff
mkorbel1 Jul 8, 2025
97dccee
some todos
mkorbel1 Jul 9, 2025
72179a7
Merge origin/main into logic_enum
mkorbel1 Jul 17, 2026
4047541
further implementation of enum support and testing
mkorbel1 Jul 20, 2026
ae8f1e1
more tests and some bug fixes
mkorbel1 Jul 20, 2026
8e8071c
tests around typed ports
mkorbel1 Jul 20, 2026
3036f50
support to maintain enum in sv gen for ports
mkorbel1 Jul 21, 2026
c3ea32e
Merge branch 'main' of https://github.com/intel/rohd into logic_enum
mkorbel1 Jul 22, 2026
a69688c
Merge branch 'main' of https://github.com/intel/rohd into logic_enum
mkorbel1 Jul 22, 2026
e8ceeed
add extra pr num in changelog
mkorbel1 Jul 22, 2026
fb7c045
some todo cleanup for issues already there or missing headers
mkorbel1 Jul 22, 2026
1093d20
no more todos floating about
mkorbel1 Jul 22, 2026
4d032e9
Merge branch 'main' of https://github.com/intel/rohd into logic_enum
mkorbel1 Aug 4, 2026
70d2aa0
fix enum cases
mkorbel1 Aug 6, 2026
9078c53
update user guide
mkorbel1 Aug 10, 2026
bd4c464
ignore doc links so we can make new ones
mkorbel1 Aug 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/configs/mlc_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
{
"pattern":"^https://github.com"
},
{
"pattern":"^https://intel\\.github\\.io(?:/|$)"
},
{
"pattern":"^https://pymtl3.readthedocs.io/en/latest/$"
},
Expand Down
4 changes: 2 additions & 2 deletions doc/user_guide/_docs/A02-logical_signals.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "Logical Signals"
permalink: /docs/logical-signals/
excerpt: "Logic signals"
last_modified_at: 2025-7-24
last_modified_at: 2026-08-10
toc: true
---

Expand All @@ -18,7 +18,7 @@ var x = Logic();
var bus = Logic(name: 'b', width: 8)
```

There are other types like [`LogicArray`](https://intel.github.io/rohd/rohd/LogicArray-class.html)s and [`LogicStructure`](https://intel.github.io/rohd/rohd/LogicStructure-class.html)s which extend from `Logic`, as well.
There are other types which extend `Logic`, including [`LogicArray`](https://intel.github.io/rohd/rohd/LogicArray-class.html), [`LogicStructure`](https://intel.github.io/rohd/rohd/LogicStructure-class.html), and [`LogicEnum`](https://intel.github.io/rohd-website/docs/logic-enums/) for representing Dart enum values as typed hardware signals.

#### The value of a signal

Expand Down
6 changes: 4 additions & 2 deletions doc/user_guide/_docs/A08-modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "Modules"
permalink: /docs/modules/
excerpt: "Modules"
last_modified_at: 2025-7-24
last_modified_at: 2026-08-10
toc: true
---

Expand Down Expand Up @@ -54,7 +54,7 @@ All gates or functionality apart from assign statements in ROHD are implemented

The default width of a port is 1. You can control the width of ports using the `width` argument of `addInput()` and `addOutput()`. You may choose to set them to a static number, based on some other variable, or even dynamically based on the width of input parameters. These functions also return the input/output signal.

There are also similar functions called `addTypedInput` and `addTypedOutput` which will create a port with matching widths and types. This is especially useful for creating `LogicStructure` ports.
There are also similar functions called `addTypedInput` and `addTypedOutput` which will create a port with matching widths and types. This is especially useful for creating `LogicStructure` and [`LogicEnum`](https://intel.github.io/rohd-website/docs/logic-enums/) ports.

Available mechanisms for creating ports on a `Module` are listed below:

Expand All @@ -70,6 +70,8 @@ Available mechanisms for creating ports on a `Module` are listed below:
| `addInOut` | Adds an in/out (bidirectional) `Logic` port to the module with explicit width. Requires an external source. |
| `addInOutArray` | Adds an in/out (bidirectional) `LogicArray` port to the module with explicit dimensions and element width. Requires an external source. |

`LogicEnum` supports typed input and output ports. Typed enum in/out ports are not currently supported because there is no net-backed `LogicEnum` type.

You can also use [`Interface`s](https://intel.github.io/rohd-website/docs/interfaces/) to create groups of ports.

It can be convenient to use dart getters for signal names so that accessing inputs and outputs of a module doesn't require calling `input()` and `output()` every time. It also makes it easier to consume your module.
Expand Down
4 changes: 3 additions & 1 deletion doc/user_guide/_docs/A10-conditionals.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "Conditionals"
permalink: /docs/conditionals/
excerpt: "Conditionals"
last_modified_at: 2022-12-06
last_modified_at: 2026-08-10
toc: true
---

Expand Down Expand Up @@ -92,6 +92,8 @@ Combinational([
]);
```

The `cases` helper accepts enum members as keys when its selector is a compatible [`LogicEnum`](https://intel.github.io/rohd-website/docs/logic-enums/). It returns an ordinary `Logic`, so enum results must be supplied as explicitly mapped signals rather than bare Dart enum members.

Note that ROHD supports the 'z' syntax, not the '?' syntax (these are equivalent in SystemVerilog).

There is no support for an equivalent of `casex` from SystemVerilog, since it can easily cause unsynthesizeable code to be generated (see: <https://www.verilogpro.com/verilog-case-casez-casex/>).
49 changes: 26 additions & 23 deletions doc/user_guide/_docs/A15-fsm.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "Finite State Machines"
permalink: /docs/fsm/
excerpt: "Finite State Machines"
last_modified_at: 2023-09-19
last_modified_at: 2026-08-10
toc: true
---

Expand Down Expand Up @@ -47,14 +47,17 @@ Now, let's define the encoding of outputs (the color of the light).

```dart
enum LightColor {
green(0),
yellow(1),
red(2);

final int value;

const LightColor(this.value);
green,
yellow,
red,
}

final lightType = LogicEnum(
LightColor.values,
definitionName: 'LightColor',
);
final northLight = addTypedOutput('northLight', lightType.clone);
final eastLight = addTypedOutput('eastLight', lightType.clone);
```

Now we can go ahead and describe the set of states for our state machine. Note that for each state, we describe a few things:
Expand All @@ -68,16 +71,16 @@ final states = <State<LightStates>>[
State(LightStates.northFlowing, events: {
TrafficPresence.isEastActive(traffic): LightStates.northSlowing,
}, actions: [
northLight < LightColor.green.value,
eastLight < LightColor.red.value,
northLight < LightColor.green,
eastLight < LightColor.red,
]),
State(
LightStates.northSlowing,
events: {},
defaultNextState: LightStates.eastFlowing,
actions: [
northLight < LightColor.yellow.value,
eastLight < LightColor.red.value,
northLight < LightColor.yellow,
eastLight < LightColor.red,
],
),
State(
Expand All @@ -86,17 +89,17 @@ final states = <State<LightStates>>[
TrafficPresence.isNorthActive(traffic): LightStates.eastSlowing,
},
actions: [
northLight < LightColor.red.value,
eastLight < LightColor.green.value,
northLight < LightColor.red,
eastLight < LightColor.green,
],
),
State(
LightStates.eastSlowing,
events: {},
defaultNextState: LightStates.northFlowing,
actions: [
northLight < LightColor.red.value,
eastLight < LightColor.yellow.value,
northLight < LightColor.red,
eastLight < LightColor.yellow,
],
),
];
Expand All @@ -120,14 +123,14 @@ final states = <State<LightStates>>[
State(LightStates.northFlowing, events: {
TrafficPresence.isEastActive(traffic): LightStates.northSlowing,
}, actions: [
northLight < LightColor.green.value,
northLight < LightColor.green,
]),
State(
LightStates.northSlowing,
events: {},
defaultNextState: LightStates.eastFlowing,
actions: [
northLight < LightColor.yellow.value,
northLight < LightColor.yellow,
],
),
State(
Expand All @@ -136,15 +139,15 @@ final states = <State<LightStates>>[
TrafficPresence.isNorthActive(traffic): LightStates.eastSlowing,
},
actions: [
eastLight < LightColor.green.value,
eastLight < LightColor.green,
],
),
State(
LightStates.eastSlowing,
events: {},
defaultNextState: LightStates.northFlowing,
actions: [
eastLight < LightColor.yellow.value,
eastLight < LightColor.yellow,
],
),
];
Expand All @@ -156,13 +159,13 @@ FiniteStateMachine<LightStates>(
states,
setupActions: [
// by default, lights should be red
northLight < LightColor.red.value,
eastLight < LightColor.red.value,
northLight < LightColor.red,
eastLight < LightColor.red,
],
);
```

This state machine is now functional and synthesizable into SystemVerilog!
This state machine is now functional and synthesizable into SystemVerilog. Its `currentState` and `nextState` signals are `LogicEnum<LightStates>`, and generated SystemVerilog uses the `LightColor` enum for internal output backing signals and symbolic assignments. See [Logic Enums](https://intel.github.io/rohd-website/docs/logic-enums/) for details about enum mappings and generation.

You can even generate a mermaid diagram for the state machine using the [`generateDiagram`](https://intel.github.io/rohd/rohd/FiniteStateMachine/generateDiagram.html) API.

Expand Down
16 changes: 15 additions & 1 deletion doc/user_guide/_docs/A21-generation.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "Generating Outputs"
permalink: /docs/generation/
last_modified_at: 2023-11-13
last_modified_at: 2026-08-10
toc: true
---

Expand Down Expand Up @@ -53,6 +53,20 @@ final generatedSv = myModule.generateSynth(

The same configuration can be passed directly to `SystemVerilogSynthesizer` when using `SynthBuilder`.

## Controlling enum generation

[`LogicEnum`](https://intel.github.io/rohd-website/docs/logic-enums/) signals generate SystemVerilog enum typedefs and symbolic values by default. Enum generation can be disabled for compatibility with tools or flows that require packed logic:

```dart
final generatedSv = myModule.generateSynth(
configuration: const SystemVerilogSynthesizerConfiguration(
generateEnums: false,
),
);
```

With enum generation disabled, the same design is emitted using ordinary packed logic and numeric values.

## Controlling naming

### Modules
Expand Down
108 changes: 108 additions & 0 deletions doc/user_guide/_docs/A23-logic-enums.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
---
title: "Logic Enums"
permalink: /docs/logic-enums/
excerpt: "Representing enumerable values as hardware signals"
last_modified_at: 2026-08-10
toc: true
---

## Logic Enums

[`LogicEnum<T>`](https://intel.github.io/rohd/rohd/LogicEnum-class.html) is a `Logic` signal constrained to values from a Dart enum. It associates each enum member with a bit-vector encoding and preserves that type information through simulation and SystemVerilog generation.

```dart
enum Operation { idle, read, write }

final operation = LogicEnum(
Operation.values,
name: 'operation',
definitionName: 'Operation',
);
```

The default constructor assigns sequential encodings in the order provided. The width is inferred from the number of values, or it can be set explicitly with `width`.

For sparse or protocol-defined encodings, use `LogicEnum.withMapping`:

```dart
final operation = LogicEnum<Operation>.withMapping(
{
Operation.idle: 0,
Operation.read: 1,
Operation.write: 3,
},
width: 2,
definitionName: 'Operation',
);
```

Mappings must be non-empty and contain unique, valid, non-negative encodings that fit within the signal width. Reading a valid but unmapped bit pattern in simulation produces `x`.

## Using Enum Values

Enum members can be used directly in conditional assignments to a compatible `LogicEnum`:

```dart
Combinational([
If(enable, then: [
operation < Operation.read,
], orElse: [
operation < Operation.idle,
]),
]);
```

Use `getsEnum` for a continuous connection to a constant enum value. In testbench code, `put` and `inject` also accept enum members. The current enum member is available through `valueEnum` when the signal contains a mapped value.

```dart
final constantOperation = operation.clone()
..getsEnum(Operation.write);

operation.inject(Operation.read);
expect(operation.valueEnum, Operation.read);
```

Assignments between `LogicEnum`s require the same Dart enum type, width, and compatible encodings. A destination may have additional mapped values, but every value mapped by the source must have the same encoding in the destination.

## Cases

Enum members can be used as keys when a `LogicEnum` is the selector:

```dart
final selected = cases(operation, {
Operation.idle: idleData,
Operation.read: readData,
Operation.write: writeData,
});
```

The `cases` helper returns an ordinary `Logic`, so bare enum members are not accepted as result or default values. When an enum result is required, provide explicitly mapped `LogicEnum` branch signals and connect the result to a compatible `LogicEnum` destination.

## Module Ports

Use `addTypedInput` and `addTypedOutput` to preserve an enum's mapping across module boundaries:

```dart
final operationIn = addTypedInput('operationIn', operationSource);
final operationOut = addTypedOutput('operationOut', operationIn.clone);

operationOut <= operationIn;
```

Generated SystemVerilog keeps input and output ports packed and uses internal enum-typed backing signals. Typed `LogicEnum` in/out ports are not supported because `LogicEnum` does not currently have a net-backed variant.

## Generated SystemVerilog

By default, SystemVerilog generation emits enum typedefs and symbolic values for `LogicEnum` signals. The `definitionName` supplies the preferred typedef name, and generated names are uniquified when necessary.

Enum generation can be disabled for tools or flows that require ordinary packed logic:

```dart
final generatedSv = module.generateSynth(
configuration: const SystemVerilogSynthesizerConfiguration(
generateEnums: false,
),
);
```

Disabling enum generation changes only the generated representation; simulation behavior and the ROHD model remain typed.
4 changes: 2 additions & 2 deletions lib/rohd.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2021-2023 Intel Corporation
// Copyright (C) 2021-2026 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause

export 'src/exceptions/exceptions.dart';
Expand All @@ -8,7 +8,7 @@ export 'src/interfaces/interfaces.dart';
export 'src/module.dart';
export 'src/modules/modules.dart';
export 'src/selection.dart';
export 'src/signals/signals.dart';
export 'src/signals/signals.dart' hide LogicDef;
export 'src/simulator.dart';
export 'src/swizzle.dart';
export 'src/synthesizers/synthesizers.dart';
Expand Down
Loading
Loading