packages feed

clash-lib 0.4 → 0.4.1

raw patch · 7 files changed

+47/−35 lines, 7 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- CLaSH.Netlist: mkExpr :: Type -> Term -> NetlistMonad (Expr, [Declaration])
+ CLaSH.Netlist: mkExpr :: Bool -> Type -> Term -> NetlistMonad (Expr, [Declaration])
- CLaSH.Netlist.BlackBox: mkPrimitive :: Bool -> Text -> [Either Term Type] -> Type -> NetlistMonad ((Expr, HWType), [Declaration])
+ CLaSH.Netlist.BlackBox: mkPrimitive :: Bool -> Bool -> Text -> [Either Term Type] -> Type -> NetlistMonad ((Expr, HWType), [Declaration])

Files

CHANGELOG.md view
@@ -1,34 +1,33 @@-# Changelog for the [`clash-lib`](http://hackage.haskell.org/package/clash-lib) package+# Changelog for the [`clash-ghc`](http://hackage.haskell.org/package/clash-ghc) package  ## 0.4 *November 17th 2014* * New features:   * Support for clash-prelude 0.6  * Fixes bugs:-  * Ambiguous type: 'std_logic_vector' or 'std_ulogic_vector' [#33](https://github.com/christiaanb/clash2/issues/33)+  * clash-ghc ignores "-package-db" flag [#35](https://github.com/christiaanb/clash2/issues/35) +## 0.3.3 *August 12th 2014*+* Fixes bugs:+  * Compile with GHC 7.8.3 [#31](https://github.com/christiaanb/clash2/issues/31)+ ## 0.3.2 *June 5th 2014*  * Fixes bugs:-  * VHDL array constant ambiguous [#18](https://github.com/christiaanb/clash2/issues/18)-  * Exception: can't create selector [#24](https://github.com/christiaanb/clash2/issues/24)-  * Calls to `vhdlTypeMark` don't result to inclusion of VHDL type in types.vhdl [#28](https://github.com/christiaanb/clash2/issues/28)+  * Type synonym improperly expanded [#17](https://github.com/christiaanb/clash2/issues/17)+  * BlackBox for `Signed` `maxBound` and `minBound` generate incorrect VHDL. [#19](https://github.com/christiaanb/clash2/issues/19)+  * Generate failure code in the VHDL for recSelError [#23](https://github.com/christiaanb/clash2/issues/23)  ## 0.3.1 *May 15th 2014*  * New features:-  * Make ANF lift non-representable values [#7](https://github.com/christiaanb/clash2/issues/7)   * Hardcode `fromInteger` for `Signed` and `Unsigned` [#9](https://github.com/christiaanb/clash2/issues/9)+  * Better blackbox operation for vindex [#12](https://github.com/christiaanb/clash2/issues/12)   * Replace VHDL default hole by error hole [#13](https://github.com/christiaanb/clash2/issues/13)  * Fixes bugs:+  * Update GHC2Core.hs [#1](https://github.com/christiaanb/clash2/issues/1)+  * primitives (clash.sized.vector) [#2](https://github.com/christiaanb/clash2/issues/2)   * Type families are not expanded [#3](https://github.com/christiaanb/clash2/issues/3)-  * Exception: CLaSH.Netlist.VHDL(512): fromSLV: Vector 13 Bool [#5](https://github.com/christiaanb/clash2/issues/5)   * Incorrect vhdl generation for default value in blackbox [#6](https://github.com/christiaanb/clash2/issues/6)-  * Duplicate type names when multiple ADTs need the same amount of bits [#8](https://github.com/christiaanb/clash2/issues/8)-  * Circuit testbench generation with MAC example fails[#15](https://github.com/christiaanb/clash2/issues/15)--* Code improvements:-  * Refactor Netlist/BlackBox [#10](https://github.com/christiaanb/clash2/issues/10)-  * CPP special-case conversion of `Control.Exception.Base.irrefutPatError` [#11](https://github.com/christiaanb/clash2/issues/11)-+  * Missing begin keyword in Signed/Unsigned JSON files [#16](https://github.com/christiaanb/clash2/issues/16)
clash-lib.cabal view
@@ -1,5 +1,5 @@ Name:                 clash-lib-Version:              0.4+Version:              0.4.1 Synopsis:             CAES Language for Synchronous Hardware - As a Library Description:   CλaSH (pronounced ‘clash’) is a functional hardware description language that
src/CLaSH/Driver/TestbenchGen.hs view
@@ -96,7 +96,7 @@     normalizeSignal glbls bndr =       runNormalization dbgLvl supply glbls typeTrans tcm eval (normalize [bndr] >>= cleanupGraph bndr) -genTestBench _ _ _ _ _ _ v _ _ _ _ c = traceIf True ("Can't make testbench for: " ++ show c) $ return ([],v)+genTestBench dbgLvl _ _ _ _ _ v _ _ _ _ c = traceIf (dbgLvl > DebugNone) ("Can't make testbench for: " ++ show c) $ return ([],v)  genClock :: (Identifier,HWType)          -> Maybe [Declaration]
src/CLaSH/Netlist.hs view
@@ -167,7 +167,7 @@   (selId,decls) <- case scrut of                      (Var _ scrutNm) -> return (mkBasicId . Text.pack $ name2String scrutNm,[])                      _ -> do-                        (newExpr, newDecls) <- mkExpr scrutTy scrut+                        (newExpr, newDecls) <- mkExpr False scrutTy scrut                         i   <- varCount <<%= (+1)                         let tmpNm   = "tmp_" ++ show i                             tmpNmT  = Text.pack tmpNm@@ -190,7 +190,7 @@   tcm                    <- Lens.use tcCache   scrutTy                <- termType tcm scrut   scrutHTy               <- unsafeCoreTypeToHWTypeM $(curLoc) scrutTy-  (scrutExpr,scrutDecls) <- first (mkScrutExpr scrutHTy (fst (last alts'))) <$> mkExpr scrutTy scrut+  (scrutExpr,scrutDecls) <- first (mkScrutExpr scrutHTy (fst (last alts'))) <$> mkExpr False scrutTy scrut   (exprs,altsDecls)      <- (second concat . unzip) <$> mapM (mkCondExpr scrutHTy) alts'    let dstId = mkBasicId . Text.pack . name2String $ varName bndr@@ -198,7 +198,7 @@   where     mkCondExpr :: HWType -> (Pat,Term) -> NetlistMonad ((Maybe Expr,Expr),[Declaration])     mkCondExpr scrutHTy (pat,alt) = do-      (altExpr,altDecls) <- mkExpr altTy alt+      (altExpr,altDecls) <- mkExpr False altTy alt       (,altDecls) <$> case pat of         DefaultPat           -> return (Nothing,altExpr)         DataPat (Embed dc) _ -> return (Just (dcToLiteral scrutHTy (dcTag dc)),altExpr)@@ -221,7 +221,7 @@       | null tyArgs -> mkFunApp bndr f args       | otherwise   -> error $ $(curLoc) ++ "Not in normal form: Var-application with Type arguments"     _ -> do-      (exprApp,declsApp) <- mkExpr (unembed $ varType bndr) app+      (exprApp,declsApp) <- mkExpr False (unembed $ varType bndr) app       let dstId = mkBasicId . Text.pack . name2String $ varName bndr       return (declsApp ++ [Assignment dstId exprApp]) @@ -238,7 +238,7 @@       if length args == length compInps         then do tcm <- Lens.use tcCache                 argTys              <- mapM (termType tcm) args-                (argExprs,argDecls) <- fmap (second concat . unzip) $! mapM (\(e,t) -> mkExpr t e) (zip args argTys)+                (argExprs,argDecls) <- fmap (second concat . unzip) $! mapM (\(e,t) -> mkExpr False t e) (zip args argTys)                 let dstId         = mkBasicId . Text.pack . name2String $ varName dst                     hiddenAssigns = map (\(i,_) -> (i,Identifier i Nothing)) hidden                     inpAssigns    = zip (map fst compInps) argExprs@@ -254,16 +254,17 @@       _ -> error $ $(curLoc) ++ "Unknown function: " ++ showDoc fun  -- | Generate an expression for a term occurring on the RHS of a let-binder-mkExpr :: Type -- ^ Type of the LHS of the let-binder+mkExpr :: Bool -- ^ Treat BlackBox expression as declaration+       -> Type -- ^ Type of the LHS of the let-binder        -> Term -- ^ Term to convert to an expression        -> NetlistMonad (Expr,[Declaration]) -- ^ Returned expression and a list of generate BlackBox declarations-mkExpr _ (Core.Literal lit) = return (HW.Literal Nothing . NumLit $ fromInteger  $! i,[])+mkExpr _ _ (Core.Literal lit) = return (HW.Literal Nothing . NumLit $ fromInteger  $! i,[])   where     i = case lit of           (IntegerLiteral i') -> i'           _ -> error $ $(curLoc) ++ "not an integer literal" -mkExpr ty app = do+mkExpr bbEasD ty app = do   let (appF,args) = collectArgs app       tmArgs      = lefts args   hwTy    <- unsafeCoreTypeToHWTypeM $(curLoc) ty@@ -271,7 +272,7 @@     Data dc       | all (\e -> isConstant e || isVar e) tmArgs -> mkDcApplication hwTy dc tmArgs       | otherwise                                  -> error $ $(curLoc) ++ "Not in normal form: DataCon-application with non-Simple arguments"-    Prim nm _ -> first fst <$> mkPrimitive False nm args ty+    Prim nm _ -> first fst <$> mkPrimitive False bbEasD nm args ty     Var _ f       | null tmArgs -> return (Identifier (mkBasicId . Text.pack $ name2String f) Nothing,[])       | otherwise -> error $ $(curLoc) ++ "Not in normal form: top-level binder in argument position: " ++ showDoc app@@ -285,7 +286,7 @@ mkDcApplication dstHType dc args = do   tcm                 <- Lens.use tcCache   argTys              <- mapM (termType tcm) args-  (argExprs,argDecls) <- fmap (second concat . unzip) $! mapM (\(e,t) -> mkExpr t e) (zip args argTys)+  (argExprs,argDecls) <- fmap (second concat . unzip) $! mapM (\(e,t) -> mkExpr True t e) (zip args argTys)   argHWTys            <- mapM coreTypeToHWTypeM argTys   fmap (,argDecls) $! case (argHWTys,argExprs) of     -- Is the DC just a newtype wrapper?
src/CLaSH/Netlist.hs-boot view
@@ -10,7 +10,8 @@   -> Maybe Int   -> NetlistMonad Component -mkExpr :: Type+mkExpr :: Bool+       -> Type        -> Term        -> NetlistMonad (Expr,[Declaration]) 
src/CLaSH/Netlist/BlackBox.hs view
@@ -107,17 +107,18 @@   (Prim f _, args) -> do     tcm <- Lens.use tcCache     ty  <- termType tcm e-    ((exprN,hwTy),decls) <- lift $ mkPrimitive True f args ty+    ((exprN,hwTy),decls) <- lift $ mkPrimitive True False f args ty     exprV <- fmap (pack . show) $ liftState vhdlMState $ N.expr False exprN     return ((Left exprV,hwTy),decls)   _ -> fmap (first (first Left)) $ mkLitInput e -mkPrimitive :: Bool+mkPrimitive :: Bool -- ^ Put BlackBox expression in parenthesis+            -> Bool -- ^ Treat BlackBox expression as declaration             -> TextS.Text             -> [Either Term Type]             -> Type             -> NetlistMonad ((Expr,HWType),[Declaration])-mkPrimitive bbEParen nm args ty = do+mkPrimitive bbEParen bbEasD nm args ty = do   bbM <- HashMap.lookup nm <$> Lens.use primitives   case bbM of     Just p@(P.BlackBox {}) -> do@@ -135,7 +136,11 @@         (Right tempE) -> do           bbExpr <- mkBlackBox tempE bbCtx           let bbExpr' = if bbEParen then mconcat ["(",bbExpr,")"] else bbExpr-          return ((BlackBoxE bbExpr' Nothing,hwTy),ctxDcls)+          if bbEasD+            then let tmpDecl  = NetDecl tmpNmT hwTy Nothing+                     tmpAssgn = Assignment tmpNmT (BlackBoxE bbExpr' Nothing)+                 in  return ((Identifier tmpNmT Nothing, hwTy), ctxDcls ++ [tmpDecl,tmpAssgn])+            else return ((BlackBoxE bbExpr' Nothing,hwTy),ctxDcls)     Just (P.Primitive pNm _)       | pNm == "GHC.Prim.tagToEnum#" -> do           hwTy <- N.unsafeCoreTypeToHWTypeM $(curLoc) ty@@ -150,7 +155,7 @@               i <- varCount <<%= (+1)               tcm     <- Lens.use tcCache               scrutTy <- termType tcm scrut-              (scrutExpr,scrutDecls) <- mkExpr scrutTy scrut+              (scrutExpr,scrutDecls) <- mkExpr False scrutTy scrut               let tmpNm     = "tmp_tte_" ++ show i                   tmpS      = pack tmpNm                   netDecl   = NetDecl tmpS hwTy Nothing@@ -164,7 +169,7 @@             tcm      <- Lens.use tcCache             scrutTy  <- termType tcm scrut             scrutHTy <- unsafeCoreTypeToHWTypeM $(curLoc) scrutTy-            (scrutExpr,scrutDecls) <- mkExpr scrutTy scrut+            (scrutExpr,scrutDecls) <- mkExpr False scrutTy scrut             let tmpNm     = "tmp_dtt_" ++ show i                 tmpS      = pack tmpNm                 netDecl   = NetDecl tmpS Integer Nothing
src/CLaSH/Normalize/Transformations.hs view
@@ -322,7 +322,10 @@       else do         bodyMaybe <- fmap (HashMap.lookup f) $ Lens.use bindings         case bodyMaybe of-          Just (_,body) -> changed (mkApps body args)+          -- Don't inline recursive expressions+          Just (_,body) -> if f `elem` (termFreeIds body)+                              then return e+                              else changed (mkApps body args)           _ -> return e  inlineClosed _ e@(Var _ f) = R $ do@@ -333,7 +336,10 @@     then do       bodyMaybe <- fmap (HashMap.lookup f) $ Lens.use bindings       case bodyMaybe of-        Just (_,body) -> changed body+        -- Don't inline recursive expressions+        Just (_,body) -> if f `elem` (termFreeIds body)+                            then return e+                            else changed body         _ -> return e     else return e