-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
1,676 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{{flutter_js}} | ||
{{flutter_build_config}} | ||
_flutter.loader.load({ | ||
serviceWorkerSettings: { | ||
serviceWorkerVersion: {{flutter_service_worker_version}}, | ||
}, | ||
onEntrypointLoaded: function(engineInitializer) { | ||
engineInitializer.initializeEngine().then(function(appRunner) { | ||
appRunner.runApp(); | ||
}); | ||
}, | ||
config: { | ||
canvasKitBaseUrl: 'canvaskit/', | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Summation | ||
|
||
ROHD-HCL comes with combinational and sequential components for summing any number of input values, including support for increment/decrement and saturation/roll-over behavior. | ||
|
||
## SumInterface | ||
|
||
The `SumInterface` is shared between [`Sum`](#sum) and [`Counter`](#counter) components and represents a single element to be summed. Each instance of a `SumInterface` has an associated `amount`, which could either be a fixed constant value (`fixedAmount`) or a dynamic `Logic`. Fixed amounts will do some automatic width inference, unless a `width` is specified. The interface can also optionally include an enable signal. It is implemented as a `PairInterface` where all ports are `fromProvider`. Each interface may be either incrementing or decrementing. | ||
|
||
```dart | ||
// An interface with a dynamic 4-bit amount to increment by | ||
SumInterface(width: 4); | ||
``` | ||
|
||
## Sum | ||
|
||
The `Sum` component takes a list of `SumInterface`s and adds them all up. The `saturates` configuration enables saturation behavior, otherwise there will be roll-over at overflow/underflow of the counter at `minValue` and `maxValue`. The sum can also be given an `initialValue` to start at. | ||
|
||
Internally, the `Sum` component builds a wider bus which is large enough to hold the biggest possible intermediate value during summation before consideration of overflow and saturation. | ||
|
||
Note that the implementation's size and complexity when synthesized depend significantly on the configuration. For example, if everything is a nice power-of-2 number, then the logic is much simpler than otherwise where hardware modulos may be required to properly handle roll-over/under scenarios. | ||
|
||
A simpler `Sum.ofLogics` constructor has less configurability, but can be passed a simple `List<Logic>` without needing to construct per-element interfaces. | ||
|
||
```dart | ||
// An 8-bit sum of a list of `SumInterface`s | ||
Sum(intfs, width: 8); | ||
``` | ||
|
||
## Counter | ||
|
||
The `Counter` component is a similarly configurable version of the `Sum` which maintains a sequential element to store the previous value. | ||
|
||
One additional nice feature of the `Counter` is that it supports a `restart` in addition to the normal `reset`. While `reset` will reset the internal flops, `restart` will re-initialize the internal `Sum` back to the reset value, but still perform the computation on inputs in the current cycle. This is especially useful in case you want to restart a counter while events worth counting may still be occuring. | ||
|
||
The `Counter` also has a `Counter.simple` constructor which is intended for very basic scenarios like "count up by 1 each cycle". | ||
|
||
```dart | ||
// A counter which increments by 1 each cycle up to 5, then rolls over. | ||
Counter.simple(clk: clk, reset: reset, maxValue: 5); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
144 changes: 144 additions & 0 deletions
144
lib/src/component_config/components/config_summation.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
// Copyright (C) 2024 Intel Corporation | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// | ||
// config_summation.dart | ||
// Configurators for summation. | ||
// | ||
// 2024 September 6 | ||
// Author: Max Korbel <[email protected]> | ||
|
||
import 'package:rohd/rohd.dart'; | ||
import 'package:rohd_hcl/rohd_hcl.dart'; | ||
import 'package:rohd_hcl/src/summation/summation_base.dart'; | ||
|
||
/// A knob for a single sum interface. | ||
class SumInterfaceKnob extends GroupOfKnobs { | ||
/// Whether the sum interface has an enable signal. | ||
ToggleConfigKnob hasEnableKnob = ToggleConfigKnob(value: false); | ||
|
||
/// Whether the sum interface has a fixed value. | ||
ToggleConfigKnob isFixedValueKnob = ToggleConfigKnob(value: false); | ||
|
||
/// The fixed value of the sum interface, only present when [isFixedValueKnob] | ||
/// is true. | ||
IntConfigKnob fixedValueKnob = IntConfigKnob(value: 1); | ||
|
||
/// The width of the sum interface. | ||
IntOptionalConfigKnob widthKnob = IntOptionalConfigKnob(value: 8); | ||
|
||
/// Whether the sum interface increments (vs. decrements). | ||
ToggleConfigKnob incrementsKnob = ToggleConfigKnob(value: true); | ||
|
||
/// Creates a new sum interface knob. | ||
SumInterfaceKnob() : super({}, name: 'Sum Interface'); | ||
|
||
@override | ||
Map<String, ConfigKnob<dynamic>> get subKnobs => { | ||
'Has Enable': hasEnableKnob, | ||
'Is Fixed Value': isFixedValueKnob, | ||
if (isFixedValueKnob.value) 'Fixed Value': fixedValueKnob, | ||
'Width': widthKnob, | ||
'Increments': incrementsKnob, | ||
}; | ||
} | ||
|
||
/// A configurator for a module like [SummationBase]. | ||
abstract class SummationConfigurator extends Configurator { | ||
/// The interface knobs. | ||
final ListOfKnobsKnob sumInterfaceKnobs = ListOfKnobsKnob( | ||
count: 1, | ||
generateKnob: (i) => SumInterfaceKnob(), | ||
name: 'Sum Interfaces', | ||
); | ||
|
||
/// The width. | ||
final IntOptionalConfigKnob widthKnob = IntOptionalConfigKnob(value: null); | ||
|
||
/// The minimum value. | ||
final IntOptionalConfigKnob minValueKnob = IntOptionalConfigKnob(value: 0); | ||
|
||
/// The maximum value. | ||
final IntOptionalConfigKnob maxValueKnob = IntOptionalConfigKnob(value: null); | ||
|
||
/// Whether the output saturates (vs. rolling over/under). | ||
final ToggleConfigKnob saturatesKnob = ToggleConfigKnob(value: false); | ||
|
||
@override | ||
Map<String, ConfigKnob<dynamic>> get knobs => { | ||
'Sum Interfaces': sumInterfaceKnobs, | ||
'Width': widthKnob, | ||
'Minimum Value': minValueKnob, | ||
'Maximum Value': maxValueKnob, | ||
'Saturates': saturatesKnob, | ||
}; | ||
} | ||
|
||
/// A configurator for [Sum]. | ||
class SumConfigurator extends SummationConfigurator { | ||
/// The initial value. | ||
final IntConfigKnob initialValueKnob = IntConfigKnob(value: 0); | ||
|
||
@override | ||
Map<String, ConfigKnob<dynamic>> get knobs => { | ||
...super.knobs, | ||
'Initial Value': initialValueKnob, | ||
}; | ||
|
||
@override | ||
Module createModule() => Sum( | ||
sumInterfaceKnobs.knobs | ||
.map((e) => e as SumInterfaceKnob) | ||
.map((e) => SumInterface( | ||
hasEnable: e.hasEnableKnob.value, | ||
fixedAmount: | ||
e.isFixedValueKnob.value ? e.fixedValueKnob.value : null, | ||
width: e.widthKnob.value, | ||
increments: e.incrementsKnob.value, | ||
)) | ||
.toList(), | ||
initialValue: initialValueKnob.value, | ||
width: widthKnob.value, | ||
minValue: minValueKnob.value, | ||
maxValue: maxValueKnob.value, | ||
saturates: saturatesKnob.value, | ||
); | ||
|
||
@override | ||
String get name => 'Sum'; | ||
} | ||
|
||
/// A configurator for [Counter]. | ||
class CounterConfigurator extends SummationConfigurator { | ||
/// The reset value. | ||
final IntConfigKnob resetValueKnob = IntConfigKnob(value: 0); | ||
|
||
@override | ||
Map<String, ConfigKnob<dynamic>> get knobs => { | ||
...super.knobs, | ||
'Reset Value': resetValueKnob, | ||
}; | ||
|
||
@override | ||
Module createModule() => Counter( | ||
sumInterfaceKnobs.knobs | ||
.map((e) => e as SumInterfaceKnob) | ||
.map((e) => SumInterface( | ||
hasEnable: e.hasEnableKnob.value, | ||
fixedAmount: | ||
e.isFixedValueKnob.value ? e.fixedValueKnob.value : null, | ||
width: e.widthKnob.value, | ||
increments: e.incrementsKnob.value, | ||
)) | ||
.toList(), | ||
resetValue: resetValueKnob.value, | ||
width: widthKnob.value, | ||
minValue: minValueKnob.value, | ||
maxValue: maxValueKnob.value, | ||
saturates: saturatesKnob.value, | ||
clk: Logic(), | ||
reset: Logic(), | ||
); | ||
|
||
@override | ||
String get name => 'Counter'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.