packages feed

clash-lib 1.4.1 → 1.4.2

raw patch · 5 files changed

+87/−21 lines, 5 filesdep ~clash-preludePVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependency ranges changed: clash-prelude

API changes (from Hackage documentation)

- Clash.Normalize.PrimitiveReductions: reduceUnconcat :: Integer -> Integer -> Type -> Term -> NormalizeSession Term
+ Clash.Normalize.PrimitiveReductions: reduceUnconcat :: InScopeSet -> PrimInfo -> Integer -> Integer -> Type -> Term -> Term -> NormalizeSession Term
- Clash.Rewrite.Types: bindings :: forall extra_a3uko. Lens' (RewriteState extra_a3uko) BindingMap
+ Clash.Rewrite.Types: bindings :: forall extra_a3umE. Lens' (RewriteState extra_a3umE) BindingMap
- Clash.Rewrite.Types: curFun :: forall extra_a3uko. Lens' (RewriteState extra_a3uko) (Id, SrcSpan)
+ Clash.Rewrite.Types: curFun :: forall extra_a3umE. Lens' (RewriteState extra_a3umE) (Id, SrcSpan)
- Clash.Rewrite.Types: extra :: forall extra_a3uko extra_a3usO. Lens (RewriteState extra_a3uko) (RewriteState extra_a3usO) extra_a3uko extra_a3usO
+ Clash.Rewrite.Types: extra :: forall extra_a3umE extra_a3uv4. Lens (RewriteState extra_a3umE) (RewriteState extra_a3uv4) extra_a3umE extra_a3uv4
- Clash.Rewrite.Types: globalHeap :: forall extra_a3uko. Lens' (RewriteState extra_a3uko) PrimHeap
+ Clash.Rewrite.Types: globalHeap :: forall extra_a3umE. Lens' (RewriteState extra_a3umE) PrimHeap
- Clash.Rewrite.Types: nameCounter :: forall extra_a3uko. Lens' (RewriteState extra_a3uko) Int
+ Clash.Rewrite.Types: nameCounter :: forall extra_a3umE. Lens' (RewriteState extra_a3umE) Int
- Clash.Rewrite.Types: transformCounter :: forall extra_a3uko. Lens' (RewriteState extra_a3uko) Int
+ Clash.Rewrite.Types: transformCounter :: forall extra_a3umE. Lens' (RewriteState extra_a3umE) Int
- Clash.Rewrite.Types: uniqSupply :: forall extra_a3uko. Lens' (RewriteState extra_a3uko) Supply
+ Clash.Rewrite.Types: uniqSupply :: forall extra_a3umE. Lens' (RewriteState extra_a3umE) Supply
- Clash.Rewrite.Types: workFreeBinders :: forall extra_a3uko. Lens' (RewriteState extra_a3uko) (VarEnv Bool)
+ Clash.Rewrite.Types: workFreeBinders :: forall extra_a3umE. Lens' (RewriteState extra_a3umE) (VarEnv Bool)

Files

