Skip to content

Commit

Permalink
added fp documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
desmonddak committed Oct 1, 2024
1 parent cfa4e17 commit f1d1a3e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
23 changes: 23 additions & 0 deletions doc/components/floating_point.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Floating-Point Components

Floating-point operations require meticulous precision, and have standards like [IEEE-754](<https://standards.ieee.org/ieee/754/6210/>) which govern them. To support floating-point components, we have created a parallel to `Logic`/`LogicValue` which are part of [ROHD](<https://intel.github.io/rohd-website/>). Here, `FloatingPoint` is the `Logic` wire in a component that carries `FloatingPointValue` literal values. An important distinction is that these classes are parameterized to create arbitrary size floating-point values.

## FloatingPointValue

The `FloatingPointValue` class comprises the sign, exponent, and mantissa `LogicValue`s that represent a floating-point number. `FloatingPointValue`s can be converted to and from Dart native `Double`s, as well as constructed from integer and string representations of their fields. They can be operated on (+, -, *, /) and compared.

The various IEEE constants representing corner cases of the field of floating-point values for a given size of `FloatingPointValue`: infinities, zeros, limits for normal (e.g. mantissa in the range of [1,2]) and sub-normal numbers (zero exponent, and mantissa <1).

Appropriate string representations, comparison operations, and operators are available. The usefulness of `FloatingPointValue` is in the testing of `FloatingPoint` components, where we can leverage the abstraction of a floating-point value type to drive and compare floating-point values operated upon by floating-point components.

As 32-bit single precision and 64-bit double-precision floating-point types are most common, we have `FloatingPoint32Value` and `FloatingPoint64Value` subclasses with direct converters from Dart native Double.

Finally, we have a `FloatingPointValue` random generator for testing purposes, generating valid floating-point types, optionally constrained to normal range (mantissa in [1, 2)).

## FloatingPoint

The `FloatingPoint` type is a `LogicStructure` which comprises the `Logic` bits for the sign, exponent, and mantissa used in hardware floating-point. These types are provided to simplify and abstract the declaration and manipulation of floating-point types in hardware. This type is parameterized like `FloatingPointValue`, for exponent and mantissa width.

Again, like `FloatingPointValue`, `FloatingPoint64` and `FloatingPoint32` subclasses are provided as these are the most common floating-point number types.

## FloatingPointAdder
6 changes: 0 additions & 6 deletions lib/src/arithmetic/evaluate_partial_product.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,6 @@ extension EvaluateLivePartialProduct on PartialProductGenerator {
final str = StringBuffer();

final maxW = maxWidth();
final nonSignExtendedPad = isSignExtended
? 0
: shift > 2
? shift - 1
: 1;

// print bit position header
str.write('| R | M | S');
for (var i = maxW - 1; i >= 0; i--) {
Expand Down

0 comments on commit f1d1a3e

Please sign in to comment.