Skip to content

Commit

Permalink
reorganized multiplier code
Browse files Browse the repository at this point in the history
  • Loading branch information
desmonddak committed Aug 9, 2024
1 parent ae9055f commit 77a47a4
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) 2024 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause
//
// compressor.dart
// addend_compressor.dart
// Column compression of partial prodcuts
//
// 2024 June 04
Expand All @@ -11,12 +11,13 @@ import 'dart:io';
import 'package:collection/collection.dart';
import 'package:meta/meta.dart';
import 'package:rohd/rohd.dart';
import 'package:rohd_hcl/rohd_hcl.dart';
import 'package:rohd_hcl/src/arithmetic/multiplier_lib.dart';
import 'package:rohd_hcl/src/utils.dart';

// TODO(desmonddak): Logic and LogicValue majority() functions

/// Base class for column compressor function
abstract class Compressor extends Module {
abstract class AddendCompressor extends Module {
/// Input bits to compress
@protected
late final Logic compressBits;
Expand All @@ -28,7 +29,7 @@ abstract class Compressor extends Module {
Logic get carry => output('carry');

/// Construct a column compressor
Compressor(Logic compressBits) {
AddendCompressor(Logic compressBits) {
this.compressBits = addInput(
'compressBits',
compressBits,
Expand All @@ -40,7 +41,7 @@ abstract class Compressor extends Module {
}

/// 2-input column compressor (half-adder)
class Compressor2 extends Compressor {
class Compressor2 extends AddendCompressor {
/// Construct a 2-input compressor (half-adder)
Compressor2(super.compressBits) {
sum <= compressBits.xor();
Expand All @@ -49,7 +50,7 @@ class Compressor2 extends Compressor {
}

/// 3-input column compressor (full-adder)
class Compressor3 extends Compressor {
class Compressor3 extends AddendCompressor {
/// Construct a 3-input column compressor (full-adder)
Compressor3(super.compressBits) {
sum <= compressBits.xor();
Expand Down Expand Up @@ -298,7 +299,7 @@ class ColumnCompressor {
final first = queue.removeFirst();
final second = queue.removeFirst();
final inputs = <CompressTerm>[first, second];
Compressor compressor;
AddendCompressor compressor;
if (depth > 3) {
inputs.add(queue.removeFirst());
compressor =
Expand Down
2 changes: 1 addition & 1 deletion lib/src/arithmetic/multiplicand_selector.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import 'package:rohd/rohd.dart';
import 'package:rohd_hcl/rohd_hcl.dart';
import 'package:rohd_hcl/src/arithmetic/multiplier_encoder.dart';
import 'package:rohd_hcl/src/arithmetic/multiplier_lib.dart';

/// A class accessing the multiples of the multiplicand at a position
class MultiplicandSelector {
Expand Down
1 change: 1 addition & 0 deletions lib/src/arithmetic/multiplier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import 'package:meta/meta.dart';
import 'package:rohd/rohd.dart';
import 'package:rohd_hcl/rohd_hcl.dart';
import 'package:rohd_hcl/src/arithmetic/multiplier_lib.dart';

/// An abstract class for all multiplier implementations.
abstract class Multiplier extends Module {
Expand Down
15 changes: 15 additions & 0 deletions lib/src/arithmetic/multiplier_lib.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (C) 2024 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause
//
// multiplier_lib.dart
// Consolidate exports of the main components for multiplication: encoder,
// selector, partial_product_generator, compressor
//
// 2024 August 9
// Author: Desmond Kirkpatrick <[email protected]>
//
//

// Just exporting encoder exports all the symbols we use
export './compressor.dart';
export './multiplier_encoder.dart';
1 change: 1 addition & 0 deletions lib/src/arithmetic/partial_product_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'dart:math';

import 'package:rohd/rohd.dart';
import 'package:rohd_hcl/rohd_hcl.dart';
import 'package:rohd_hcl/src/arithmetic/multiplier_lib.dart';

/// A class that generates a set of partial products. Essentially a set of
/// shifted rows of [Logic] addends generated by Booth recoding and
Expand Down

0 comments on commit 77a47a4

Please sign in to comment.