CHANGELOG.md view
@@ -1,5 +1,15 @@ # Changelog for the Clash project +## 1.4.2 *May 18th 2021*+Fixed:++ * Erroneous examples in `Clash.Annotation.TopEntity` documentation [#646](https://github.com/clash-lang/clash-compiler/issues/646) and [#654](https://github.com/clash-lang/clash-compiler/issues/654)+ * `unconcat` cannot be used as initial/reset value for a `register` [#1756](https://github.com/clash-lang/clash-compiler/issues/1756)+ * `showX` now doesn't crash if a spine of a `Vec` is undefined+ * `~ISACTIVEENABLE` in blackboxes works again, and now acts on `Signal dom Bool` in addition to `Enable dom`. Since [#1368](https://github.com/clash-lang/clash-compiler/pull/1368), enable lines were always generated even if they were known to be always enabled. Fixes [#1786](https://github.com/clash-lang/clash-compiler/issues/1786).+ * clash --show-options now shows -fclash-* options in GHC 9.0 [#1787](https://github.com/clash-lang/clash-compiler/issues/1787)+ * `makeRecursiveGroups` now correctly identifies mutual recursion between global binders ([#1796](https://github.com/clash-lang/clash-compiler/issues/1796)).+ ## 1.4.1 *April 6th 2021* Fixed: 
clash-lib.cabal view
@@ -1,6 +1,6 @@ Cabal-version:        2.2 Name:                 clash-lib-Version:              1.4.1+Version:              1.4.2 Synopsis:             Clash: a functional hardware description language - As a library Description:   Clash is a functional hardware description language that borrows both its@@ -144,7 +144,7 @@                       base16-bytestring       >= 0.1.1    && < 1.1,                       binary                  >= 0.8.5    && < 0.11,                       bytestring              >= 0.10.0.2 && < 0.12,-                      clash-prelude           == 1.4.1,+                      clash-prelude           == 1.4.2,                       concurrent-supply       >= 0.1.7    && < 0.2,                       containers              >= 0.5.0.0  && < 0.7,                       cryptohash-sha256       >= 0.11     && < 0.12,
src/Clash/Netlist/BlackBox/Util.hs view
@@ -459,14 +459,23 @@        (IsActiveEnable n) ->         let (e, ty, _) = bbInputs b !! n in-        case (e, ty) of-          (Literal Nothing (BoolLit True), Enable {})  -> 0-          -- TODO: Emit warning? If enable signal is inferred as always False,-          -- TODO: the component will never be enabled. This is probably not the-          -- TODO: user's intention.-          (Literal Nothing (BoolLit False), Enable {}) -> 1-          (_, Bool)                                    -> 1-          (_, Enable _)                                -> 1+        case ty of+          Enable _ ->+            case e of+              DataCon _ _ [Literal Nothing (BoolLit True)]  -> 0+              -- TODO: Emit warning? If enable signal is inferred as always+              -- TODO: False, the component will never be enabled. This is+              -- TODO: probably not the user's intention.+              DataCon _ _ [Literal Nothing (BoolLit False)] -> 1+              _                                             -> 1+          Bool ->+            case e of+              Literal Nothing (BoolLit True)  -> 0+              -- TODO: Emit warning? If enable signal is inferred as always+              -- TODO: False, the component will never be enabled. This is+              -- TODO: probably not the user's intention.+              Literal Nothing (BoolLit False) -> 1+              _                               -> 1           _ ->             error $ $(curLoc) ++ "IsActiveEnable: Expected Bool, not: " ++ show ty 
src/Clash/Normalize/PrimitiveReductions.hs view
@@ -23,10 +23,10 @@     * Clash.Sized.Vector.dtfold     * Clash.Sized.RTree.tfold     * Clash.Sized.Vector.reverse+    * Clash.Sized.Vector.unconcat    Partially handles: -    * Clash.Sized.Vector.unconcat     * Clash.Sized.Vector.transpose -} @@ -914,12 +914,15 @@ -- | Replace an application of the @Clash.Sized.Vector.unconcat@ primitive on -- vectors of a known length @n@, by the fully unrolled recursive "definition" -- of @Clash.Sized.Vector.unconcat@-reduceUnconcat :: Integer  -- ^ Length of the result vector+reduceUnconcat :: InScopeSet+               -> PrimInfo -- ^ Unconcat primitive info+               -> Integer  -- ^ Length of the result vector                -> Integer  -- ^ Length of the elements of the result vector                -> Type -- ^ Element type+               -> Term -- ^ SNat "Length of the elements of the result vector"                -> Term -- ^ Argument vector                -> NormalizeSession Term-reduceUnconcat n 0 aTy arg = do+reduceUnconcat inScope unconcatPrimInfo n m aTy sm arg = do     tcm <- Lens.view tcCache     let ty = termType tcm arg     go tcm ty@@ -929,13 +932,46 @@       | (Just vecTc)     <- lookupUniqMap vecTcNm tcm       , nameOcc vecTcNm == "Clash.Sized.Vector.Vec"       , [nilCon,consCon] <- tyConDataCons vecTc-      = let nilVec           = mkVec nilCon consCon aTy 0 []-            innerVecTy       = mkTyConApp vecTcNm [LitTy (NumTy 0), aTy]-            retVec           = mkVec nilCon consCon innerVecTy n (replicate (fromInteger n) nilVec)-        in  changed retVec-    go _ ty = error $ $(curLoc) ++ "reduceUnconcat: argument does not have a vector type: " ++ showPpr ty+      , let innerVecTy = mkTyConApp vecTcNm [LitTy (NumTy m), aTy]+      = if n == 0 then+          changed (mkVecNil nilCon innerVecTy)+        else if m == 0 then do+          let+            nilVec = mkVecNil nilCon aTy+            retVec = mkVec nilCon consCon innerVecTy n (replicate (fromInteger n) nilVec)+          changed retVec+        else do+          uniqs0 <- Lens.use uniqSupply+          let+            (uniqs1,(vars,headsAndTails)) =+              second (second concat . unzip)+                     (extractElems uniqs0 inScope consCon aTy 'U' (n*m) arg)+            -- Build a vector out of the first m elements+            mvec = mkVec nilCon consCon aTy m (take (fromInteger m) vars)+            -- Get the vector representing the next ((n-1)*m) elements+            -- N.B. `extractElems (xs :: Vec 2 a)` creates:+            -- x0  = head xs+            -- xs0 = tail xs+            -- x1  = head xs0+            -- xs1 = tail xs0+            (lbs,head -> nextVec) = splitAt ((2*fromInteger m)-1) headsAndTails+            -- recursively call unconcat+            nextUnconcat = mkApps (Prim unconcatPrimInfo)+                                  [ Right (LitTy (NumTy (n-1)))+                                  , Right (LitTy (NumTy m))+                                  , Right aTy+                                  , Left (Literal (NaturalLiteral (n-1)))+                                  , Left sm+                                  , Left (snd nextVec)+                                  ]+            -- let (mvec,nextVec) = splitAt sm arg+            -- in Cons mvec (unconcat sm nextVec)+            lBody = mkVecCons consCon innerVecTy n mvec nextUnconcat+            lb = Letrec lbs lBody -reduceUnconcat _ _ _ _ = error $ $(curLoc) ++ "reduceUnconcat: unimplemented"+          uniqSupply Lens..= uniqs1+          changed lb+    go _ ty = error $ $(curLoc) ++ "reduceUnconcat: argument does not have a vector type: " ++ showPpr ty  -- | Replace an application of the @Clash.Sized.Vector.transpose@ primitive on -- vectors of a known length @n@, by the fully unrolled recursive "definition"
src/Clash/Normalize/Transformations.hs view
@@ -2327,9 +2327,20 @@                else return e           _ -> return e       "Clash.Sized.Vector.unconcat" | argLen == 6 -> do-        let ([_knN,_sm,arg],[mTy,nTy,aTy]) = Either.partitionEithers args+        let ([_knN,sm,arg],[nTy,mTy,aTy]) = Either.partitionEithers args+            argTy = termType tcm arg         case (runExcept (tyNatSize tcm nTy), runExcept (tyNatSize tcm mTy)) of-          (Right n, Right 0) -> (`mkTicks` ticks) <$> reduceUnconcat n 0 aTy arg+          (Right n, Right m) -> do+            shouldReduce1 <- List.orM [ pure (m==0)+                                      , shouldReduce ctx+                                      , isUntranslatableType_not_poly aTy+                                      --  Note [Unroll shouldSplit types]+                                      , pure (Maybe.isJust (shouldSplit tcm argTy))+                                      ]+            if shouldReduce1 then+              (`mkTicks` ticks) <$> reduceUnconcat is0 p n m aTy sm arg+            else+              return e           _ -> return e       "Clash.Sized.Vector.transpose" | argLen == 5 -> do         let ([_knN,arg],[mTy,nTy,aTy]) = Either.partitionEithers args