Skip to content

Instantly share code, notes, and snippets.

@christiaanb
Last active October 16, 2015 08:03
Show Gist options
  • Save christiaanb/c6e7d7ddcb7a6480fc43 to your computer and use it in GitHub Desktop.
Save christiaanb/c6e7d7ddcb7a6480fc43 to your computer and use it in GitHub Desktop.
module BitPalindrome2 where
-- import Control.Arrow (second)
import CLaSH.Prelude
-- This function will be in `clash-prelude-0.10.1`
bv2v :: KnownNat n => BitVector n -> Vec n Bit
bv2v = unpack
evenPalindrome :: (Eq a,KnownNat m)
=> Vec (2*m) a
-> Bool
evenPalindrome v = l == reverse r
where
(l,r) = splitAtI v
topEntity :: BitVector 8 -> Bool
topEntity = evenPalindrome . bv2v
-- pointFreePalindrome :: (Eq a,KnownNat m)
-- => Vec (2*m) a
-- -> Bool
-- pointFreePalindrome = uncurry (==) . second reverse . splitAtI
-- topEntity :: BitVector 8 -> Bool
-- topEntity = pointFreePalindrome . bv2v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment