clash-lib 0.3.0.1 → 0.3.0.2
raw patch · 3 files changed
+18/−8 lines, 3 files
Files
- clash-lib.cabal +2/−2
- src/CLaSH/Netlist/BlackBox.hs +3/−2
- src/CLaSH/Netlist/Util.hs +13/−4
clash-lib.cabal view
@@ -1,5 +1,5 @@ Name: clash-lib-Version: 0.3.0.1+Version: 0.3.0.2 Synopsis: CAES Language for Synchronous Hardware - As a Library Description: CλaSH (pronounced ‘clash’) is a functional hardware description language that@@ -25,7 +25,7 @@ . * <https://github.com/christiaanb/Idris-dev Idris Frontend> .- * <https://github.com/christiaanb/clash2 GHC/Haskell Frontend>+ * <http://hackage.haskell.org/package/clash-ghc GHC/Haskell Frontend> . . Prelude library: <http://hackage.haskell.org/package/clash-prelude>
src/CLaSH/Netlist/BlackBox.hs view
@@ -56,7 +56,7 @@ (funInps,declssF) <- fmap (unzip . catMaybes) $ mapM (runMaybeT . mkFunInput resId . fst) funArgs -- Make context result- let res = case synchronizedClk (unembed $ V.varType resId) of+ let res = case synchronizedClk tcm (unembed $ V.varType resId) of Just clk -> Right . (,clk) . mkBasicId . pack $ name2String (V.varName resId) Nothing -> Left . mkBasicId . pack $ name2String (V.varName resId) resTy <- N.unsafeCoreTypeToHWTypeM $(curLoc) (unembed $ V.varType resId)@@ -90,8 +90,9 @@ mkInput (Var ty v, False) = do let vT = mkBasicId . pack $ name2String v+ tcm <- Lens.use tcCache hwTy <- lift $ N.unsafeCoreTypeToHWTypeM $(curLoc) ty- case synchronizedClk ty of+ case synchronizedClk tcm ty of Just clk -> return ((Right (vT,clk), hwTy),[]) Nothing -> return ((Left vT, hwTy),[])
src/CLaSH/Netlist/Util.hs view
@@ -73,14 +73,15 @@ coreTypeToHWTypeM ty = hush <$> (coreTypeToHWType <$> Lens.use typeTranslator <*> Lens.use tcCache <*> pure ty) -- | Returns the name and period of the clock corresponding to a type-synchronizedClk :: Type+synchronizedClk :: HashMap TyConName TyCon -- ^ TyCon cache+ -> Type -> Maybe (Identifier,Int)-synchronizedClk ty+synchronizedClk tcm ty | not . null . typeFreeVars $ ty = Nothing | Just (tyCon,args) <- splitTyConAppM ty = case name2String tyCon of "CLaSH.Signal.Types.Signal" -> Just (pack "clk1000",1000)- "CLaSH.Sized.Vector.Vec" -> synchronizedClk (args!!1)+ "CLaSH.Sized.Vector.Vec" -> synchronizedClk tcm (args!!1) "CLaSH.Signal.Implicit.SignalP" -> Just (pack "clk1000",1000) "CLaSH.Signal.Types.CSignal" -> case (head args) of (LitTy (NumTy i)) -> Just (pack ("clk" ++ show i),i)@@ -88,7 +89,15 @@ "CLaSH.Signal.Types.CSignalP" -> case (head args) of (LitTy (NumTy i)) -> Just (pack ("clk" ++ show i),i) _ -> error $ $(curLoc) ++ "Clock period not a simple literal: " ++ showDoc ty- _ -> Nothing+ _ -> case tyConDataCons (tcm HashMap.! tyCon) of+ [dc] -> let argTys = dcArgTys dc+ argTVs = dcUnivTyVars dc+ argSubts = zip argTVs args+ args' = map (substTys argSubts) argTys+ in case args' of+ (arg:_) -> synchronizedClk tcm arg+ _ -> Nothing+ _ -> Nothing | otherwise = Nothing