Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integer #85

Merged
merged 38 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
03fcfcc
integer arithmetic operations
desmonddak Aug 7, 2024
e34ec22
multiplier documentation and generator
desmonddak Aug 7, 2024
bb0326f
spacing issue in doc
desmonddak Aug 7, 2024
e8fd111
dart format
desmonddak Aug 7, 2024
164a215
dart format
desmonddak Aug 7, 2024
31c2a8e
carry_save_multiplier cannot HANDLE different widths
desmonddak Aug 7, 2024
0b4dafc
proper headers
desmonddak Aug 7, 2024
6f4ae41
fixed header comments
desmonddak Aug 7, 2024
9768113
copyright updates
desmonddak Aug 9, 2024
ac60259
convert asserts to exceptions
desmonddak Aug 9, 2024
ae9055f
split/reorganize integer multiplication files
desmonddak Aug 9, 2024
77a47a4
reorganized multiplier code
desmonddak Aug 9, 2024
a7527c0
git failed to add all changes.
desmonddak Aug 9, 2024
fe18879
save issue or git issue
desmonddak Aug 9, 2024
3e29ad1
test cleanup and more reorg of multiplier code
desmonddak Aug 9, 2024
2a29ceb
cleanup compressors
desmonddak Aug 9, 2024
fd46336
kill print statements
desmonddak Aug 9, 2024
e8b96e8
fixed broken multiplier_lib
desmonddak Aug 10, 2024
61521b5
integrated sign extension into PP generation
desmonddak Aug 10, 2024
857b7b7
fixed default arg warning
desmonddak Aug 10, 2024
e449c12
tuned up PP printout with a new LogicValue firstOne extension
desmonddak Aug 11, 2024
5a4cad7
code cleanup, remove print, long lines
desmonddak Aug 11, 2024
32dde50
much cleaner multiply test, sign args
desmonddak Aug 12, 2024
d61c8b0
added test for majority() and fixed. updated LogicValue.firstOne() to…
desmonddak Aug 12, 2024
a26a709
cleanup of API making more methods private, fixing SignMag adder API
desmonddak Aug 13, 2024
7da5003
missed some final fixes
desmonddak Aug 16, 2024
cde1c36
fixed sign-mag to be correct width, fixed tests to be uniquely named
desmonddak Aug 17, 2024
bdd5f9a
reorg and add major multiplier internals documentation
desmonddak Aug 19, 2024
22da93f
remove links for now to pass lint
desmonddak Aug 19, 2024
a4d73b6
major restructuring of partial product compressor classes, documentat…
desmonddak Sep 1, 2024
029c480
simplify doc for multiplier
desmonddak Sep 1, 2024
79118f0
cleaned up interfaces using optional named args adderGen and ppGen, d…
desmonddak Sep 1, 2024
b88fda8
Hid ColumnCompression code, exposed AddendCompressor. General cleanup…
desmonddak Sep 4, 2024
4180ad9
back out AddendCompressor and leave as a ColumnCompressor object gene…
desmonddak Sep 5, 2024
448b4e9
format issue
desmonddak Sep 5, 2024
741e78e
commit to force git to run the job
desmonddak Sep 5, 2024
b32b725
remove unused import
desmonddak Sep 5, 2024
9f7d84d
another unused import
desmonddak Sep 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ You must have [Dart](https://dart.dev/) installed on your system to use ROHD and

#### On your own system

[Visual Studio Code (VSCode)](https://code.visualstudio.com/) is a great IDE for development. You can find installation instructions for VSCode here: <https://code.visualstudio.com/Download>
[Visual Studio Code (VSCode)](https://code.visualstudio.com/) is a great IDE for development. You can find installation instructions for VSCode here: <https://visualstudio.microsoft.com/#vscode-section>

The Dart extension extends VSCode with support for the Dart programming language and provides tools for effectively editing, refactoring and running. Check out the detailed information: <https://dartcode.org/>

Expand Down Expand Up @@ -131,7 +131,7 @@ Please include the SPDX tag near the top of any new files you create:
Here is an example of a recommended file header template:

```dart
// Copyright (C) 2021-2023 Intel Corporation
// Copyright (C) 2021-2024 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause
//
// example.dart
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ Some examples of component categories include:

----------------

Copyright (C) 2023 Intel Corporation
Copyright (C) 2023-2024 Intel Corporation
desmonddak marked this conversation as resolved.
Show resolved Hide resolved
SPDX-License-Identifier: BSD-3-Clause
2 changes: 1 addition & 1 deletion confapp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ flowchart TD;

----------------

Copyright (C) 2023 Intel Corporation
Copyright (C) 2023-2024 Intel Corporation
SPDX-License-Identifier: BSD-3-Clause
2 changes: 1 addition & 1 deletion confapp/lib/app.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2023 Intel Corporation
// Copyright (C) 2023-2024 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause
//
// app.dart
Expand Down
2 changes: 1 addition & 1 deletion confapp/lib/hcl/cubit/component_cubit.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2023 Intel Corporation
// Copyright (C) 2023-2024 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause
//
// component_cubit.dart
Expand Down
2 changes: 1 addition & 1 deletion confapp/lib/hcl/cubit/system_verilog_cubit.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2023 Intel Corporation
// Copyright (C) 2023-2024 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause
//
// system_verilog_cubit.dart
Expand Down
2 changes: 1 addition & 1 deletion confapp/lib/hcl/hcl.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2023 Intel Corporation
// Copyright (C) 2023-2024 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause

export 'view/hcl_page.dart';
2 changes: 1 addition & 1 deletion confapp/lib/hcl/view/hcl_page.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2023 Intel Corporation
// Copyright (C) 2023-2024 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause
//
// hcl_page.dart
Expand Down
2 changes: 1 addition & 1 deletion confapp/lib/hcl/view/hcl_view.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2023 Intel Corporation
// Copyright (C) 2023-2024 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause
//
// hcl_view.dart
Expand Down
2 changes: 1 addition & 1 deletion confapp/lib/hcl/view/screen/content_widget.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2023 Intel Corporation
// Copyright (C) 2023-2024 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause
//
// content_widget.dart
Expand Down
2 changes: 1 addition & 1 deletion confapp/lib/hcl/view/screen/sidebar_widget.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2023 Intel Corporation
// Copyright (C) 2023-2024 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause
//
// sidebar_widget.dart
Expand Down
2 changes: 1 addition & 1 deletion confapp/lib/hcl_bloc_observer.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2023 Intel Corporation
// Copyright (C) 2023-2024 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause
//
// hcl_bloc_observer.dart
Expand Down
2 changes: 1 addition & 1 deletion confapp/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2023 Intel Corporation
// Copyright (C) 2023-2024 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause
//
// main.dart
Expand Down
2 changes: 1 addition & 1 deletion confapp/test/example_component.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2023 Intel Corporation
// Copyright (C) 2023-2024 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause
//
// example_component.dart
Expand Down
2 changes: 1 addition & 1 deletion confapp/test/hcl/view/hcl_page_test.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2023 Intel Corporation
// Copyright (C) 2023-2024 Intel Corporation
// SPDX-License-Identifier: BSD-3-Clause
//
// hcl_page_test.dart
Expand Down
11 changes: 8 additions & 3 deletions doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Below is a list of components grouped by category. Ones with links are documented and completed, while others are still in planning or development stages.

Some in-development items will have opened issues, as well. Feel free to create a pull request or file issues to add more ideas to this list. If you plan to develop and contribute a component, please be sure to open an issue so that there's not multiple people working on the same thing. Make sure to check if someone else has an open issue for a certain component before starting.
Some in-development items will have opened issues, as well. Feel free to create a pull request or file issues to add more ideas to this list. If you plan to develop and contribute a component, please be sure to open an issue so that there are not multiple people working on the same thing. Make sure to check if someone else has an open issue for a certain component before starting.

- Encoders & Decoders
- [1-hot to Binary](./components/onehot.md)
Expand All @@ -25,18 +25,23 @@ Some in-development items will have opened issues, as well. Feel free to create
- Find maximum
- Find N'th pattern from the start/end
- Count
- [Count bit occurence](./components/count.md)
- Count pattern occurence
- [Count bit occurrence](./components/count.md)
- Count pattern occurrence
- Detection
- [Edge detection](./components/edge_detector.md)
- Sort
- [Bitonic sort](./components/sort.md#bitonic-sort)
- Arithmetic
- [Prefix Trees](./components/parallel_prefix_operations.md)
- [Adders](./components/adder.md)
- [Sign Magnitude Adder](./components/adder.md#ripple-carry-adder)
- Subtractors
- [One's Complement Adder Subtractor](./components/adder.md#ones-complement-adder-subtractor)
- Multipliers
- [Pipelined Integer Multiplier](./components/multiplier.md#carry-save-multiplier)
- [Compression Tree Multiplier](./components/multiplier.md#compression-tree-multiplier)
- [Compression Tree Multiply-Accumulate](./components/multiplier.md#compression-tree-multiply-accumulate)
- [Booth Encoding and Compression Components](./components/multiplier_components.md)
- Dividers
- Log
- Square root
Expand Down
84 changes: 82 additions & 2 deletions doc/components/adder.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# Adder

ROHD HCL provides an adder module to get the sum from a list of logic. As of now, we have
ROHD-HCL provides a set of adder modules to get the sum from a pair of Logic. As of now, we have

- [Ripple Carry Adder](#ripple-carry-adder)
- [Parallel Prefix Adder](#parallel-prefix-adder)
- [One's Complement Adder Subtractor](#ones-complement-adder-subtractor)
- [Sign Magnitude Adder](#sign-magnitude-adder)

## Ripple Carry Adder

A ripple carry adder is a digital circuit used for binary addition. It consists of a series of full adders connected in a chain, with the carry output of each adder linked to the carry input of the next one. Starting from the least significant bit (LSB) to most significant bit (MSB), the adder sequentially adds corresponding bits of two binary numbers.

The [`RippleCarryAdder`](https://intel.github.io/rohd-hcl/rohd_hcl/RippleCarryAdder-class.html) module in ROHD-HCL accept input `Logic`s a and b as the input pin and the name of the module `name`. Note that the width of the inputs must be the same or a `RohdHclException` will be thrown.
The [`RippleCarryAdder`](https://intel.github.io/rohd-hcl/rohd_hcl/RippleCarryAdder-class.html) module in ROHD-HCL accept input `Logic`s a and b as the input pin and the name of the module `name`. Note that the width of the inputs must be the same or a `RohdHclException` will be thrown.

An example is shown below to add two inputs of signals that have 8-bits of width.

Expand All @@ -22,3 +25,80 @@ b.put(5);
final rippleCarryAdder = RippleCarryAdder(a, b);
final sum = rippleCarryAdder.sum;
```

## Parallel Prefix Adder

A parallel prefix adder is an adder that uses different varieties of a parallel prefix tree (see `Parallel Prefix Operations`) to efficiently connect a set of `Full Adder` circuits to form a complete adder.

Here is an example of instantiating a `ParallelPrefixAdder`:

```dart
const width = 6;
final a = Logic(name: 'a', width: width);
final b = Logic(name: 'b', width: width);

a.put(18);
b.put(24);

final adder = ParallelPrefixAdder(a, b, ppGen: BrentKung.new);

final sum = adder.sum;

print('${sum.value.toBigInt()}');
```

## One's Complement Adder Subtractor

A ones-complement adder (and subtractor) is useful in efficient arithmetic operations as the
end-around carry can be bypassed and used later.

The `OnesComplementAdder` can take a subtraction command as either a Logic `subtractIn` or a boolean `subtract` (the Logic overrides the boolean). If Logic `carry` is provided, the end-around carry is output on `carry` and the value will be one less than expected when `carry` is high. An `adderGen` adder function can be provided that generates your favorite internal adder (such as a parallel prefix adder).

The output of `OnesComplementAdder` is a `sum` which is the magnitude and a `sign`.

Here is an example of instantiating a `OnesComplementAdder` as a subtractor, but saving the `carry`:

```dart
const width = 4;
final a = Logic(width: width);
final b = Logic(width: width);

a.put(av);
b.put(bv);
final carry = Logic();
final adder = OnesComplementAdder(
a, b, carryOut: carry, adderGen: RippleCarryAdder.new,
subtract: true);
final mag = adder.sum.value.toInt() + (carry.value.isZero ? 0 : 1));
final out = (adder.sign.value.toInt() == 1 ? -mag : mag);
```

## Sign Magnitude Adder

A sign magnitude adder is useful in situations where the sign of the addends is separated from their magnitude (e.g., not 2s complement), such as in floating point multipliers. The `SignMagnitudeAdder` inherits from `Adder` but adds the `Logic` inputs for the two operands.

If you can supply the largest magnitude number first, then you can disable a comparator generation inside by declaring the `largestMagnitudeFirst` option as true.

The `SignMagnitudeAdder` uses a `OnesComplementAdder` internally.

Here is an example of instantiating a `SignMagnitudeAdder`:

```dart
const width = 6;
final aSign = Logic(name: 'aSign');
final a = Logic(name: 'a', width: width);
final bSign = Logic(name: 'bSign');
final b = Logic(name: 'b', width: width);

aSign.put(1);
a.put(24);
b.put(18);
bSign.put(0);

final adder = SignMagnitudeAdder(aSign, a, bSign, b, adderGen: RippleCarryAdder.new,
largestMagnitudeFirst: true);

final sum = adder.sum;

print('${sum.value.toBigInt()}');
```
2 changes: 1 addition & 1 deletion doc/components/arbiter.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Arbiters

ROHD HCL implements a generic `abstract` [`Arbiter`](https://intel.github.io/rohd-hcl/rohd_hcl/Arbiter-class.html) class that other arbiters can extend. It accepts a `List` of `requests`, where each request is a `1-bit` signal indicating that there is a request for a resource. The output `grants` is a `List` where each element corresponds to the request with the same index. The arbiter implementation decides how to select which request receives a grant.
ROHD-HCL implements a generic `abstract` [`Arbiter`](https://intel.github.io/rohd-hcl/rohd_hcl/Arbiter-class.html) class that other arbiters can extend. It accepts a `List` of `requests`, where each request is a `1-bit` signal indicating that there is a request for a resource. The output `grants` is a `List` where each element corresponds to the request with the same index. The arbiter implementation decides how to select which request receives a grant.

## Stateful Arbiter

Expand Down
2 changes: 1 addition & 1 deletion doc/components/binary_gray.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Binary Gray

ROHD HCL provides a module to perform conversion on binary to gray and gray to binary.
ROHD-HCL provides a module to perform conversion on binary to gray and gray to binary.

## Binary-to-Gray

Expand Down
4 changes: 2 additions & 2 deletions doc/components/count.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Count

ROHD HCL comes with a `Count` component. The detailed API docs are available [here](https://intel.github.io/rohd-hcl/rohd_hcl/rohd_hcl-library.html).
ROHD-HCL comes with a `Count` component. The detailed API docs are available [here](https://intel.github.io/rohd-hcl/rohd_hcl/rohd_hcl-library.html).

A `Count` will count all one(`1`)/zero(`0`) within a given Logic `bus`.

Expand All @@ -12,7 +12,7 @@ This will return a Logic value labeled as `countOne` for `1` and `countZero` for

## Count One

To count all ones just pass in the `bus` with `countOne` as `true`. By default countOne is `true`.
To count all ones just pass in the `bus` with `countOne` as `true`. By default, `countOne` is `true`.

## Count Zero

Expand Down
2 changes: 1 addition & 1 deletion doc/components/edge_detector.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Edge Detection

The `EdgeDetector` is a simple utility to determine whether the current value of a 1-bit signal is different from the value in the previous cycle. It is a fully synchronous design, so it does not asynchronously detect edges. It optionally supports a reset, with an optional reset value. It can be configured to detect positive, negative, or "any" edges.
The `EdgeDetector` is a simple utility to determine whether the current value of a 1-bit signal is different from the value in the previous cycle. It is a fully synchronous design, so it does not asynchronously detect edges. It optionally supports a reset, with an optional reset value. Furthermore, it can be configured to detect positive, negative, or "any" edges.
4 changes: 2 additions & 2 deletions doc/components/fifo.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# FIFO

ROHD HCL comes with a simple FIFO (First In, First Out). The detailed API docs are available [here](https://intel.github.io/rohd-hcl/rohd_hcl/Fifo-class.html).
ROHD-HCL comes with a simple FIFO (First In, First Out). The detailed API docs are available [here](https://intel.github.io/rohd-hcl/rohd_hcl/Fifo-class.html).

The underlying implementation uses a flop-based memory (see [`RegisterFile`](https://intel.github.io/rohd-hcl/rohd_hcl/RegisterFile-class.html)) to store data until it is ready to be popped, with independent read and write pointers.

Expand Down Expand Up @@ -40,7 +40,7 @@ The FIFO comes with both a checker and a tracker that you can leverage in your t

### Checker

The `FifoChecker` is a ROHD-VF component which will watch for proper usge of a FIFO in your simulation. It is intended to check usage, not the internal workings of the FIFO, which are already pre-validated in the unit tests. This means it covers things like underflow, overflow, and that the FIFO is empty at the end of the test.
The `FifoChecker` is a ROHD-VF component which will watch for proper usage of a FIFO in your simulation. It is intended to check usage, not the internal workings of the FIFO, which are already pre-validated in the unit tests. This means it covers things like underflow, overflow, and that the FIFO is empty at the end of the test.

### Tracker

Expand Down
4 changes: 2 additions & 2 deletions doc/components/find.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Find

ROHD HCL comes with a Find. The detailed API docs are available [here](https://intel.github.io/rohd-hcl/rohd_hcl/rohd_hcl-library.html).
ROHD-HCL comes with a Find. The detailed API docs are available [here](https://intel.github.io/rohd-hcl/rohd_hcl/rohd_hcl-library.html).

A Find will search for first/nth occurrence of one(`1`)/zero(`0`) within a given Logic `bus`.
The underlying implementation uses a `Count` to count 1's or 0's whenever a Logic `n` value
Expand All @@ -10,7 +10,7 @@ It takes a Binary Logic `bus` and finds the position of any one or zero within t
That is to say, By default a Find will go for finding the first occurrence when no `n` is passed. In addition, with `countOne` which is set as `true` by default to
search only one (`1`). Both boolean `countOne` and Logic `n` are optional. Only Logic `bus` is mandatory argument.

This has an output pin named as `find`, for the index position on the occurrence searched (`1`s or `0`s) taken from the LSB (Least significant bit).
This has an output pin named as `find`, for the index position on the occurrence searched (`1`s or `0`s) taken from the LSB (Least Significant Bit).

## Find First

Expand Down
2 changes: 1 addition & 1 deletion doc/components/memory.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Memory

ROHD HCL provides a generic `abstract` [`Memory`](https://intel.github.io/rohd-hcl/rohd_hcl/Memory-class.html) class which accepts a dynamic number of `writePorts` and `readPorts`, where each port is of type [`DataPortInterface`](https://intel.github.io/rohd-hcl/rohd_hcl/DataPortInterface-class.html). A `DataPortInterface` is a simple interface with `en` and `addr` as `control` signals and `data` signal(s). In a write interface, all signals are in the same direction. In a read interface, the `control` signals are in the opposite direction of the `data` signal(s).
ROHD-HCL provides a generic `abstract` [`Memory`](https://intel.github.io/rohd-hcl/rohd_hcl/Memory-class.html) class which accepts a dynamic number of `writePorts` and `readPorts`, where each port is of type [`DataPortInterface`](https://intel.github.io/rohd-hcl/rohd_hcl/DataPortInterface-class.html). A `DataPortInterface` is a simple interface with `en` and `addr` as `control` signals and `data` signal(s). In a write interface, all signals are in the same direction. In a read interface, the `control` signals are in the opposite direction of the `data` signal(s).

## Masks

Expand Down
Loading
Loading