Strange evaluation-time error when comparing two FloatingPoint values #711
-
I've been attempting to debug an evaluation-time error that I observe when compiling a program that uses the package Top where
import FloatingPoint
mkTop :: Module Empty
mkTop =
module
let x :: Double
x = 0.0
y :: Double
y = 0.0
rules
"step": when True ==>
$display (fshow (x < y)) This will print package Top where
import FloatingPoint
mkTop :: Module Empty
mkTop =
module
x :: Reg Double <- mkReg 0.0
y :: Reg Double <- mkReg 0.0
rules
"step": when True ==>
$display (fshow (x < y)) I would expect this program to be equivalent. Surprisingly,
The error message arises from here: bsc/src/Libraries/Base3-Math/FloatingPoint.bsv Lines 945 to 953 in 9a97f9d I am very unclear as to how |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
They are not equivalent because, in one, the inputs are constants that are known (statically) at compile time and, in the other, the inputs come from registers who values are only known (dynamically) at runtime of the hardware. The reset value of We can see this with a simpler example:
BSC has to produce hardware for all possible case-arms, so it has to evaluate all arms, and one of the arms is an error, so you get an evaluation-time error. In your example, instead of using the operator It's also possible that you could add a guard like |
Beta Was this translation helpful? Give feedback.
They are not equivalent because, in one, the inputs are constants that are known (statically) at compile time and, in the other, the inputs come from registers who values are only known (dynamically) at runtime of the hardware. The reset value of
0.0
to the registers does not matter; BSC must assume that the registers could contain any possible values, including NaN values. (In theory, maybe BSC could perform "model checking" to detect what states can be reached, but BSC does not currently do that.) When the input is statically known, BSC can pick the right case-arm and only evaluate that. However, when the input is not known at compile time, BSC must generate the hardware for all possibl…