From f1d1a3eb1a4e41847207d173b5960e3f36dd4ec2 Mon Sep 17 00:00:00 2001 From: "Desmond A. Kirkpatrick" Date: Mon, 30 Sep 2024 23:57:32 -0700 Subject: [PATCH] added fp documentation --- doc/components/floating_point.md | 23 +++++++++++++++++++ .../arithmetic/evaluate_partial_product.dart | 6 ----- 2 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 doc/components/floating_point.md diff --git a/doc/components/floating_point.md b/doc/components/floating_point.md new file mode 100644 index 000000000..203e72d6d --- /dev/null +++ b/doc/components/floating_point.md @@ -0,0 +1,23 @@ +# Floating-Point Components + +Floating-point operations require meticulous precision, and have standards like [IEEE-754]() which govern them. To support floating-point components, we have created a parallel to `Logic`/`LogicValue` which are part of [ROHD](). 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 diff --git a/lib/src/arithmetic/evaluate_partial_product.dart b/lib/src/arithmetic/evaluate_partial_product.dart index 6bd3e6c2a..f684b0bfa 100644 --- a/lib/src/arithmetic/evaluate_partial_product.dart +++ b/lib/src/arithmetic/evaluate_partial_product.dart @@ -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--) {