diff --git a/lib/src/component_config/components/component_registry.dart b/lib/src/component_config/components/component_registry.dart index 4a9ae2598..f25d00b0a 100644 --- a/lib/src/component_config/components/component_registry.dart +++ b/lib/src/component_config/components/component_registry.dart @@ -22,5 +22,6 @@ List get componentRegistry => [ OneHotConfigurator(), RegisterFileConfigurator(), EdgeDetectorConfigurator(), + FindConfigurator(), ParallelPrefixAdderConfigurator(), ]; diff --git a/lib/src/component_config/components/components.dart b/lib/src/component_config/components/components.dart index 0548c89fe..899a8ec0a 100644 --- a/lib/src/component_config/components/components.dart +++ b/lib/src/component_config/components/components.dart @@ -5,6 +5,7 @@ export 'config_carry_save_multiplier.dart'; export 'config_ecc.dart'; export 'config_edge_detector.dart'; export 'config_fifo.dart'; +export 'config_find.dart'; export 'config_one_hot.dart'; export 'config_parallel_prefix_adder.dart'; export 'config_priority_arbiter.dart'; diff --git a/lib/src/component_config/components/config_edge_detector.dart b/lib/src/component_config/components/config_edge_detector.dart index ec061ea31..7e636a9b6 100644 --- a/lib/src/component_config/components/config_edge_detector.dart +++ b/lib/src/component_config/components/config_edge_detector.dart @@ -31,6 +31,7 @@ class EdgeDetectorConfigurator extends Configurator { Logic(), clk: Logic(), reset: hasResetKnob.value ? Logic() : null, + edgeType: edgeTypeKnob.value, resetValue: hasResetKnob.value ? resetValueKnob.value == 'Input' ? Logic() diff --git a/lib/src/component_config/components/config_find.dart b/lib/src/component_config/components/config_find.dart new file mode 100644 index 000000000..a48603c01 --- /dev/null +++ b/lib/src/component_config/components/config_find.dart @@ -0,0 +1,49 @@ +// Copyright (C) 2024 Intel Corporation +// SPDX-License-Identifier: BSD-3-Clause +// +// config_priority_arbiter.dart +// Configurator for a PriorityArbiter. +// +// 2024 February 7 +// Author: Max Korbel + +import 'dart:collection'; + +import 'package:rohd/rohd.dart'; +import 'package:rohd_hcl/rohd_hcl.dart'; + +/// A [Configurator] for [Find]. +class FindConfigurator extends Configurator { + /// A knob controlling the width of the bus. + final IntConfigKnob busWidthKnob = IntConfigKnob(value: 8); + + /// A knob controlling whether it should count ones or zeros. + final ToggleConfigKnob countOneKnob = ToggleConfigKnob(value: true); + + /// A knob controlling the generation of an error signal. + final ToggleConfigKnob generateErrorKnob = ToggleConfigKnob(value: false); + + /// A knob controlling whether it should have `n` as an input. + final ToggleConfigKnob includeNKnob = ToggleConfigKnob(value: false); + + @override + late final Map> knobs = UnmodifiableMapView({ + 'Bus Width': busWidthKnob, + 'Count Ones': countOneKnob, + 'Generate Error': generateErrorKnob, + 'Include N': includeNKnob, + }); + + @override + Module createModule() => Find( + Logic(width: busWidthKnob.value), + countOne: countOneKnob.value, + generateError: generateErrorKnob.value, + n: includeNKnob.value + ? Logic(width: log2Ceil(busWidthKnob.value)) + : null, + ); + + @override + final String name = 'Find'; +} diff --git a/test/configurator_test.dart b/test/configurator_test.dart index d65d36cfa..8cd6155ac 100644 --- a/test/configurator_test.dart +++ b/test/configurator_test.dart @@ -258,6 +258,14 @@ void main() { expect(sv, contains('input logic [15:0] transmission')); }); + test('find configurator', () async { + final cfg = FindConfigurator(); + cfg.includeNKnob.value = true; + cfg.generateErrorKnob.value = true; + final sv = await cfg.generateSV(); + expect(sv, contains('module Find')); + }); + test('prefix tree adder configurator', () async { final cfg = ParallelPrefixAdderConfigurator(); // final json = cfg.toJson(pretty: true);