-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extensive fp cleanup, support of Inf/NaN, addition of simple fp multi…
…plier
- Loading branch information
Showing
28 changed files
with
2,083 additions
and
669 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
// Copyright (C) 2024 Intel Corporation | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
|
||
export 'floating_point_adder.dart'; | ||
export 'floating_point_adder_round.dart'; | ||
export 'floating_point_adder_simple.dart'; | ||
export 'floating_point_multiplier.dart'; | ||
export 'floating_point_multiplier_simple.dart'; |
73 changes: 73 additions & 0 deletions
73
lib/src/arithmetic/floating_point/floating_point_adder.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
// Copyright (C) 2025 Intel Corporation | ||
// SPDX-License-Identifier: BSD-3-Clause | ||
// | ||
// floating_point_adder.dart | ||
// An abstract base class defining the API for floating-point adders. | ||
// | ||
// 2025 January 3 | ||
// Author: Desmond A Kirkpatrick <[email protected] | ||
|
||
import 'package:meta/meta.dart'; | ||
import 'package:rohd/rohd.dart'; | ||
import 'package:rohd_hcl/rohd_hcl.dart'; | ||
|
||
/// An abstract API for floating point adders. | ||
abstract class FloatingPointAdder extends Module { | ||
/// Width of the output exponent field. | ||
final int exponentWidth; | ||
|
||
/// Width of the output mantissa field. | ||
final int mantissaWidth; | ||
|
||
/// The [clk]: if a valid clock signal is passed in, a pipestage is added to | ||
/// the adder to help optimize frequency. | ||
Logic? clk; | ||
|
||
/// Optional [reset], used only if a [clk] is not null to reset the pipeline | ||
/// flops. | ||
Logic? reset; | ||
|
||
/// Optional [enable], used only if a [clk] is not null to enable the pipeline | ||
/// flops. | ||
Logic? enable; | ||
|
||
/// The first addend [ia], named this way to allow for a local variable 'a'. | ||
@protected | ||
late final FloatingPoint ia; | ||
|
||
/// The second addend [ib], named this way to allow for a local variable 'b'. | ||
@protected | ||
late final FloatingPoint ib; | ||
|
||
/// getter for the computed [FloatingPoint] output. | ||
late final FloatingPoint sum = | ||
FloatingPoint(exponentWidth: exponentWidth, mantissaWidth: mantissaWidth) | ||
..gets(output('sum')); | ||
|
||
/// Add two floating point numbers [a] and [b], returning result in [sum]. | ||
/// - [clk], [reset], [enable] are optional inputs to control a pipestage | ||
/// (only inserted if [clk] is provided). | ||
FloatingPointAdder(FloatingPoint a, FloatingPoint b, | ||
{this.clk, this.reset, this.enable, super.name = 'floating_point_adder'}) | ||
: exponentWidth = a.exponent.width, | ||
mantissaWidth = a.mantissa.width, | ||
super() { | ||
if (b.exponent.width != exponentWidth || | ||
b.mantissa.width != mantissaWidth) { | ||
throw RohdHclException('FloatingPoint widths must match'); | ||
} | ||
if (clk != null) { | ||
clk = addInput('clk', clk!); | ||
} | ||
if (reset != null) { | ||
reset = addInput('reset', reset!); | ||
} | ||
if (enable != null) { | ||
enable = addInput('enable', enable!); | ||
} | ||
ia = a.clone()..gets(addInput('a', a, width: a.width)); | ||
ib = b.clone()..gets(addInput('b', b, width: b.width)); | ||
|
||
// addOutput('sum', width: exponentWidth + mantissaWidth + 1); | ||
} | ||
} |
Oops, something went wrong.