Skip to content

Instantly share code, notes, and snippets.

@christiaanb
Last active October 15, 2015 14:35
Show Gist options
  • Save christiaanb/25191ea84ee264765af3 to your computer and use it in GitHub Desktop.
Save christiaanb/25191ea84ee264765af3 to your computer and use it in GitHub Desktop.
{-# LANGUAGE ScopedTypeVariables #-}
module BitPalindrome where
import CLaSH.Prelude
-- Not used anywhere, but using (!) is more idiomatic than "slice x x"
sl8 :: BitVector 8 -> (Bit, Bit, Bit, Bit, Bit, Bit, Bit, Bit)
sl8 a = (a ! 0, a ! 1, a ! 2, a ! 3, a ! 4, a ! 5, a ! 6, a ! 7)
-- (==) on Vectors will become a comparison tree in HW
palindrome :: forall n . KnownNat n => BitVector n -> Bool
palindrome bv = v == reverse v
where
v :: Vec n Bit
v = unpack bv
topEntity :: BitVector 8 -> Bool
topEntity = palindrome
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment