packages feed

clash-lib 0.6.18 → 0.6.19

raw patch · 5 files changed

+26/−12 lines, 5 filesdep +integer-gmp

Dependencies added: integer-gmp

Files

CHANGELOG.md view
@@ -1,6 +1,12 @@ # Changelog for the [`clash-lib`](http://hackage.haskell.org/package/clash-lib) package -## 0.6.18+## 0.6.19 *July 19th 2016*+* Fixes bugs:+  * Rounding error in `logBase` calculation++## 0.6.18 *July 15th 2016*+* New features:+  * Better error location reporting * Fixes bugs:   * Values of type Index 'n', where 'n' > 2^MACHINE_WIDTH, incorrectly considered non-synthesisable due to overflow 
clash-lib.cabal view
@@ -1,5 +1,5 @@ Name:                 clash-lib-Version:              0.6.18+Version:              0.6.19 Synopsis:             CAES Language for Synchronous Hardware - As a Library Description:   CλaSH (pronounced ‘clash’) is a functional hardware description language that@@ -101,6 +101,7 @@                       filepath                >= 1.3.0.1  && < 1.5,                       ghc                     >= 7.10.1   && < 8.1,                       hashable                >= 1.2.1.0  && < 1.3,+                      integer-gmp             >= 1.0      && < 1.1,                       lens                    >= 3.9.2    && < 4.15,                       mtl                     >= 2.1.2    && < 2.3,                       pretty                  >= 1.1.1.0  && < 1.2,
src/CLaSH/Core/Util.hs view
@@ -407,10 +407,8 @@       , length tys == 2       , Right (Left i1) <- go (tys !! 0)       , Right (Left i2) <- go (tys !! 1)-      , i1 > 1-      , i2 > 2-      = return (Left (ceiling (logBase (fromIntegral i1 :: Double)-                                       (fromIntegral i2 :: Double))))+      , Just k <- clogBase i1 i2+      = return (Left (toInteger k))        | name2String tc == "GHC.TypeLits.Extra.GCD"       , length tys == 2
src/CLaSH/Netlist/Util.hs view
@@ -186,19 +186,19 @@ typeSize (BitVector i) = i typeSize (Index 0) = 0 typeSize (Index 1) = 1-typeSize (Index u) = clog2 u+typeSize (Index u) = fromMaybe 0 (clogBase 2 u) typeSize (Signed i) = i typeSize (Unsigned i) = i typeSize (Vector n el) = n * typeSize el typeSize t@(SP _ cons) = conSize t +   maximum (map (sum . map typeSize . snd) cons)-typeSize (Sum _ dcs) = max 1 (clog2 . toInteger $ length dcs)+typeSize (Sum _ dcs) = max 1 (fromMaybe 0 . clogBase 2 . toInteger $ length dcs) typeSize (Product _ tys) = sum $ map typeSize tys  -- | Determines the bitsize of the constructor of a type conSize :: HWType         -> Int-conSize (SP _ cons) = clog2 . toInteger $ length cons+conSize (SP _ cons) = fromMaybe 0 . clogBase 2 . toInteger $ length cons conSize t           = typeSize t  -- | Gives the length of length-indexed types
src/CLaSH/Util.hs view
@@ -8,6 +8,7 @@  {-# LANGUAGE CPP                  #-} {-# LANGUAGE FlexibleInstances    #-}+{-# LANGUAGE MagicHash            #-} {-# LANGUAGE Rank2Types           #-} {-# LANGUAGE TupleSections        #-} @@ -36,6 +37,8 @@ import Data.Version                   (Version) import Control.Lens import Debug.Trace                    (trace)+import GHC.Base                       (Int(..),isTrue#,(==#),(+#))+import GHC.Integer.Logarithms         (integerLogBase#) import qualified Language.Haskell.TH  as TH  #ifdef CABAL@@ -222,6 +225,12 @@ clashLibVersion = error "development version" #endif --- | ceiling (log_2(c))-clog2 :: Integer -> Int-clog2 = ceiling . logBase (2 :: Double) . fromIntegral+-- | \x y -> ceiling (logBase x y), x > 1 && y > 0+clogBase :: Integer -> Integer -> Maybe Int+clogBase x y | x > 1 && y > 0 =+  let z1 = integerLogBase# x y+      z2 = integerLogBase# x (y-1)+  in  if (isTrue# (z1 ==# z2))+         then Just (I# (z1 +# 1#))+         else Just (I# z1)+clogBase _ _ = Nothing