-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
starting on configurator for counter and sum
- Loading branch information
Showing
7 changed files
with
112 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (C) 2024 Intel Corporation | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// | ||
// config_counter.dart | ||
// Configurator for a Counter. | ||
// | ||
// 2024 September 6 | ||
// Author: Max Korbel <[email protected]> | ||
|
||
import 'package:rohd_hcl/rohd_hcl.dart'; | ||
|
||
class SumInterfaceKnob extends GroupOfKnobs { | ||
ToggleConfigKnob hasEnableKnob = ToggleConfigKnob(value: false); | ||
|
||
ToggleConfigKnob isFixedValueKnob = ToggleConfigKnob(value: false); | ||
|
||
IntOptionalConfigKnob widthKnob = IntOptionalConfigKnob(value: 8); | ||
|
||
SumInterfaceKnob() : super({}); | ||
|
||
@override | ||
Map<String, ConfigKnob<dynamic>> get subKnobs => { | ||
'Has Enable': hasEnableKnob, | ||
'Is Fixed Value': isFixedValueKnob, | ||
'Width': widthKnob, | ||
}; | ||
} | ||
|
||
// class CounterConfigurator extends Configurator {} |
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
50 changes: 50 additions & 0 deletions
50
lib/src/component_config/config_knobs/int_optional_config_knob.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,50 @@ | ||
// Copyright (C) 2024 Intel Corporation | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// | ||
// int_optional_config_knob.dart | ||
// A knob for holding a number or null. | ||
// | ||
// 2024 September 9 | ||
|
||
import 'package:rohd_hcl/rohd_hcl.dart'; | ||
|
||
/// A knob to store an [int]. | ||
class IntOptionalConfigKnob extends TextConfigKnob<int?> { | ||
/// Creates a new config knob with the specified initial [value]. | ||
IntOptionalConfigKnob({required super.value}); | ||
|
||
@override | ||
Map<String, dynamic> toJson() => { | ||
'value': value == null | ||
? null | ||
: value! > 255 | ||
? '0x${value!.toRadixString(16)}' | ||
: value | ||
}; | ||
|
||
@override | ||
String get valueString => value == null | ||
? '' | ||
: value! > 255 | ||
? '0x${value!.toRadixString(16)}' | ||
: value.toString(); | ||
|
||
@override | ||
bool get allowEmpty => true; | ||
|
||
@override | ||
void loadJson(Map<String, dynamic> decodedJson) { | ||
final val = decodedJson['value']; | ||
if (val == null) { | ||
value = null; | ||
} else if (val is String) { | ||
if (val.isEmpty) { | ||
value = null; | ||
} else { | ||
value = int.parse(val); | ||
} | ||
} else { | ||
value = val as int; | ||
} | ||
} | ||
} |
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
22 changes: 22 additions & 0 deletions
22
lib/src/component_config/config_knobs/text_config_knob.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,22 @@ | ||
// Copyright (C) 2024 Intel Corporation | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// | ||
// text_config_knob.dart | ||
// Definition of a configuration knob which can be configured by parsing text. | ||
// | ||
// 2023 December 5 | ||
|
||
import 'package:rohd_hcl/rohd_hcl.dart'; | ||
|
||
/// A configuration knob for use in [Configurator]s which can be configured by | ||
/// text. | ||
abstract class TextConfigKnob<T> extends ConfigKnob<T> { | ||
/// Creates a new knob with an initial [value]. | ||
TextConfigKnob({required super.value}); | ||
|
||
/// A [String] representation of the [value]. | ||
String get valueString => value.toString(); | ||
|
||
/// Whether the knob allows an empty string as input. | ||
bool get allowEmpty => false; | ||
} |