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

WIP: Float conv1 #109

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

WIP: Float conv1 #109

wants to merge 10 commits into from

Conversation

saw235
Copy link

@saw235 saw235 commented Oct 15, 2024

Description & Motivation

Software and Hardware Arbitrary Precision Float Converter

Copy link
Contributor

@mkorbel1 mkorbel1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great progress!

]),
Iff(source.isSubnormal() | source.isNormal(), [
_result <
mux(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why use a mux here instead of two if statements?

import 'package:rohd/rohd.dart';

void main() {
const fp32ExponentWidth = 8;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this PR should provide these constants for reference:
#110

although, why test these specifically instead of a handful of arbitrary sizes?

final converter = FloatingPointConverter(fp32,
destExponentWidth: bf19ExponentWidth,
destMantissaWidth: bf19MantissaWidth,
name: 'fp32_to_bf19');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test the whole module works on some things?


adjustedMantissa <=
adjustMantissaPrecision(source.mantissa, destMantissaWidth,
Const(FloatingPointRoundingMode.roundNearestEven.index));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

heads up that Const default width is 1

destMantissaWidth: bf19MantissaWidth,
name: 'fp32_to_bf19');

expect(converter.result.floatingPointValue.toString().contains('x'), false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's an isValid on LogicValue you can use

destMantissaWidth: fp16MantissaWidth,
name: 'fp32_to_bf19');

print('Test case:');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use the reason field of expect to give more detailed explanations, and '''s to make multi-line strings

///
/// [destExponentWidth] and [destMantissaWidth] are the widths of the exponent
/// and mantissa of the destination [FloatingPoint] respectively.
static FloatingPoint handleOverflow(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you may want to tag these helper functions with @visibleForTesting unless you think they are useful outside of this converter?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants