[vhdl] Handle garbage truncf input data#1002
Open
zero9178 wants to merge 1 commit into
Open
Conversation
VHDL's `to_float32` function may fatally assert in simulation if the `float64` input value is out-of-range for a `float32` (e.g. exponent too large). This is generally not propblematic in dynamatic since C defines this as UB and therefore this is valid behavior for the compiler. However, the `truncf` circuit did not care to check whether `valid` is set and would just process its input data regardless of whether the input is valid, potentially leading to processing a `float64` leading to a simulator crash. This PR fixes this issue by simply masking the input when `valid` is not set. Very technically speaking this only exists to appease simulator semantics, though I'd hope synthesis can optimize out the check for equivalent circuits. Fixes #998
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
VHDL's
to_float32function may fatally assert in simulation if thefloat64input value is out-of-range for afloat32(e.g. exponent too large). This is generally not propblematic in dynamatic since C defines this as UB and therefore this is valid behavior for the compiler.However, the
truncfcircuit did not care to check whethervalidis set and would just process its input data regardless of whether the input is valid, potentially leading to processing afloat64leading to a simulator crash.This PR fixes this issue by simply masking the input when
validis not set. Very technically speaking this only exists to appease simulator semantics, though I'd hope synthesis can optimize out the check for equivalent circuits.Fixes #998