I have a function that I would handle undefined in. Something like:
foo :: MyType -> State X ()
foo mt
| isUndefined mt = do
x .= undefined
y .= undefined
foo (A a) = x .= a
foo (B b) = y .= b
However it generates a blackbox in the code because of catch method. How am I supposed to handle undefined?
Ok clashSimulation && hasUndefined mt seems to work
1 Like
It’s important to realize that checking if something is undefined is inherently a simulation time activity and will never actually work in hardware since there you will always have a value.
That being said, in Clash we typically use errorX or deepErrorX to create undefined expressions. These allow you to state the reason why that value is undefined. In your HDL they will also end up as undefined values which your synthesis tool can then “optimize away” by e.g. selecting an already existing valid value.