Description
The simulation code of the rotateL# and rotateR#, functions of the BitVector throw a divide by zero exception when applied on a BitVector of length 0.
Steps to reproduce
- Write a Clash file that uses a rotateL or rotateR on a BitVector of length 0, for example:
module Example.Project where
import Clash.Prelude
topEntity :: (BitVector 0) -> (BitVector 0)
topEntity x = rotateL x 2
- Go into the repl using
cabal repl
- Load the file:
:l Example/Project
- run an example by executing the topEntity function, eg:
topEntity 4
The same error occurs when I compile the code using cabal run clash -- /src/Example/Project.hs --verilog.
Expected result:
The rotate function and thus the repl execution should return a BitVector of length 0, shown as 0.
Actual result:
The repl shows *** Exception: divide by zero.
Possible causes
I think it has something to do with the mod in b' = formIntegral b `mod` sz being partial.
This is on line 1313 in the clash-prelude/src/Clash/Sized/Internal/BitVector.hs file
Meta info
- Cabal version: 3.12.1.0
- Clash version: 1.8.2
Description
The simulation code of the
rotateL#androtateR#, functions of the BitVector throw a divide by zero exception when applied on a BitVector of length 0.Steps to reproduce
cabal repl:l Example/ProjecttopEntity 4The same error occurs when I compile the code using
cabal run clash -- /src/Example/Project.hs --verilog.Expected result:
The rotate function and thus the repl execution should return a BitVector of length 0, shown as
0.Actual result:
The repl shows
*** Exception: divide by zero.Possible causes
I think it has something to do with the
modinb' = formIntegral b `mod` szbeing partial.This is on line 1313 in the
clash-prelude/src/Clash/Sized/Internal/BitVector.hsfileMeta info