Skip to content

Commit

Permalink
Find Configurator (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkorbel1 authored Feb 7, 2024
1 parent 8beecb7 commit 52e0433
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ List<Configurator> get componentRegistry => [
OneHotConfigurator(),
RegisterFileConfigurator(),
EdgeDetectorConfigurator(),
FindConfigurator(),
ParallelPrefixAdderConfigurator(),
];
1 change: 1 addition & 0 deletions lib/src/component_config/components/components.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
49 changes: 49 additions & 0 deletions lib/src/component_config/components/config_find.dart
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>

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<String, ConfigKnob<dynamic>> 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';
}
8 changes: 8 additions & 0 deletions test/configurator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 52e0433

Please sign in to comment.