Created
December 8, 2017 22:15
-
-
Save thoughtpolice/7384c09ddc7efbfe075069d3036e8328 to your computer and use it in GitHub Desktop.
clash example
This file contains 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
module Test where | |
import Clash.Prelude | |
-- this just puts zeros in front of the bit vector | |
f :: KnownNat a => BitVector a -> BitVector (a + 1) | |
f bv = zeroExtend bv | |
-- this gets the length of a bit vector, as an SNat | |
g :: KnownNat a => BitVector a -> SNat a | |
g _ = SNat | |
-- this gets the length of *any* 'thing with known size that can become | |
-- a bitvector' | |
h :: (BitPack a, BitSize a ~ n, KnownNat n) => a -> SNat n | |
h _ = SNat |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment