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

Use NumericType classes, additional tests, transition to simplejson. #468

Merged
merged 21 commits into from
Mar 29, 2021

Conversation

cgyurgyik
Copy link
Collaborator

@cgyurgyik cgyurgyik commented Mar 28, 2021

Closes #464. As discussed in there, The json module automatically converts decimal values to float. simplejson allows for the numbers to be casted directly to Decimal.

Next, this PR adds a NumericType interface, which provide FixedPoint and Bitnum classes. Given a value (in decimal, binary string, or hexadecimal string form), width, and signed-ness, these classes will provide simple getter methods to view different interpretations of the variable, e.g. hex_string(), unsigned_integer(), and so on. Some simple checks are also implemented, such as overflow.

FixedPoint(
   value="1.5",
   width=3,
   int_width=1, 
   is_signed=True
).pretty_print()

will output:

        Signed Fixed Point: 1.5
        ------------------
        Width: 3, IntWidth: 1, FracWidth: 2
        Decimal Class: 1.5
        Fraction Class: 3/2
        Bit String: 0b110
        Hex String: 0x6
        Unsigned Integer: 6

@cgyurgyik cgyurgyik changed the title [WIP] Use NumericType classes, additional tests, transition to simplejson. Use NumericType classes, additional tests, transition to simplejson. Mar 29, 2021
@cgyurgyik cgyurgyik marked this pull request as ready for review March 29, 2021 22:09
@rachitnigam
Copy link
Contributor

Minor comments. Merge when addressed. I assume you've already tested the changes with calyx-eval?

@cgyurgyik
Copy link
Collaborator Author

Minor comments. Merge when addressed. I assume you've already tested the changes with calyx-eval?

Done.

@cgyurgyik cgyurgyik merged commit 03ad6d4 into master Mar 29, 2021
@cgyurgyik cgyurgyik deleted the fp-tests branch March 29, 2021 23:53
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.

Fixed point decimal representation.
2 participants