Last active
October 15, 2015 15:00
-
-
Save christiaanb/d114231c02f8ed90b428 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 PopulationCount where | |
import CLaSH.Prelude | |
popCnt :: forall n . (KnownNat (n+1), KnownNat (n + 2)) | |
=> BitVector (n+1) | |
-> Index (n+2) | |
popCnt bv = sum (map fromIntegral v) | |
where | |
v :: Vec (n+1) Bit | |
v = unpack bv | |
topEntity :: BitVector 16 -> Index 17 | |
topEntity = popCnt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment