Last active
October 15, 2015 14:35
-
-
Save christiaanb/25191ea84ee264765af3 to your computer and use it in GitHub Desktop.
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
{-# 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