clash-lib 1.6.3 → 1.6.4
raw patch · 40 files changed
+417/−333 lines, 40 filesdep ~clash-preludedep ~lensPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: clash-prelude, lens
API changes (from Hackage documentation)
- Clash.Netlist.Types: [_clashOpts] :: NetlistState -> ClashOpts
- Clash.Netlist.Types: [_customReprs] :: NetlistState -> CustomReprs
- Clash.Netlist.Types: [_intWidth] :: NetlistState -> Int
- Clash.Netlist.Types: [_primitives] :: NetlistState -> CompiledPrimMap
- Clash.Netlist.Types: [_tcCache] :: NetlistState -> TyConMap
+ Clash.Core.Evaluator.Types: instance Clash.Core.HasType.InferType Clash.Core.Evaluator.Types.Value
+ Clash.Netlist.BlackBox.Types: IsScalar :: !Int -> Element
+ Clash.Netlist.Types: [_clashEnv] :: NetlistEnv -> ClashEnv
+ Clash.Netlist.Types: clashEnv :: Lens' NetlistEnv ClashEnv
- Clash.Netlist: runNetlistMonad :: Bool -> ClashOpts -> CustomReprs -> BindingMap -> VarEnv TopEntityT -> CompiledPrimMap -> TyConMap -> (CustomReprs -> TyConMap -> Type -> State HWMap (Maybe (Either String FilteredHWType))) -> Int -> Bool -> SomeBackend -> IdentifierSet -> FilePath -> VarEnv Identifier -> NetlistMonad a -> IO (a, NetlistState)
+ Clash.Netlist: runNetlistMonad :: ClashEnv -> Bool -> BindingMap -> VarEnv TopEntityT -> (CustomReprs -> TyConMap -> Type -> State HWMap (Maybe (Either String FilteredHWType))) -> Bool -> SomeBackend -> IdentifierSet -> FilePath -> VarEnv Identifier -> NetlistMonad a -> IO (a, NetlistState)
- Clash.Netlist.Types: NetlistEnv :: Text -> Text -> Maybe Text -> NetlistEnv
+ Clash.Netlist.Types: NetlistEnv :: ClashEnv -> Text -> Text -> Maybe Text -> NetlistEnv
- Clash.Netlist.Types: NetlistState :: BindingMap -> ComponentMap -> CompiledPrimMap -> (CustomReprs -> TyConMap -> Type -> State HWMap (Maybe (Either String FilteredHWType))) -> TyConMap -> !(Identifier, SrcSpan) -> Int -> IdentifierSet -> IdentifierSet -> Set Text -> VarEnv Identifier -> VarEnv TopEntityT -> FilePath -> Int -> CustomReprs -> ClashOpts -> Bool -> Bool -> SomeBackend -> HWMap -> NetlistState
+ Clash.Netlist.Types: NetlistState :: BindingMap -> ComponentMap -> (CustomReprs -> TyConMap -> Type -> State HWMap (Maybe (Either String FilteredHWType))) -> !(Identifier, SrcSpan) -> IdentifierSet -> IdentifierSet -> Set Text -> VarEnv Identifier -> VarEnv TopEntityT -> FilePath -> Int -> Bool -> Bool -> SomeBackend -> HWMap -> NetlistState
- Clash.Netlist.Types: clashOpts :: Lens' NetlistState ClashOpts
+ Clash.Netlist.Types: clashOpts :: Getter NetlistEnv ClashOpts
- Clash.Netlist.Types: customReprs :: Lens' NetlistState CustomReprs
+ Clash.Netlist.Types: customReprs :: Getter NetlistEnv CustomReprs
- Clash.Netlist.Types: intWidth :: Lens' NetlistState Int
+ Clash.Netlist.Types: intWidth :: Getter NetlistEnv Int
- Clash.Netlist.Types: primitives :: Lens' NetlistState CompiledPrimMap
+ Clash.Netlist.Types: primitives :: Getter NetlistEnv CompiledPrimMap
- Clash.Netlist.Types: tcCache :: Lens' NetlistState TyConMap
+ Clash.Netlist.Types: tcCache :: Getter NetlistEnv TyConMap
- Clash.Primitives.DSL: tuple :: [TExpr] -> TExpr
+ Clash.Primitives.DSL: tuple :: HasCallStack => [TExpr] -> TExpr
- Clash.Primitives.DSL: unsignedFromBitVector :: Size -> Text -> TExpr -> State (BlockState VHDLState) TExpr
+ Clash.Primitives.DSL: unsignedFromBitVector :: HasCallStack => Size -> Text -> TExpr -> State (BlockState VHDLState) TExpr
- Clash.Primitives.DSL: unvec :: Backend backend => Text -> TExpr -> State (BlockState backend) [TExpr]
+ Clash.Primitives.DSL: unvec :: (HasCallStack, Backend backend) => Text -> TExpr -> State (BlockState backend) [TExpr]
- Clash.Rewrite.Types: bindings :: forall extra_a3VqS. Lens' (RewriteState extra_a3VqS) BindingMap
+ Clash.Rewrite.Types: bindings :: forall extra_a3VI0. Lens' (RewriteState extra_a3VI0) BindingMap
- Clash.Rewrite.Types: curFun :: forall extra_a3VqS. Lens' (RewriteState extra_a3VqS) (Id, SrcSpan)
+ Clash.Rewrite.Types: curFun :: forall extra_a3VI0. Lens' (RewriteState extra_a3VI0) (Id, SrcSpan)
- Clash.Rewrite.Types: extra :: forall extra_a3VqS extra_a3VyE. Lens (RewriteState extra_a3VqS) (RewriteState extra_a3VyE) extra_a3VqS extra_a3VyE
+ Clash.Rewrite.Types: extra :: forall extra_a3VI0 extra_a3VPM. Lens (RewriteState extra_a3VI0) (RewriteState extra_a3VPM) extra_a3VI0 extra_a3VPM
- Clash.Rewrite.Types: globalHeap :: forall extra_a3VqS. Lens' (RewriteState extra_a3VqS) PrimHeap
+ Clash.Rewrite.Types: globalHeap :: forall extra_a3VI0. Lens' (RewriteState extra_a3VI0) PrimHeap
- Clash.Rewrite.Types: nameCounter :: forall extra_a3VqS. Lens' (RewriteState extra_a3VqS) Int
+ Clash.Rewrite.Types: nameCounter :: forall extra_a3VI0. Lens' (RewriteState extra_a3VI0) Int
- Clash.Rewrite.Types: transformCounter :: forall extra_a3VqS. Lens' (RewriteState extra_a3VqS) Word
+ Clash.Rewrite.Types: transformCounter :: forall extra_a3VI0. Lens' (RewriteState extra_a3VI0) Word
- Clash.Rewrite.Types: transformCounters :: forall extra_a3VqS. Lens' (RewriteState extra_a3VqS) (HashMap Text Word)
+ Clash.Rewrite.Types: transformCounters :: forall extra_a3VI0. Lens' (RewriteState extra_a3VI0) (HashMap Text Word)
- Clash.Rewrite.Types: uniqSupply :: forall extra_a3VqS. Lens' (RewriteState extra_a3VqS) Supply
+ Clash.Rewrite.Types: uniqSupply :: forall extra_a3VI0. Lens' (RewriteState extra_a3VI0) Supply
- Clash.Rewrite.Types: workFreeBinders :: forall extra_a3VqS. Lens' (RewriteState extra_a3VqS) (VarEnv Bool)
+ Clash.Rewrite.Types: workFreeBinders :: forall extra_a3VI0. Lens' (RewriteState extra_a3VI0) (VarEnv Bool)
Files
- CHANGELOG.md +29/−0
- clash-lib.cabal +3/−3
- prims/common/GHC_Integer_Type.primitives.yaml +6/−6
- prims/common/GHC_Natural.primitives.yaml +4/−4
- prims/common/GHC_Num_Integer.primitives.yaml +9/−9
- prims/common/GHC_Num_Natural.primitives.yaml +2/−2
- prims/commonverilog/Clash_Promoted_Nat.primitives.yaml +1/−1
- prims/commonverilog/GHC_Integer_Logarithms.primitives.yaml +1/−1
- prims/commonverilog/GHC_Integer_Type.primitives.yaml +27/−27
- prims/commonverilog/GHC_Natural.primitives.yaml +3/−3
- prims/commonverilog/GHC_Num_Integer.primitives.yaml +29/−29
- prims/commonverilog/GHC_Num_Natural.primitives.yaml +11/−11
- prims/verilog/Clash_Intel_DDR.primitives.yaml +1/−1
- prims/vhdl/Clash_Sized_Internal_BitVector.primitives.yaml +3/−11
- prims/vhdl/Clash_Sized_Internal_Signed.primitives.yaml +2/−10
- prims/vhdl/Clash_Sized_Internal_Unsigned.primitives.yaml +2/−10
- prims/vhdl/GHC_Integer_Type.primitives.yaml +2/−10
- prims/vhdl/GHC_Natural.primitives.yaml +3/−3
- prims/vhdl/GHC_Num_Integer.primitives.yaml +2/−10
- prims/vhdl/GHC_Num_Natural.primitives.yaml +2/−10
- prims/vhdl/GHC_Prim.primitives.yaml +5/−25
- src/Clash/Annotations/BitRepresentation/ClashLib.hs +5/−1
- src/Clash/Backend/SystemVerilog.hs +1/−1
- src/Clash/Backend/VHDL.hs +18/−4
- src/Clash/Backend/Verilog.hs +1/−1
- src/Clash/Core/Evaluator/Types.hs +24/−4
- src/Clash/Driver.hs +1/−1
- src/Clash/Driver/Manifest.hs +8/−0
- src/Clash/Netlist.hs +20/−40
- src/Clash/Netlist/BlackBox.hs +25/−25
- src/Clash/Netlist/BlackBox/Parser.hs +7/−6
- src/Clash/Netlist/BlackBox/Types.hs +14/−4
- src/Clash/Netlist/BlackBox/Util.hs +80/−20
- src/Clash/Netlist/Types.hs +18/−10
- src/Clash/Netlist/Util.hs +10/−10
- src/Clash/Normalize/Transformations/DEC.hs +27/−10
- src/Clash/Primitives/DSL.hs +5/−4
- src/Clash/Primitives/Sized/ToInteger.hs +2/−2
- src/Clash/Primitives/Sized/Vector.hs +3/−3
- src/Clash/Primitives/Verification.hs +1/−1
CHANGELOG.md view
@@ -1,4 +1,33 @@ # Changelog for the Clash project+## 1.6.4 *Aug 30th 2022*+Fixed:++ * Input validation of the used arguments in blackboxes is now complete. [#2184](https://github.com/clash-lang/clash-compiler/pull/2184)+ * `Clash.Annotations.BitRepresentation.Deriving.deriveAnnotation` no longer has quadratic complexity in the size of the constructors and fields. [#2209](https://github.com/clash-lang/clash-compiler/pull/2209)+ * Fully resolve type synonyms when deriving bit representations. [#2209](https://github.com/clash-lang/clash-compiler/pull/2209)+ * Disregard ticks when determining whether terms are shared. Fixes [#2233](https://github.com/clash-lang/clash-compiler/issues/2233).+ * The blackbox parser will make sure it fully parses its input, and report an error when it can't. [#2237](https://github.com/clash-lang/clash-compiler/issues/2237)+ * Wrap ~ARG[n] in parentheses. Fixes [#2213](https://github.com/clash-lang/clash-compiler/issues/2213)+ * The VHDL shift primitives no longer generate bound check failures. Fixes [#2215](https://github.com/clash-lang/clash-compiler/issues/2215)+ * Evaluator fails impredicative type instantiation of error values [#2272](https://github.com/clash-lang/clash-compiler/issues/2272)+ * Fix out of bound errors in toEnum/fromSLV for sum types [#2220](https://github.com/clash-lang/clash-compiler/issues/2220)+ * Netlist generation fails for certain uses of GADTs [#2289](https://github.com/clash-lang/clash-compiler/issues/2289)+ * The documentation for `ANN TestBench` had it backwards; it now correctly indicates the annotation is on the test bench, not the device under test. [#1750](https://github.com/clash-lang/clash-compiler/issues/1750)++Fixes with minor changes:++ * `reduceXor` now produces a result if the argument has undefined bits instead of throwing an `XException` (the result is an undefined bit). `reduceAnd` and `reduceOr` already always produced a result. [#2244](https://github.com/clash-lang/clash-compiler/pull/2244)++Added:++ * Support for symbols in types while deriving bit representations. [#2209](https://github.com/clash-lang/clash-compiler/pull/2209)+ * Support for promoted data types while deriving bit representations. [#2209](https://github.com/clash-lang/clash-compiler/pull/2209)+ * `scanlPar` and `scanrPar` in Clash's Prelude, as well as the `RTree` versions `tscanl` and `tscanr`. These variants of `scanl1` and `scanr1` compile to a binary tree of operations, with a depth of `O(log(n))` (`n` being the length of the vector) rather than a depth of `n` for `scanl1` and `scanr1`. [#2177](https://github.com/clash-lang/clash-compiler/pull/2177)+ * The GADT constructors for `RTree` (`RLeaf` and `RBranch`) are now exported directly in addition to the patterns `LR` and `BR`. [#2177](https://github.com/clash-lang/clash-compiler/pull/2177)+ * Added the `~ISSCALAR` template which can be used to check if an argument is rendered to a scalar in HDL. [#2184](https://github.com/clash-lang/clash-compiler/pull/2184)+ * Added support for records and infix constructors when using `Clash.Annotations.BitRepresentation.Deriving.deriveAnnotation`. [#2191](https://github.com/clash-lang/clash-compiler/pull/2191)+ * Clash now contains instances for `ShowX`, `NFDataX` and `BitPack` on the newtypes from the Data.Functor modules (`Identity`, `Const`, `Compose`, `Product` and `Sum`). [#2218](https://github.com/clash-lang/clash-compiler/issues/2218)+ ## 1.6.3 *Apr 7th 2022* Fixed: * Handle `~ISUNDEFINED` hole in black boxes for `BitVector` and for product types. This means that with `-fclash-aggressive-x-optimization-blackboxes`, resets are now omitted for _undefined_ reset values of such types as well. [#2117](https://github.com/clash-lang/clash-compiler/issues/2117)
clash-lib.cabal view
@@ -1,6 +1,6 @@ Cabal-version: 2.2 Name: clash-lib-Version: 1.6.3+Version: 1.6.4 Synopsis: Clash: a functional hardware description language - As a library Description: Clash is a functional hardware description language that borrows both its@@ -136,7 +136,7 @@ base16-bytestring >= 0.1.1 && < 1.1, binary >= 0.8.5 && < 0.11, bytestring >= 0.10.0.2 && < 0.12,- clash-prelude == 1.6.3,+ clash-prelude == 1.6.4, concurrent-supply >= 0.1.7 && < 0.2, containers >= 0.5.0.0 && < 0.7, cryptohash-sha256 >= 0.11 && < 0.12,@@ -154,7 +154,7 @@ haskell-src-meta >= 0.8 && < 0.9, hint >= 0.7 && < 0.10, interpolate >= 0.2.0 && < 1.0,- lens >= 4.10 && < 5.1.0,+ lens >= 4.10 && < 5.2.0, mtl >= 2.1.2 && < 2.3, ordered-containers >= 0.2 && < 0.3, prettyprinter >= 1.2.0.1 && < 1.8,
prims/common/GHC_Integer_Type.primitives.yaml view
@@ -5,7 +5,7 @@ Integer -> Integer -> Integer' template: ~ARG[0] + ~ARG[1] warning: 'GHC.Integer.Type.plusInteger: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Integer.Type.minusInteger kind: Expression@@ -13,7 +13,7 @@ Integer -> Integer -> Integer' template: ~ARG[0] - ~ARG[1] warning: 'GHC.Integer.Type.minusInteger: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Integer.Type.leInteger kind: Expression@@ -21,7 +21,7 @@ -> Integer -> Bool' template: ~ARG[0] <= ~ARG[1] warning: 'GHC.Integer.Type.leInteger: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Integer.Type.gtInteger kind: Expression@@ -29,7 +29,7 @@ -> Integer -> Bool' template: ~ARG[0] > ~ARG[1] warning: 'GHC.Integer.Type.gtInteger: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Integer.Type.ltInteger kind: Expression@@ -37,7 +37,7 @@ -> Integer -> Bool' template: ~ARG[0] < ~ARG[1] warning: 'GHC.Integer.Type.ltInteger: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Integer.Type.geInteger kind: Expression@@ -45,4 +45,4 @@ -> Integer -> Bool' template: ~ARG[0] >= ~ARG[1] warning: 'GHC.Integer.Type.geInteger: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.'
prims/common/GHC_Natural.primitives.yaml view
@@ -3,7 +3,7 @@ comment: Needed to make the evaluator handle this constructor strictly primType: Constructor warning: 'GHC.Natural.NatS#: Naturals are dynamically sized in simulation, but- fixed-length after synthesization. Use carefully.'+ fixed-length after synthesis. Use carefully.' workInfo: Never - Primitive: name: GHC.Natural.naturalToInteger@@ -25,7 +25,7 @@ Natural -> Natural -> Natural' template: ~ARG[0] + ~ARG[1] warning: 'GHC.Natural.plusNatural: Naturals are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Natural.minusNatural kind: Expression@@ -33,10 +33,10 @@ Natural -> Natural -> Natural' template: ~ARG[0] - ~ARG[1] warning: 'GHC.Natural.minusNatural: Naturals are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - Primitive: name: GHC.Natural.gcdNatural primType: Function warning: 'GHC.Natural.gcdNatural: Naturals are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' workInfo: Never
prims/common/GHC_Num_Integer.primitives.yaml view
@@ -3,21 +3,21 @@ comment: Needed to make the evaluator handle this constructor strictly primType: Constructor warning: 'GHC.Num.Integer.IS: Integers are dynamically sized in simulation, but- fixed-length after synthesization. Use carefully.'+ fixed-length after synthesis. Use carefully.' workInfo: Never - Primitive: name: GHC.Num.Integer.IP comment: Needed to make the evaluator handle this constructor strictly primType: Constructor warning: 'GHC.Num.Integer.IP: Integers are dynamically sized in simulation, but- fixed-length after synthesization. Use carefully.'+ fixed-length after synthesis. Use carefully.' workInfo: Never - Primitive: name: GHC.Num.Integer.IN comment: Needed to make the evaluator handle this constructor strictly primType: Constructor warning: 'GHC.Num.Integer.IN: Integers are dynamically sized in simulation, but- fixed-length after synthesization. Use carefully.'+ fixed-length after synthesis. Use carefully.' workInfo: Never - Primitive: name: GHC.Num.Integer.integerFromNatural@@ -32,7 +32,7 @@ -> Integer -> Integer' template: ~ARG[0] + ~ARG[1] warning: 'GHC.Num.Integer.integerAdd: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Integer.integerSub kind: Expression@@ -40,7 +40,7 @@ -> Integer -> Integer' template: ~ARG[0] - ~ARG[1] warning: 'GHC.Num.Integer.integerSub: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Integer.integerLe kind: Expression@@ -48,7 +48,7 @@ -> Integer -> Bool' template: ~ARG[0] <= ~ARG[1] warning: 'GHC.Num.Integer.integerLe: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Integer.integerGt kind: Expression@@ -56,7 +56,7 @@ -> Integer -> Bool' template: ~ARG[0] > ~ARG[1] warning: 'GHC.Num.Integer.integerGt: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Integer.integerLt kind: Expression@@ -64,7 +64,7 @@ -> Integer -> Bool' template: ~ARG[0] < ~ARG[1] warning: 'GHC.Num.Integer.integerLt: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Integer.integerGe kind: Expression@@ -72,4 +72,4 @@ -> Integer -> Bool' template: ~ARG[0] >= ~ARG[1] warning: 'GHC.Num.Integer.integerGe: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.'
prims/common/GHC_Num_Natural.primitives.yaml view
@@ -3,14 +3,14 @@ comment: Needed to make the evaluator handle this constructor strictly primType: Constructor warning: 'GHC.Num.Natural.NS: Naturals are dynamically sized in simulation, but- fixed-length after synthesization. Use carefully.'+ fixed-length after synthesis. Use carefully.' workInfo: Never - Primitive: name: GHC.Num.Natural.NB comment: Needed to make the evaluator handle this constructor strictly primType: Constructor warning: 'GHC.Num.Natural.NB: Naturals are dynamically sized in simulation, but- fixed-length after synthesization. Use carefully.'+ fixed-length after synthesis. Use carefully.' workInfo: Never - BlackBox: name: GHC.Num.Natural.naturalAdd
prims/commonverilog/Clash_Promoted_Nat.primitives.yaml view
@@ -34,7 +34,7 @@ function integer ~INCLUDENAME[0]; input integer base, value; begin- for (~INCLUDENAME[0] = 0; base ** ~INCLUDENAME[0] < value; ~~INCLUDENAME[0]=~INCLUDENAME[0]+1);+ for (~INCLUDENAME[0] = 0; base ** ~INCLUDENAME[0] < value; ~INCLUDENAME[0]=~INCLUDENAME[0]+1); end endfunction kind: Expression
prims/commonverilog/GHC_Integer_Logarithms.primitives.yaml view
@@ -19,4 +19,4 @@ :: Integer -> Integer -> Int#' template: ~INCLUDENAME[0](~ARG[0],~ARG[1]) warning: 'GHC.Integer.Logarithms.integerLogBase#: Integers are dynamically sized- in simulation, but fixed-length after synthesization. Use carefully.'+ in simulation, but fixed-length after synthesis. Use carefully.'
prims/commonverilog/GHC_Integer_Type.primitives.yaml view
@@ -5,7 +5,7 @@ Int# -> Integer' template: assign ~RESULT = $signed(~ARG[0]); warning: 'GHC.Integer.Type.smallInteger: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' workInfo: Never - BlackBox: name: GHC.Integer.Type.integerToInt@@ -14,7 +14,7 @@ Integer -> Int#' template: assign ~RESULT = $signed(~ARG[0]); warning: 'GHC.Integer.Type.integerToInt: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' workInfo: Never - BlackBox: name: GHC.Integer.Type.timesInteger@@ -23,7 +23,7 @@ Integer -> Integer -> Integer' template: ~ARG[0] * ~ARG[1] warning: 'GHC.Integer.Type.timesInteger: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Integer.Type.negateInteger kind: Expression@@ -31,7 +31,7 @@ Integer -> Integer' template: -~ARG[0] warning: 'GHC.Integer.Type.negateInteger: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Integer.Type.absInteger kind: Expression@@ -39,7 +39,7 @@ -> Integer' template: '(~ARG[0] < ~SIZE[~TYPO]''sd0) ? -~ARG[0] : ~ARG[0]' warning: 'GHC.Integer.Type.absInteger: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Integer.Type.remInteger kind: Expression@@ -47,7 +47,7 @@ -> Integer -> Integer' template: ~ARG[0] % ~ARG[1] warning: 'GHC.Integer.Type.remInteger: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Integer.Type.eqInteger kind: Expression@@ -55,7 +55,7 @@ -> Integer -> Bool' template: ~ARG[0] == ~ARG[1] warning: 'GHC.Integer.Type.eqInteger: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Integer.Type.neqInteger kind: Expression@@ -63,7 +63,7 @@ -> Integer -> Bool' template: ~ARG[0] != ~ARG[1] warning: 'GHC.Integer.Type.neqInteger: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Integer.Type.eqInteger# kind: Expression@@ -71,7 +71,7 @@ -> Integer -> Bool' template: '(~ARG[0] == ~ARG[1]) ? ~SIZE[~TYPO]''sd1 : ~SIZE[~TYPO]''sd0' warning: 'GHC.Integer.Type.eqInteger#: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Integer.Type.neqInteger# kind: Expression@@ -79,7 +79,7 @@ -> Integer -> Bool' template: '(~ARG[0] != ~ARG[1]) ? ~SIZE[~TYPO]''sd1 : ~SIZE[~TYPO]''sd0' warning: 'GHC.Integer.Type.neqInteger#: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Integer.Type.leInteger# kind: Expression@@ -87,7 +87,7 @@ -> Integer -> Bool' template: '(~ARG[0] <= ~ARG[1]) ? ~SIZE[~TYPO]''sd1 : ~SIZE[~TYPO]''sd0' warning: 'GHC.Integer.Type.leInteger#: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Integer.Type.gtInteger# kind: Expression@@ -95,7 +95,7 @@ -> Integer -> Bool' template: '(~ARG[0] > ~ARG[1] ? ~SIZE[~TYPO]''sd1 : ~SIZE[~TYPO]''sd0' warning: 'GHC.Integer.Type.gtInteger#: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Integer.Type.ltInteger# kind: Expression@@ -103,7 +103,7 @@ -> Integer -> Bool' template: '(~ARG[0] < ~ARG[1]) ? ~SIZE[~TYPO]''sd1 : ~SIZE[~TYPO]''sd0' warning: 'GHC.Integer.Type.ltInteger#: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Integer.Type.geInteger# kind: Expression@@ -111,7 +111,7 @@ -> Integer -> Bool' template: '(~ARG[0] >= ~ARG[1]) ? ~SIZE[~TYPO]''sd1 : ~SIZE[~TYPO]''sd0' warning: 'GHC.Integer.Type.geInteger#: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Integer.Type.shiftRInteger kind: Expression@@ -119,7 +119,7 @@ Integer -> Int# -> Integer' template: ~ARG[0] >>> ~ARG[1] warning: 'GHC.Integer.Type.shiftRInteger: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Integer.Type.shiftLInteger kind: Expression@@ -127,7 +127,7 @@ Integer -> Int# -> Integer' template: ~ARG[0] <<< ~ARG[1] warning: 'GHC.Integer.Type.shiftLInteger: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Integer.Type.testBitInteger kind: Expression@@ -135,7 +135,7 @@ :: Integer -> Int# -> Bool' template: ~VAR[input][0][~ARG[1]] == 1'b1 warning: 'GHC.Integer.Type.testBitInteger: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Integer.Type.wordToInteger kind: Declaration@@ -143,7 +143,7 @@ Word# -> Integer' template: assign ~RESULT = $signed(~ARG[0]); warning: 'GHC.Integer.Type.wordToInteger: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' workInfo: Never - BlackBox: name: GHC.Integer.Type.integerToWord@@ -152,7 +152,7 @@ Integer -> Word#' template: assign ~RESULT = $unsigned(~ARG[0]); warning: 'GHC.Integer.Type.integerToWord: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' workInfo: Never - BlackBox: name: GHC.Integer.Type.integerToWord64@@ -162,7 +162,7 @@ Integer -> Word64#' template: assign ~RESULT = $unsigned(~ARG[0]); warning: 'GHC.Integer.Type.integerToWord64: Integers are dynamically sized in- simulation, but fixed-length after synthesization. Use carefully.'+ simulation, but fixed-length after synthesis. Use carefully.' workInfo: Never - BlackBox: name: GHC.Integer.Type.bitInteger@@ -171,7 +171,7 @@ -> Integer' template: 1 << ~ARG[0] warning: 'GHC.Integer.Type.bitInteger: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Integer.Type.complementInteger kind: Expression@@ -179,7 +179,7 @@ :: Integer -> Integer' template: ~ ~ARG[0] warning: 'GHC.Integer.Type.complementInteger: Integers are dynamically sized in- simulation, but fixed-length after synthesization. Use carefully.'+ simulation, but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Integer.Type.xorInteger kind: Expression@@ -187,7 +187,7 @@ -> Integer -> Integer' template: ~ARG[0] ^ ~ARG[1] warning: 'GHC.Integer.Type.xorInteger: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Integer.Type.orInteger kind: Expression@@ -195,7 +195,7 @@ -> Integer -> Integer' template: ~ARG[0] | ~ARG[1] warning: 'GHC.Integer.Type.orInteger: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Integer.Type.andInteger kind: Expression@@ -203,7 +203,7 @@ -> Integer -> Integer' template: ~ARG[0] & ~ARG[1] warning: 'GHC.Integer.Type.andInteger: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Integer.Type.$wsignumInteger kind: Expression@@ -212,7 +212,7 @@ template: '(~ARG[0] < ~SIZE[~TYPO]''sd0) ? -~SIZE[~TYPO]''sd1 : ((~ARG[0] == ~SIZE[~TYPO]''sd0) ? ~SIZE[~TYPO]''sd0 : ~SIZE[~TYPO]''sd1)' warning: 'GHC.Integer.Type.$wsignumInteger: Integers are dynamically sized in- simulation, but fixed-length after synthesization. Use carefully.'+ simulation, but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Integer.Type.quotInteger kind: Expression@@ -220,4 +220,4 @@ Integer -> Integer -> Integer' template: ~ARG[0] / ~ARG[1] warning: 'GHC.Integer.Type.quotInteger: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.'
prims/commonverilog/GHC_Natural.primitives.yaml view
@@ -5,7 +5,7 @@ :: Integer -> Natural' template: $unsigned(~VAR[n][0][(~SIZE[~TYPO]-1):0]) warning: 'GHC.Natural.naturalFromInteger: Naturals are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' workInfo: Never - BlackBox: name: GHC.Natural.timesNatural@@ -14,7 +14,7 @@ Natural -> Natural -> Natural' template: ~ARG[0] * ~ARG[1] warning: 'GHC.Natural.timesNatural: Naturals are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Natural.wordToNatural# kind: Declaration@@ -22,5 +22,5 @@ :: Word# -> Natural' template: assign ~RESULT = $unsigned(~ARG[0]); warning: 'GHC.Natural.wordToNatural#: Naturals are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' workInfo: Never
prims/commonverilog/GHC_Num_Integer.primitives.yaml view
@@ -32,7 +32,7 @@ Integer -> Int#' template: assign ~RESULT = $signed(~ARG[0]); warning: 'GHC.Num.Integer.integerToInt#: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' workInfo: Never - BlackBox: name: GHC.Num.Integer.integerMul@@ -41,7 +41,7 @@ -> Integer -> Integer' template: ~ARG[0] * ~ARG[1] warning: 'GHC.Num.Integer.integerMul: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Integer.integerNegate kind: Expression@@ -49,7 +49,7 @@ Integer -> Integer' template: -~ARG[0] warning: 'GHC.Num.Integer.integerNegate: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Integer.integerAbs kind: Expression@@ -57,7 +57,7 @@ -> Integer' template: '(~ARG[0] < ~SIZE[~TYPO]''sd0) ? -~ARG[0] : ~ARG[0]' warning: 'GHC.Num.Integer.integerAbs: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Integer.integerRem kind: Expression@@ -65,7 +65,7 @@ -> Integer -> Integer' template: ~ARG[0] % ~ARG[1] warning: 'GHC.Num.Integer.integerRem: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Integer.integerEq kind: Expression@@ -73,7 +73,7 @@ -> Integer -> Bool' template: ~ARG[0] == ~ARG[1] warning: 'GHC.Num.Integer.integerEq: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Integer.integerNe kind: Expression@@ -81,7 +81,7 @@ -> Integer -> Bool' template: ~ARG[0] != ~ARG[1] warning: 'GHC.Num.Integer.integerNe: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Integer.integerEq# kind: Expression@@ -89,7 +89,7 @@ -> Integer -> Int#' template: '(~ARG[0] == ~ARG[1]) ? ~SIZE[~TYPO]''sd1 : ~SIZE[~TYPO]''sd0' warning: 'GHC.Num.Integer.integerEq#: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Integer.integerNe# kind: Expression@@ -97,7 +97,7 @@ -> Integer -> Int#' template: '(~ARG[0] != ~ARG[1]) ? ~SIZE[~TYPO]''sd1 : ~SIZE[~TYPO]''sd0' warning: 'GHC.Num.Integer.integerNe#: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Integer.integerLe# kind: Expression@@ -105,7 +105,7 @@ -> Integer -> Int#' template: '(~ARG[0] <= ~ARG[1]) ? ~SIZE[~TYPO]''sd1 : ~SIZE[~TYPO]''sd0' warning: 'GHC.Num.Integer.integerLe#: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Integer.integerGt# kind: Expression@@ -113,7 +113,7 @@ -> Integer -> Int#' template: '(~ARG[0] > ~ARG[1] ? ~SIZE[~TYPO]''sd1 : ~SIZE[~TYPO]''sd0' warning: 'GHC.Num.Integer.integerGt#: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Integer.integerLt# kind: Expression@@ -121,7 +121,7 @@ -> Integer -> Int#' template: '(~ARG[0] < ~ARG[1]) ? ~SIZE[~TYPO]''sd1 : ~SIZE[~TYPO]''sd0' warning: 'GHC.Num.Integer.integerLt#: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Integer.integerGe# kind: Expression@@ -129,7 +129,7 @@ -> Integer -> Int#' template: '(~ARG[0] >= ~ARG[1]) ? ~SIZE[~TYPO]''sd1 : ~SIZE[~TYPO]''sd0' warning: 'GHC.Num.Integer.integerGe#: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Integer.integerShiftR# kind: Expression@@ -137,7 +137,7 @@ Integer -> Word# -> Integer' template: ~ARG[0] >>> ~ARG[1] warning: 'GHC.Num.Integer.integerShiftR#: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Integer.integerShiftL# kind: Expression@@ -145,7 +145,7 @@ Integer -> Word# -> Integer' template: ~ARG[0] <<< ~ARG[1] warning: 'GHC.Num.Integer.integerShiftL#: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Integer.integerTestBit# kind: Expression@@ -153,7 +153,7 @@ :: Integer -> Word# -> Bool' template: ~VAR[input][0][~ARG[1]] == 1'b1 warning: 'GHC.Num.Integer.integerTestBit#: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Integer.integerFromWord# kind: Declaration@@ -161,7 +161,7 @@ :: Word# -> Integer' template: assign ~RESULT = $signed(~ARG[0]); warning: 'GHC.Num.Integer.integerFromWord#: Integers are dynamically sized in- simulation, but fixed-length after synthesization. Use carefully.'+ simulation, but fixed-length after synthesis. Use carefully.' workInfo: Never - BlackBox: name: GHC.Num.Integer.integerToWord#@@ -170,7 +170,7 @@ :: Integer -> Word#' template: assign ~RESULT = $unsigned(~ARG[0]); warning: 'GHC.Num.Integer.integerToWord#: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' workInfo: Never - BlackBox: name: GHC.Num.Integer.integerToWord64#@@ -180,7 +180,7 @@ :: Integer -> Word64#' template: assign ~RESULT = $unsigned(~ARG[0]); warning: 'GHC.Num.Integer.integerToWord64#: Integers are dynamically sized in- simulation, but fixed-length after synthesization. Use carefully.'+ simulation, but fixed-length after synthesis. Use carefully.' workInfo: Never - BlackBox: name: GHC.Num.Integer.integerBit#@@ -189,7 +189,7 @@ Word# -> Integer' template: 1 << ~ARG[0] warning: 'GHC.Num.Integer.integerBit#: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Integer.integerComplement kind: Expression@@ -197,7 +197,7 @@ :: Integer -> Integer' template: ~ ~ARG[0] warning: 'GHC.Num.Integer.integerComplement: Integers are dynamically sized in- simulation, but fixed-length after synthesization. Use carefully.'+ simulation, but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Integer.integerXor kind: Expression@@ -205,7 +205,7 @@ -> Integer -> Integer' template: ~ARG[0] ^ ~ARG[1] warning: 'GHC.Num.Integer.integerXor: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Integer.integerOr kind: Expression@@ -213,7 +213,7 @@ -> Integer -> Integer' template: ~ARG[0] | ~ARG[1] warning: 'GHC.Num.Integer.integerOr: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Integer.integerAnd kind: Expression@@ -221,7 +221,7 @@ -> Integer -> Integer' template: ~ARG[0] & ~ARG[1] warning: 'GHC.Num.Integer.integerAnd: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Integer.integerSignum kind: Expression@@ -230,7 +230,7 @@ template: '(~ARG[0] < ~SIZE[~TYPO]''sd0) ? -~SIZE[~TYPO]''sd1 : ((~ARG[0] == ~SIZE[~TYPO]''sd0) ? ~SIZE[~TYPO]''sd0 : ~SIZE[~TYPO]''sd1)' warning: 'GHC.Num.Integer.integerSignum: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Integer.$wintegerSignum kind: Expression@@ -239,7 +239,7 @@ template: '(~ARG[0] < ~SIZE[~TYPO]''sd0) ? -~SIZE[~TYPO]''sd1 : ((~ARG[0] == ~SIZE[~TYPO]''sd0) ? ~SIZE[~TYPO]''sd0 : ~SIZE[~TYPO]''sd1)' warning: 'GHC.Num.Integer.$wintegerSignum: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Integer.integerLogBase# imports:@@ -261,7 +261,7 @@ :: Integer -> Integer -> Word#' template: ~INCLUDENAME[0](~ARG[0],~ARG[1]) warning: 'GHC.Num.Integer.integerLogBase#: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Integer.integerCompare kind: Expression@@ -270,7 +270,7 @@ template: '(~ARG[0] < ~ARG[1]) ? -~SIZE[~TYPO]''d0 : ((~ARG[0] == ~ARG[1]) ? ~SIZE[~TYPO]''d1 : ~SIZE[~TYPO]''d2)' warning: 'GHC.Num.Integer.integerCompare: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Integer.integerQuot kind: Expression@@ -278,4 +278,4 @@ Integer -> Integer -> Integer' template: ~ARG[0] / ~ARG[1] warning: 'GHC.Num.Integer.integerQuot: Integers are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.'
prims/commonverilog/GHC_Num_Natural.primitives.yaml view
@@ -22,7 +22,7 @@ -> Natural -> Natural' template: ~ARG[0] % ~ARG[1] warning: 'GHC.Num.Natural.naturalRem: Naturals are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Natural.naturalLogBase# imports:@@ -44,7 +44,7 @@ :: Natural -> Natural -> Word#' template: ~INCLUDENAME[0](~ARG[0],~ARG[1]) warning: 'GHC.Num.Natural.naturalLogBase#: Naturals are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Natural.naturalEq# kind: Expression@@ -52,7 +52,7 @@ -> Natural -> Int#' template: '(~ARG[0] == ~ARG[1]) ? ~SIZE[~TYPO]''d1 : ~SIZE[~TYPO]''d0' warning: 'GHC.Num.Natural.naturalEq#: Naturals are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Natural.naturalNe# kind: Expression@@ -60,7 +60,7 @@ -> Natural -> Int#' template: '(~ARG[0] != ~ARG[1]) ? ~SIZE[~TYPO]''d1 : ~SIZE[~TYPO]''d0' warning: 'GHC.Num.Natural.naturalNe#: Naturals are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Natural.naturalLe# kind: Expression@@ -68,7 +68,7 @@ -> Natural -> Int#' template: '(~ARG[0] <= ~ARG[1]) ? ~SIZE[~TYPO]''d1 : ~SIZE[~TYPO]''d0' warning: 'GHC.Num.Natural.naturalLe#: Naturals are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Natural.naturalGt# kind: Expression@@ -76,7 +76,7 @@ -> Natural -> Int#' template: '(~ARG[0] > ~ARG[1] ? ~SIZE[~TYPO]''d1 : ~SIZE[~TYPO]''d0' warning: 'GHC.Num.Natural.naturalGt#: Naturals are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Natural.naturalLt# kind: Expression@@ -84,7 +84,7 @@ -> Natural -> Int#' template: '(~ARG[0] < ~ARG[1]) ? ~SIZE[~TYPO]''d1 : ~SIZE[~TYPO]''d0' warning: 'GHC.Num.Natural.naturalLt#: Naturals are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Natural.naturalGe# kind: Expression@@ -92,7 +92,7 @@ -> Natural -> Int#' template: '(~ARG[0] >= ~ARG[1]) ? ~SIZE[~TYPO]''d1 : ~SIZE[~TYPO]''d0' warning: 'GHC.Num.Natural.naturalGe#: Naturals are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Natural.naturalShiftL# kind: Expression@@ -100,7 +100,7 @@ :: Natural -> Word# -> Natural' template: ~ARG[0] <<< ~ARG[1] warning: 'GHC.Num.Natural.naturalShiftL#: Naturals are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Natural.naturalShiftR# kind: Expression@@ -108,7 +108,7 @@ :: Natuarl -> Word# -> Natural' template: ~ARG[0] >>> ~ARG[1] warning: 'GHC.Num.Natural.naturalShiftR#: Naturals are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Natural.NaturalCompare kind: Expression@@ -117,7 +117,7 @@ template: '(~ARG[0] < ~ARG[1]) ? -~SIZE[~TYPO]''d0 : ((~ARG[0] == ~ARG[1]) ? ~SIZE[~TYPO]''d1 : ~SIZE[~TYPO]''d2)' warning: 'GHC.Num.Natural.naturalCompare: Naturals are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' - BlackBox: name: GHC.Num.Natural.naturalQuot kind: Expression
prims/verilog/Clash_Intel_DDR.primitives.yaml view
@@ -34,7 +34,7 @@ .aclr (1'b0),~ELSE .aclr (~ARG[6]), .sclr (1'b0),~FI- .datain (~ARG[8]),~+ .datain (~ARG[8]), .inclock (~ARG[5]), .inclocken (~IF ~ISACTIVEENABLE[7] ~THEN ~ARG[7] ~ELSE 1'b1 ~FI), .dataout_h (~SYM[2]),
prims/vhdl/Clash_Sized_Internal_BitVector.primitives.yaml view
@@ -78,7 +78,7 @@ kind: Expression type: 'toEnum## :: Int -> Bit'- template: ~ARG[0](0)+ template: ~VAR[i][0](0) workInfo: Never - BlackBox: name: Clash.Sized.Internal.BitVector.and##@@ -518,11 +518,7 @@ -- pragma translate_off natural'high when (~VAR[shI][2](~SIZE[~TYP[2]]-1 downto 31) /= 0) else -- pragma translate_on- to_integer(~VAR[shI][2]- -- pragma translate_off- (30 downto 0)- -- pragma translate_on- );+ to_integer(~VAR[shI][2]); ~RESULT <= std_logic_vector(shift_left(unsigned(~ARG[1]),~SYM[1])) -- pragma translate_off when (~ARG[2] >= 0) else (others => 'X')@@ -542,11 +538,7 @@ -- pragma translate_off natural'high when (~VAR[shI][2](~SIZE[~TYP[2]]-1 downto 31) /= 0) else -- pragma translate_on- to_integer(~VAR[shI][2]- -- pragma translate_off- (30 downto 0)- -- pragma translate_on- );+ to_integer(~VAR[shI][2]); ~RESULT <= std_logic_vector(shift_right(unsigned(~ARG[1]),~SYM[1])) -- pragma translate_off when (~ARG[2] >= 0) else (others => 'X')
prims/vhdl/Clash_Sized_Internal_Signed.primitives.yaml view
@@ -224,11 +224,7 @@ -- pragma translate_off natural'high when (~VAR[shI][2](~SIZE[~TYP[2]]-1 downto 31) /= 0) else -- pragma translate_on- to_integer(~VAR[shI][2]- -- pragma translate_off- (30 downto 0)- -- pragma translate_on- );+ to_integer(~VAR[shI][2]); ~RESULT <= shift_left(~ARG[1],~SYM[1]) -- pragma translate_off when (~ARG[2] >= 0) else (others => 'X')@@ -248,11 +244,7 @@ -- pragma translate_off natural'high when (~VAR[shI][2](~SIZE[~TYP[2]]-1 downto 31) /= 0) else -- pragma translate_on- to_integer(~VAR[shI][2]- -- pragma translate_off- (30 downto 0)- -- pragma translate_on- );+ to_integer(~VAR[shI][2]); ~RESULT <= shift_right(~ARG[1],~SYM[1]) -- pragma translate_off when (~ARG[2] >= 0) else (others => 'X')
prims/vhdl/Clash_Sized_Internal_Unsigned.primitives.yaml view
@@ -177,11 +177,7 @@ -- pragma translate_off natural'high when (~VAR[shI][2](~SIZE[~TYP[2]]-1 downto 31) /= 0) else -- pragma translate_on- to_integer(~VAR[shI][2]- -- pragma translate_off- (30 downto 0)- -- pragma translate_on- );+ to_integer(~VAR[shI][2]); ~RESULT <= shift_left(~ARG[1],~SYM[1]) -- pragma translate_off when (~ARG[2] >= 0) else (others => 'X')@@ -201,11 +197,7 @@ -- pragma translate_off natural'high when (~VAR[shI][2](~SIZE[~TYP[2]]-1 downto 31) /= 0) else -- pragma translate_on- to_integer(~VAR[shI][2]- -- pragma translate_off- (30 downto 0)- -- pragma translate_on- );+ to_integer(~VAR[shI][2]); ~RESULT <= shift_right(~ARG[1],~SYM[1]) -- pragma translate_off when (~ARG[2] >= 0) else (others => 'X')
prims/vhdl/GHC_Integer_Type.primitives.yaml view
@@ -215,11 +215,7 @@ -- pragma translate_off natural'high when (~VAR[shI][1](~SIZE[~TYP[1]]-1 downto 31) /= 0) else -- pragma translate_on- to_integer(~VAR[shI][1]- -- pragma translate_off- (30 downto 0)- -- pragma translate_on- );+ to_integer(~VAR[shI][1]); ~RESULT <= shift_right(~ARG[0],~SYM[1]) -- pragma translate_off when (~ARG[1] >= 0) else (others => 'X')@@ -241,11 +237,7 @@ -- pragma translate_off natural'high when (~VAR[shI][1](~SIZE[~TYP[1]]-1 downto 31) /= 0) else -- pragma translate_on- to_integer(~VAR[shI][1]- -- pragma translate_off- (30 downto 0)- -- pragma translate_on- );+ to_integer(~VAR[shI][1]); ~RESULT <= shift_left(~ARG[0],~SYM[1]) -- pragma translate_off when (~ARG[1] >= 0) else (others => 'X')
prims/vhdl/GHC_Natural.primitives.yaml view
@@ -5,7 +5,7 @@ :: Integer -> Natural' template: resize(unsigned(std_logic_vector(~ARG[0])),~SIZE[~TYPO]) warning: 'GHC.Natural.naturalFromInteger: Naturals are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' workInfo: Never - BlackBox: name: GHC.Natural.timesNatural@@ -14,7 +14,7 @@ Natural -> Natural -> Natural' template: resize(~ARG[0] * ~ARG[1],~SIZE[~TYPO]) warning: 'GHC.Natural.timesNatural: Naturals are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' workInfo: Never - BlackBox: name: GHC.Natural.wordToNatural#@@ -23,5 +23,5 @@ :: Word# -> Natural' template: unsigned(std_logic_vector(~ARG[0])) warning: 'GHC.Natural.wordToNatural#: Naturals are dynamically sized in simulation,- but fixed-length after synthesization. Use carefully.'+ but fixed-length after synthesis. Use carefully.' workInfo: Never
prims/vhdl/GHC_Num_Integer.primitives.yaml view
@@ -241,11 +241,7 @@ -- pragma translate_off natural'high when (~VAR[shI][1](~SIZE[~TYP[1]]-1 downto 31) /= 0) else -- pragma translate_on- to_integer(~VAR[shI][1]- -- pragma translate_off- (30 downto 0)- -- pragma translate_on- );+ to_integer(~VAR[shI][1]); ~RESULT <= shift_right(~ARG[0],~SYM[1]); end block; warning: 'GHC.Num.Integer.integerShiftR#: Integers are dynamically sized in simulation,@@ -263,11 +259,7 @@ -- pragma translate_off natural'high when (~VAR[shI][1](~SIZE[~TYP[1]]-1 downto 31) /= 0) else -- pragma translate_on- to_integer(~VAR[shI][1]- -- pragma translate_off- (30 downto 0)- -- pragma translate_on- );+ to_integer(~VAR[shI][1]); ~RESULT <= shift_left(~ARG[0],~SYM[1]); end block; warning: 'GHC.Num.Integer.integerShiftL#: Integers are dynamically sized in simulation,
prims/vhdl/GHC_Num_Natural.primitives.yaml view
@@ -100,11 +100,7 @@ -- pragma translate_off natural'high when (~VAR[shI][1](~SIZE[~TYP[1]]-1 downto 31) /= 0) else -- pragma translate_on- to_integer(~VAR[shI][1]- -- pragma translate_off- (30 downto 0)- -- pragma translate_on- );+ to_integer(~VAR[shI][1]); ~RESULT <= shift_left(~ARG[0],~SYM[1]); end block; warning: 'GHC.Num.Natural.naturalShiftL#: Naturals are dynamically sized in simulation,@@ -122,11 +118,7 @@ -- pragma translate_off natural'high when (~VAR[shI][1](~SIZE[~TYP[1]]-1 downto 31) /= 0) else -- pragma translate_on- to_integer(~VAR[shI][1]- -- pragma translate_off- (30 downto 0)- -- pragma translate_on- );+ to_integer(~VAR[shI][1]); ~RESULT <= shift_right(~ARG[0],~SYM[1]); end block; warning: 'GHC.Num.Natural.naturalShiftR#: Naturals are dynamically sized in simulation,
prims/vhdl/GHC_Prim.primitives.yaml view
@@ -162,11 +162,7 @@ -- pragma translate_off natural'high when (~VAR[shI][1](~SIZE[~TYP[1]]-1 downto 31) /= 0) else -- pragma translate_on- to_integer(~VAR[shI][1]- -- pragma translate_off- (30 downto 0)- -- pragma translate_on- );+ to_integer(~VAR[shI][1]); ~RESULT <= shift_left(~ARG[0],~SYM[1]) -- pragma translate_off when (~ARG[1] >= 0) else (others => 'X')@@ -186,11 +182,7 @@ -- pragma translate_off natural'high when (~VAR[shI][1](~SIZE[~TYP[1]]-1 downto 31) /= 0) else -- pragma translate_on- to_integer(~VAR[shI][1]- -- pragma translate_off- (30 downto 0)- -- pragma translate_on- );+ to_integer(~VAR[shI][1]); ~RESULT <= shift_right(~ARG[0],~SYM[1]) -- pragma translate_off when (~ARG[1] >= 0) else (others => 'X')@@ -210,11 +202,7 @@ -- pragma translate_off natural'high when (~VAR[shI][1](~SIZE[~TYP[1]]-1 downto 31) /= 0) else -- pragma translate_on- to_integer(~VAR[shI][1]- -- pragma translate_off- (30 downto 0)- -- pragma translate_on- );+ to_integer(~VAR[shI][1]); ~RESULT <= ~ARG[0] srl ~SYM[1] -- pragma translate_off when (~ARG[1] >= 0) else (others => 'X')@@ -287,11 +275,7 @@ -- pragma translate_off natural'high when (~VAR[shI][1](~SIZE[~TYP[1]]-1 downto 31) /= 0) else -- pragma translate_on- to_integer(~VAR[shI][1]- -- pragma translate_off- (30 downto 0)- -- pragma translate_on- );+ to_integer(~VAR[shI][1]); ~RESULT <= shift_left(~ARG[0],~SYM[1]) -- pragma translate_off when (~ARG[1] >= 0) else (others => 'X')@@ -311,11 +295,7 @@ -- pragma translate_off natural'high when (~VAR[shI][1](~SIZE[~TYP[1]]-1 downto 31) /= 0) else -- pragma translate_on- to_integer(~VAR[shI][1]- -- pragma translate_off- (30 downto 0)- -- pragma translate_on- );+ to_integer(~VAR[shI][1]); ~RESULT <= shift_right(~ARG[0],~SYM[1]) -- pragma translate_off when (~ARG[1] >= 0) else (others => 'X')
src/Clash/Annotations/BitRepresentation/ClashLib.hs view
@@ -1,5 +1,6 @@ {-| Copyright : (C) 2018, Google Inc.+ 2022, LUMI GUIDE FIETSDETECTIE B.V. License : BSD2 (see the file LICENSE) Maintainer : Christiaan Baaij <christiaan.baaij@gmail.com> @@ -15,12 +16,13 @@ ) where import Clash.Annotations.BitRepresentation.Internal- (Type'(AppTy',ConstTy',LitTy'))+ (Type'(..)) import qualified Clash.Annotations.BitRepresentation.Util as BitRepresentation import qualified Clash.Core.Type as C import Clash.Core.Name (nameOcc) import qualified Clash.Netlist.Types as Netlist import Clash.Util (curLoc)+import qualified Data.Text as T (pack) -- Convert Core type to BitRepresentation type coreToType'@@ -37,6 +39,8 @@ return $ ConstTy' (nameOcc name) coreToType' (C.LitTy (C.NumTy n)) = return $ LitTy' n+coreToType' (C.LitTy (C.SymTy lit)) =+ return $ SymLitTy' (T.pack lit) coreToType' e = Left $ $(curLoc) ++ "Unexpected type: " ++ show e
src/Clash/Backend/SystemVerilog.hs view
@@ -59,7 +59,7 @@ import Clash.Netlist.BlackBox.Util (extractLiterals, renderBlackBox, renderFilePath) import qualified Clash.Netlist.Id as Id-import Clash.Netlist.Types hiding (_intWidth, intWidth)+import Clash.Netlist.Types hiding (intWidth) import Clash.Netlist.Util import Clash.Signal.Internal (ActiveEdge (..)) import Clash.Util
src/Clash/Backend/VHDL.hs view
@@ -71,7 +71,7 @@ import Clash.Netlist.BlackBox.Util (extractLiterals, renderBlackBox, renderFilePath) import qualified Clash.Netlist.Id as Id-import Clash.Netlist.Types hiding (_intWidth, intWidth)+import Clash.Netlist.Types hiding (intWidth) import Clash.Netlist.Util import Clash.Util (SrcSpan, noSrcSpan, clogBase, curLoc, makeCached, indexNote)@@ -742,11 +742,25 @@ "function" <+> "fromSLV" <+> parens ("slv" <+> colon <+> "in" <+> "std_logic_vector") <+> "return" <+> qualTyName t <+> "is" <> line <> "begin" <> line <> indent 2- ( "return" <+> qualTyName t <> "'val" <>- parens ("to_integer" <>- parens ("unsigned" <> parens "slv"))) <> semi <> line <>+ (+ translate_off (+ "if unsigned(slv) <= " <> qualTyName t <> "'pos("<> qualTyName t <> "'high) then"+ ) <> line <>+ indent 2+ ( "return" <+> qualTyName t <> "'val" <>+ parens ("to_integer" <>+ parens ("unsigned" <> parens "slv"))) <> semi <> line <>+ translate_off (+ "else" <> line <>+ indent 2+ ( "return" <+> qualTyName t <> "'val(0)") <> semi <> line <>+ "end if" <> semi+ )+ ) <> line <> "end" <> semi )+ where+ translate_off body = "-- pragma translate_off" <> line <> body <> line <> "-- pragma translate_on" funDec _ syn t@(Vector _ elTy) = Just ( "function" <+> "toSLV" <+> parens ("value : " <+> qualTyName t) <+> "return std_logic_vector" <> semi <> line <>
src/Clash/Backend/Verilog.hs view
@@ -73,7 +73,7 @@ import Clash.Netlist.BlackBox.Util (extractLiterals, renderBlackBox, renderFilePath) import qualified Clash.Netlist.Id as Id-import Clash.Netlist.Types hiding (_intWidth, intWidth)+import Clash.Netlist.Types hiding (intWidth) import Clash.Netlist.Util import Clash.Signal.Internal (ActiveEdge (..)) import Clash.Util
src/Clash/Core/Evaluator/Types.hs view
@@ -1,8 +1,9 @@ {-# LANGUAGE CPP #-}+{-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} {-|- Copyright : (C) 2020-2021, QBayLogic B.V.+ Copyright : (C) 2020-2022, QBayLogic B.V. License : BSD2 (see the file LICENSE) Maintainer : QBayLogic B.V. <devops@qbaylogic.com> @@ -22,13 +23,13 @@ import Data.Text.Prettyprint.Doc (hsep) #endif -import Clash.Core.DataCon (DataCon)+import Clash.Core.DataCon (DataCon, dcType) import Clash.Core.HasType import Clash.Core.Literal (Literal(CharLiteral)) import Clash.Core.Pretty (fromPpr, ppr, showPpr)-import Clash.Core.Term (Term(..), PrimInfo(..), TickInfo, Alt)+import Clash.Core.Term (Term(..), PrimInfo(..), TickInfo, Alt, mkApps) import Clash.Core.TyCon (TyConMap)-import Clash.Core.Type (Type)+import Clash.Core.Type (Type (..), mkFunTy) import Clash.Core.Var (Id, IdScope(..), TyVar) import Clash.Core.VarEnv import Clash.Driver.Types (BindingMap, bindingTerm)@@ -264,6 +265,25 @@ | CastValue Value Type Type -- ^ Preserve casts from Terms in Values deriving Show++instance InferType Value where+ inferCoreTypeOf tcm = go+ where+ go = \case+ Lambda i t -> mkFunTy (coreTypeOf i) (inferCoreTypeOf tcm t)+ TyLambda v t -> ForAllTy v (inferCoreTypeOf tcm t)+ DC dc args -> applyTypeToArgs (mkApps (Data dc) args) tcm (dcType dc) args+ Lit l -> coreTypeOf l+ PrimVal p tys vals ->+ let args = map Right tys ++ map (Left . valToTerm) vals+ in applyTypeToArgs+ (mkApps (Prim p) args)+ tcm+ (primType p)+ args+ Suspend t -> inferCoreTypeOf tcm t+ TickValue _ v -> go v+ CastValue _ _ t -> t valToTerm :: Value -> Term valToTerm v = case v of
src/Clash/Driver.hs view
@@ -1000,7 +1000,7 @@ forM files $ \(fname, content) -> writeAndHash (dir </> fname) (ByteStringLazyChar8.pack content) --- | Copy data files added with ~FILEPATH+-- | Copy data files added with ~FILE copyDataFiles :: [FilePath] -- ^ Import directories passed in with @-i@
src/Clash/Driver/Manifest.hs view
@@ -155,11 +155,19 @@ , fileNames :: [(FilePath, ByteString)] -- ^ Names and hashes of all the generated files for the @TopEntity@. Hashes -- are SHA256.+ --+ -- This list is reverse topologically sorted. I.e., a component might depend+ -- on any component listed before it, but not after it. , domains :: HashMap Text VDomainConfiguration -- ^ Domains encountered in design , transitiveDependencies :: [Text] -- ^ Dependencies of this design (fully qualified binder names). Is a -- transitive closure of all dependencies.+ --+ -- This list is topologically sorted. I.e., a dependency might depend+ -- on any dependency listed after it, but not before it.+ --+ -- TODO: this ordered differs from `fileNames` and `componentNames`. Fix? } deriving (Show,Read,Eq) instance ToJSON Manifest where
src/Clash/Netlist.hs view
@@ -117,14 +117,9 @@ -- ^ Name of the @topEntity@ -> IO (Component, ComponentMap, IdentifierSet) genNetlist env isTb globals tops topNames typeTrans ite be seen0 dir prefixM topEntity = do- let opts = envOpts env- let reprs = envCustomReprs env- let primMap = envPrimitives env- let tcm = envTyConMap env- let iw = opt_intWidth opts ((_meta, topComponent), s) <-- runNetlistMonad isTb opts reprs globals tops primMap tcm typeTrans- iw ite be seen1 dir componentNames_ $ genComponent topEntity+ runNetlistMonad env isTb globals tops typeTrans ite be seen1 dir componentNames_+ $ genComponent topEntity return (topComponent, _components s, seen1) where (componentNames_, seen1) =@@ -132,25 +127,16 @@ -- | Run a NetlistMonad action in a given environment runNetlistMonad- :: Bool+ :: ClashEnv+ -> Bool -- ^ Whether this we're compiling a testbench (suppresses certain warnings)- -> ClashOpts- -- ^ Options Clash was called with- -> CustomReprs- -- ^ Custom bit representations for certain types -> BindingMap -- ^ Global binders -> VarEnv TopEntityT -- ^ TopEntity annotations- -> CompiledPrimMap- -- ^ Primitive Definitions- -> TyConMap- -- ^ TyCon cache -> (CustomReprs -> TyConMap -> Type -> State HWMap (Maybe (Either String FilteredHWType))) -- ^ Hardcode Type -> HWType translator- -> Int- -- ^ Int/Word/Integer bit-width -> Bool -- ^ Whether the backend supports ifThenElse expressions -> SomeBackend@@ -164,9 +150,8 @@ -> NetlistMonad a -- ^ Action to run -> IO (a, NetlistState)-runNetlistMonad isTb opts reprs s tops p tcm typeTrans iw- ite be seenIds_ env componentNames_- = flip runReaderT (NetlistEnv "" "" Nothing)+runNetlistMonad env isTb s tops typeTrans ite be seenIds_ dir componentNames_+ = flip runReaderT (NetlistEnv env "" "" Nothing) . flip runStateT s' . runNetlist where@@ -174,20 +159,15 @@ NetlistState { _bindings=s , _components=OMap.empty- , _primitives=p , _typeTranslator=typeTrans- , _tcCache=tcm , _curCompNm=(error "genComponent should have set _curCompNm", noSrcSpan)- , _intWidth=iw , _seenIds=seenIds_ , _seenComps=seenIds_ , _seenPrimitives=Set.empty , _componentNames=componentNames_ , _topEntityAnns=tops- , _hdlDir=env+ , _hdlDir=dir , _curBBlvl=0- , _customReprs=reprs- , _clashOpts=opts , _isTestBench=isTb , _backEndITE=ite , _backend=be@@ -271,7 +251,7 @@ -- ^ Corresponding term -> NetlistMonad (ComponentMeta, Component) genComponentT compName0 componentExpr = do- tcm <- Lens.use tcCache+ tcm <- Lens.view tcCache compName1 <- (`lookupVarEnv'` compName0) <$> Lens.use componentNames sp <- (bindingLoc . (`lookupVarEnv'` compName0)) <$> Lens.use bindings curCompNm .= (compName1, sp)@@ -335,7 +315,7 @@ where multiDecls pInfo args0 = do- tcm <- Lens.use tcCache+ tcm <- Lens.view tcCache resInits0 <- getResInits (id_, tm) let resInits1 = map Just resInits0 <> repeat Nothing@@ -376,7 +356,7 @@ termToWireOrReg :: Term -> NetlistMonad WireOrReg termToWireOrReg (stripTicks -> Case scrut _ alts0@(_:_:_)) = do- tcm <- Lens.use tcCache+ tcm <- Lens.view tcCache let scrutTy = inferCoreTypeOf tcm scrut scrutHTy <- unsafeCoreTypeToHWTypeM' $(curLoc) scrutTy ite <- Lens.use backEndITE@@ -384,7 +364,7 @@ Just _ | ite -> return Wire _ -> return Reg termToWireOrReg (collectArgs -> (Prim p,_)) = do- bbM <- HashMap.lookup (primName p) <$> Lens.use primitives+ bbM <- HashMap.lookup (primName p) <$> Lens.view primitives case bbM of Just (extractPrim -> Just BlackBox {..}) | outputReg -> return Reg _ | primName p == "Clash.Explicit.SimIO.mealyIO" -> return Reg@@ -398,7 +378,7 @@ _ -> return [] where go pInfo (BlackBox {resultInits=nmDs, multiResult=True}) = withTicks ticks $ \_ -> do- tcm <- Lens.use tcCache+ tcm <- Lens.view tcCache let (args1, res) = splitMultiPrimArgs (multiPrimInfo' tcm pInfo) args0 (bbCtx, _) <- mkBlackBoxContext (primName pInfo) res args1 mapM (go' (primName pInfo) bbCtx) nmDs@@ -513,7 +493,7 @@ -> NetlistMonad [Declaration] mkSelection declType bndr scrut altTy alts0 tickDecls = do let dstId = netlistId1 id id2identifier bndr- tcm <- Lens.use tcCache+ tcm <- Lens.view tcCache let scrutTy = inferCoreTypeOf tcm scrut scrutHTy <- unsafeCoreTypeToHWTypeM' $(curLoc) scrutTy scrutId <- Id.suffix dstId "selection"@@ -548,7 +528,7 @@ -> return $! scrutDecls ++ altTDecls ++ altFDecls ++ tickDecls ++ [Assignment dstId (IfThenElse scrutExpr altTExpr altFExpr)] _ -> do- reprs <- Lens.use customReprs+ reprs <- Lens.view customReprs let alts1 = (reorderDefault . reorderCustom tcm reprs scrutTy) alts0 (scrutExpr,scrutDecls) <- first (mkScrutExpr sp scrutHTy (fst (head alts1))) <$> mkExpr True declType (NetlistId scrutId scrutTy) scrut@@ -657,7 +637,7 @@ -> NetlistMonad [Declaration] mkFunApp dstId fun args tickDecls = do topAnns <- Lens.use topEntityAnns- tcm <- Lens.use tcCache+ tcm <- Lens.view tcCache case (isGlobalId fun, lookupVarEnv fun topAnns) of (True, Just topEntity) | let ty = coreTypeOf (topId topEntity)@@ -835,7 +815,7 @@ -> Term -- ^ Term to convert to an expression -> NetlistMonad (Expr,[Declaration]) -- ^ Returned expression and a list of generate BlackBox declarations mkExpr _ _ _ (stripTicks -> Core.Literal l) = do- iw <- Lens.use intWidth+ iw <- Lens.view intWidth case l of IntegerLiteral i -> return (HW.Literal (Just (Signed iw,iw)) $ NumLit i, []) IntLiteral i -> return (HW.Literal (Just (Signed iw,iw)) $ NumLit i, [])@@ -884,7 +864,7 @@ , NetDecl' Nothing Wire argNm (Right hwTyA) Nothing:decls) Case scrut ty' [alt] -> mkProjection bbEasD bndr scrut ty' alt Case scrut tyA alts -> do- tcm <- Lens.use tcCache+ tcm <- Lens.view tcCache let scrutTy = inferCoreTypeOf tcm scrut scrutHTy <- unsafeCoreTypeToHWTypeM' $(curLoc) scrutTy ite <- Lens.use backEndITE@@ -922,7 +902,7 @@ -- ^ The field to be projected -> NetlistMonad (Expr, [Declaration]) mkProjection mkDec bndr scrut altTy alt@(pat,v) = do- tcm <- Lens.use tcCache+ tcm <- Lens.view tcCache let scrutTy = inferCoreTypeOf tcm scrut e = Case scrut scrutTy [alt] (_,sp) <- Lens.use curCompNm@@ -1014,7 +994,7 @@ -- ^ Returned expression and a list of generate BlackBox declarations mkDcApplication [dstHType] bndr dc args = do let dcNm = nameOcc (dcName dc)- tcm <- Lens.use tcCache+ tcm <- Lens.view tcCache let argTys = map (inferCoreTypeOf tcm) args argNm <- netlistId1 return (\b -> Id.suffix (id2identifier b) "_dc_arg") bndr argHWTys <- mapM coreTypeToHWTypeM' argTys@@ -1148,7 +1128,7 @@ -- Handle MultiId assignment mkDcApplication dstHTypes (MultiId argNms) _ args = do- tcm <- Lens.use tcCache+ tcm <- Lens.view tcCache let argTys = map (inferCoreTypeOf tcm) args argHWTys <- mapM coreTypeToHWTypeM' argTys -- Filter out the arguments of hwtype `Void` and only translate
src/Clash/Netlist/BlackBox.hs view
@@ -3,7 +3,7 @@ Copyright : (C) 2012-2016, University of Twente, 2016-2017, Myrtle Software Ltd, 2017 , Google Inc.,- 2021 , QBayLogic B.V.+ 2021-2022, QBayLogic B.V. License : BSD2 (see the file LICENSE) Maintainer : QBayLogic B.V. <devops@qbaylogic.com> @@ -168,11 +168,11 @@ ) where addFunction resTys im (arg,i) = do- tcm <- Lens.use tcCache+ tcm <- Lens.view tcCache if isFun tcm arg then do -- Only try to calculate function plurality when primitive actually -- exists. Here to prevent crashes on __INTERNAL__ primitives.- prim <- HashMap.lookup bbName <$> Lens.use primitives+ prim <- HashMap.lookup bbName <$> Lens.view primitives funcPlurality <- case extractPrim <$> prim of Just (Just p) ->@@ -233,9 +233,9 @@ , [Declaration] ) mkArgument bbName bndr nArg e = do- tcm <- Lens.use tcCache+ tcm <- Lens.view tcCache let ty = inferCoreTypeOf tcm e- iw <- Lens.use intWidth+ iw <- Lens.view intWidth hwTyM <- fmap stripFiltered <$> N.termHWTypeM e let eTyMsg = "(" ++ showPpr e ++ " :: " ++ showPpr ty ++ ")" ((e',t,l),d) <- case hwTyM of@@ -299,7 +299,7 @@ -- ^ Name of primitive -> NetlistMonad CompiledPrimitive extractPrimWarnOrFail nm = do- prim <- HashMap.lookup nm <$> Lens.use primitives+ prim <- HashMap.lookup nm <$> Lens.view primitives case prim of Just (HasBlackBox warnings compiledPrim) -> -- See if we need to warn the user@@ -328,9 +328,9 @@ -> NetlistMonad CompiledPrimitive go ((WarnAlways warning):ws) cp = do- primWarn <- opt_primWarn <$> Lens.use clashOpts+ opts <- Lens.view clashOpts+ let primWarn = opt_primWarn opts seen <- Set.member nm <$> Lens.use seenPrimitives- opts <- Lens.use clashOpts when (primWarn && not seen) $ liftIO@@ -401,7 +401,7 @@ -- Multi result primitives assign their results to signals -- provided as arguments. Hence, we ignore any declarations -- from 'resBndr1'.- tcm <- Lens.use tcCache+ tcm <- Lens.view tcCache let (args1, resArgs) = splitMultiPrimArgs (multiPrimInfo' tcm pInfo) args (bbCtx, ctxDcls) <- mkBlackBoxContext (primName pInfo) resArgs args1 (templ, templDecl) <- prepareBlackBox name template bbCtx@@ -493,13 +493,13 @@ hwTy <- N.unsafeCoreTypeToHWTypeM' $(curLoc) ty case args of [Right (ConstTy (TyCon tcN)), Left (C.Literal (IntLiteral i))] -> do- tcm <- Lens.use tcCache+ tcm <- Lens.view tcCache let dcs = tyConDataCons (tcm `lookupUniqMap'` tcN) dc = dcs !! fromInteger i (exprN,dcDecls) <- mkDcApplication [hwTy] dst dc [] return (exprN,dcDecls) [Right _, Left scrut] -> do- tcm <- Lens.use tcCache+ tcm <- Lens.view tcCache let scrutTy = inferCoreTypeOf tcm scrut (scrutExpr,scrutDecls) <- mkExpr False Concurrent (NetlistId (Id.unsafeMake "c$tte_rhs") scrutTy) scrut@@ -514,10 +514,10 @@ _ -> error $ $(curLoc) ++ "tagToEnum: " ++ show (map (either showPpr showPpr) args) | pNm == "GHC.Prim.dataToTag#" -> case args of [Right _,Left (Data dc)] -> do- iw <- Lens.use intWidth+ iw <- Lens.view intWidth return (N.Literal (Just (Signed iw,iw)) (NumLit $ toInteger $ dcTag dc - 1),[]) [Right _,Left scrut] -> do- tcm <- Lens.use tcCache+ tcm <- Lens.view tcCache let scrutTy = inferCoreTypeOf tcm scrut scrutHTy <- unsafeCoreTypeToHWTypeM' $(curLoc) scrutTy (scrutExpr,scrutDecls) <-@@ -535,7 +535,7 @@ resM <- resBndr1 True dst case resM of Just (_,dstNm,dstDecl) -> do- tcm <- Lens.use tcCache+ tcm <- Lens.view tcCache mealyDecls <- collectMealy dstNm dst tcm (lefts args) return (Noop, dstDecl ++ mealyDecls) Nothing -> return (Noop,[])@@ -562,7 +562,7 @@ resM <- resBndr1 True dst case resM of Just (_,dstNm,dstDecl) -> do- tcm <- Lens.use tcCache+ tcm <- Lens.view tcCache let (fun0:arg0:_) = lefts args arg1 = unSimIO tcm arg0 fun1 = case fun0 of@@ -607,7 +607,7 @@ (expr,decls) <- case lefts args of (arg:_) -> mkExpr False Concurrent dst arg _ -> error "internal error: insufficient arguments"- iw <- Lens.use intWidth+ iw <- Lens.view intWidth return (N.DataCon (Signed iw) (DC (Void Nothing,-1)) [expr],decls) | pNm == "GHC.Num.Integer.IP" -> do@@ -631,7 +631,7 @@ (expr,decls) <- case lefts args of (arg:_) -> mkExpr False Concurrent dst arg _ -> error "internal error: insufficient arguments"- iw <- Lens.use intWidth+ iw <- Lens.view intWidth return (N.DataCon (Unsigned iw) (DC (Void Nothing,-1)) [expr],decls) | pNm == "GHC.Num.Integer.NB" -> do@@ -886,7 +886,7 @@ #else collectBindIO dst (m:Lam x q@(Lam _ e):_) = do #endif- tcm <- Lens.use tcCache+ tcm <- Lens.view tcCache (ds0,subst) <- collectAction tcm let qS = substTm "collectBindIO1" subst q case splitNormalized tcm qS of@@ -936,7 +936,7 @@ collectAppIO :: NetlistId -> [Term] -> [Term] -> NetlistMonad (Expr,[Declaration]) collectAppIO dst (fun1:arg1:_) rest = case collectArgs fun1 of (Prim (PrimInfo "Clash.Explicit.SimIO.fmapSimIO#" _ _ _ _),(lefts -> (fun0:arg0:_))) -> do- tcm <- Lens.use tcCache+ tcm <- Lens.view tcCache let argN = map (Left . unSimIO tcm) (arg0:arg1:rest) mkExpr False Sequential dst (mkApps fun0 argN) (Prim (PrimInfo "Clash.Explicit.SimIO.apSimIO#" _ _ _ _),(lefts -> args)) -> do@@ -989,7 +989,7 @@ mkFunInput resId e = let (appE,args,ticks) = collectArgsTicks e in withTicks ticks $ \tickDecls -> do- tcm <- Lens.use tcCache+ tcm <- Lens.view tcCache -- TODO: Rewrite this function to use blackbox functions. Right now it -- TODO: generates strings that are later parsed/interpreted again. Silly! templ <- case appE of@@ -1177,7 +1177,7 @@ return ((Right decl,wr,[],[],[],bbCtx),dcls) where goExpr app@(collectArgsTicks -> (C.Var fun,args@(_:_),ticks)) = do- tcm <- Lens.use tcCache+ tcm <- Lens.view tcCache resTy <- unsafeCoreTypeToHWTypeM' $(curLoc) (inferCoreTypeOf tcm app) let (tmArgs,tyArgs) = partitionEithers args if null tyArgs@@ -1193,7 +1193,7 @@ (_,sp) <- Lens.use curCompNm throw (ClashException sp ($(curLoc) ++ "Not in normal form: Var-application with Type arguments:\n\n" ++ showPpr app) Nothing) goExpr e' = do- tcm <- Lens.use tcCache+ tcm <- Lens.view tcCache let eType = inferCoreTypeOf tcm e' (appExpr,appDecls) <- mkExpr False Concurrent (NetlistId (Id.unsafeMake "c$bb_res") eType) e' let assn = Assignment (Id.unsafeMake "~RESULT") appExpr@@ -1217,7 +1217,7 @@ return (Right ((Id.unsafeMake "",[assn]),Wire)) go _ _ (Case scrut ty [alt]) = do- tcm <- Lens.use tcCache+ tcm <- Lens.view tcCache let sTy = inferCoreTypeOf tcm scrut (projection,decls) <- mkProjection False (NetlistId (Id.unsafeMake "c$bb_res") sTy) scrut ty alt let assn = Assignment (Id.unsafeMake "~RESULT") projection@@ -1227,7 +1227,7 @@ return (Right ((nm,decls ++ [assn]),Wire)) go _ _ (Case scrut ty alts@(_:_:_)) = do- tcm <- Lens.use tcCache+ tcm <- Lens.view tcCache let scrutTy = inferCoreTypeOf tcm scrut scrutHTy <- unsafeCoreTypeToHWTypeM' $(curLoc) scrutTy ite <- Lens.use backEndITE@@ -1247,7 +1247,7 @@ return (Right ((nm,assn++selectionDecls),Wire)) go is0 _ e'@(Let{}) = do- tcm <- Lens.use tcCache+ tcm <- Lens.view tcCache let normE = splitNormalized tcm e' (_,[],[],_,[],binders,resultM) <- case normE of Right norm -> mkUniqueNormalized is0 Nothing norm
src/Clash/Netlist/BlackBox/Parser.hs view
@@ -1,7 +1,7 @@ {-| Copyright : (C) 2012-2016, University of Twente, 2017 , Myrtle Software Ltd,- 2021 , QBayLogic B.V.+ 2021-2022, QBayLogic B.V. License : BSD2 (see the file LICENSE) Maintainer : QBayLogic B.V. <devops@qbaylogic.com> @@ -25,11 +25,8 @@ -- | Parse a text as a BlackBoxTemplate, returns a list of errors in case -- parsing fails--- runParse :: Text -> (BlackBoxTemplate, [Error LineColPos])--- runParse = PCC.parse ((,) <$> pBlackBoxD <*> pEnd)--- . createStr (LineColPos 0 0 0) runParse :: Text -> Result BlackBoxTemplate-runParse = parseString pBlackBoxD (Directed "" 0 0 0 0) . unpack+runParse = parseString (pBlackBoxD <* eof) (Directed "" 0 0 0 0) . unpack -- | Parse a BlackBoxTemplate (Declarations and Expressions) pBlackBoxD :: Parser BlackBoxTemplate@@ -80,7 +77,7 @@ <|> Const <$> (string "~CONST" *> brackets' natural') <|> Lit <$> (string "~LIT" *> brackets' natural') <|> Name <$> (string "~NAME" *> brackets' natural')- <|> ToVar <$> try (string "~VAR" *> brackets' pSigD) <*> brackets' natural'+ <|> ToVar <$> try (string "~VAR" *> brackets' pSigDorEmpty) <*> brackets' natural' <|> (Sym Text.empty) <$> (string "~SYM" *> brackets' natural') <|> Typ Nothing <$ string "~TYPO" <|> (Typ . Just) <$> try (string "~TYP" *> brackets' natural')@@ -110,6 +107,7 @@ <|> Sel <$> (string "~SEL" *> brackets' pTagE) <*> brackets' natural' <|> IsLit <$> (string "~ISLIT" *> brackets' natural') <|> IsVar <$> (string "~ISVAR" *> brackets' natural')+ <|> IsScalar <$> (string "~ISSCALAR" *> brackets' natural') <|> IsActiveHigh <$> (string "~ISACTIVEHIGH" *> brackets' natural') <|> IsActiveEnable <$> (string "~ISACTIVEENABLE" *> brackets' natural') <|> IsUndefined <$> (string "~ISUNDEFINED" *> brackets' natural')@@ -153,3 +151,6 @@ <|> (Text (pack "]") <$ (pack <$> string "\\]")) <|> (Text <$> (pack <$> some (satisfyRange '\000' '\90'))) <|> (Text <$> (pack <$> some (satisfyRange '\94' '\125'))))++pSigDorEmpty :: Parser [Element]+pSigDorEmpty = pSigD <|> mempty
src/Clash/Netlist/BlackBox/Types.hs view
@@ -2,6 +2,7 @@ Copyright : (C) 2012-2016, University of Twente, 2017 , Myrtle Software Ltd, 2021-2022, QBayLogic B.V.+ 2022 , LUMI GUIDE FIETSDETECTIE B.V. License : BSD2 (see the file LICENSE) Maintainer : QBayLogic B.V. <devops@qbaylogic.com> @@ -97,6 +98,7 @@ -- - Clash.Netlist.BlackBox.Types.renderElem -- - Clash.Netlist.BlackBox.Types.renderTag -- - Clash.Netlist.BlackBox.Types.setSym+-- - Clash.Netlist.BlackBox.Util.inputHole -- - Clash.Netlist.BlackBox.Types.getUsedArguments -- - Clash.Netlist.BlackBox.Types.usedVariables -- - Clash.Netlist.BlackBox.Types.verifyBlackBoxContext@@ -165,20 +167,28 @@ -- ^ Record selector of a type | IsLit !Int | IsVar !Int+ | IsScalar !Int+ -- ^ Whether element is scalar | IsActiveHigh !Int- -- ^ Whether a domain's reset lines are synchronous.+ -- ^ Whether a domain's reset lines are active high. Errors if not applied to+ -- a @KnownDomain@ or @KnownConfiguration@. | Tag !Int -- ^ Tag of a domain. | Period !Int- -- ^ Period of a domain.+ -- ^ Period of a domain. Errors if not applied to a @KnownDomain@ or+ -- @KnownConfiguration@. | LongestPeriod -- ^ Longest period of all known domains | ActiveEdge !Signal.ActiveEdge !Int- -- ^ Test active edge of memory elements in a certain domain+ -- ^ Test active edge of memory elements in a certain domain. Errors if not+ -- applied to a @KnownDomain@ or @KnownConfiguration@. | IsSync !Int -- ^ Whether a domain's reset lines are synchronous. Errors if not applied to- -- a KnownDomain.+ -- a @KnownDomain@ or @KnownConfiguration@. | IsInitDefined !Int+ -- ^ Whether the initial (or "power up") value of memory elements in a domain+ -- are configurable to a specific value rather than unknown\/undefined. Errors+ -- if not applied to a @KnownDomain@ or @KnownConfiguration@. | IsActiveEnable !Int -- ^ Whether given enable line is active. More specifically, whether the -- enable line is NOT set to a constant 'True'.
src/Clash/Netlist/BlackBox/Util.hs view
@@ -2,6 +2,7 @@ Copyright : (C) 2012-2016, University of Twente, 2016-2017, Myrtle Software Ltd, 2021-2022, QBayLogic B.V.+ 2022 , LUMI GUIDE FIETSDETECTIE B.V. License : BSD2 (see the file LICENSE) Maintainer : QBayLogic B.V. <devops@qbaylogic.com> @@ -23,7 +24,7 @@ import Control.Lens (use, (%=), _1, _2, element, (^?)) import Control.Monad (forM, (<=<))-import Control.Monad.State (State, StateT (..), lift)+import Control.Monad.State (State, StateT (..), lift, gets) import Data.Bitraversable (bitraverse) import Data.Bool (bool) import Data.Coerce (coerce)@@ -54,7 +55,7 @@ import Text.Trifecta.Result hiding (Err) import Clash.Backend- (Backend (..), Usage (..), AggressiveXOptBB(..))+ (Backend (..), Usage (..), AggressiveXOptBB(..), RenderEnums(..)) import Clash.Netlist.BlackBox.Parser import Clash.Netlist.BlackBox.Types import Clash.Netlist.Types@@ -68,16 +69,61 @@ import Clash.Util import qualified Clash.Util.Interpolate as I +import Clash.Annotations.Primitive (HDL(VHDL))+ inputHole :: Element -> Maybe Int inputHole = \case- Arg n -> pure n- Lit n -> pure n- Const n -> pure n- Name n -> pure n- Typ (Just n) -> pure n- TypM (Just n) -> pure n- Err (Just n) -> pure n- _ -> Nothing+ Text _ -> Nothing+ Component _ -> Nothing+ Result -> Nothing+ Arg n -> pure n+ ArgGen _ n -> pure n+ Const n -> pure n+ Lit n -> pure n+ Name n -> pure n+ ToVar _ n -> pure n+ Sym _ _ -> Nothing+ Typ nM -> nM+ TypM nM -> nM+ Err nM -> nM+ TypElem _ -> Nothing+ CompName -> Nothing+ IncludeName _ -> Nothing+ IndexType _ -> Nothing+ Size _ -> Nothing+ Length _ -> Nothing+ Depth _ -> Nothing+ MaxIndex _ -> Nothing+ FilePath _ -> Nothing+ Template _ _ -> Nothing+ Gen _ -> Nothing+ IF _ _ _ -> Nothing+ And _ -> Nothing+ IW64 -> Nothing+ CmpLE _ _ -> Nothing+ HdlSyn _ -> Nothing+ BV _ _ _ -> Nothing+ Sel _ _ -> Nothing+ IsLit n -> pure n+ IsVar n -> pure n+ IsScalar n -> pure n+ IsActiveHigh n -> pure n+ Tag n -> pure n+ Period n -> pure n+ LongestPeriod -> Nothing+ ActiveEdge _ n -> pure n+ IsSync n -> pure n+ IsInitDefined n -> pure n+ IsActiveEnable n -> pure n+ IsUndefined n -> pure n+ StrCmp _ n -> pure n+ OutputWireReg n -> pure n+ Vars n -> pure n+ GenSym _ _ -> Nothing+ Repeat _ _ -> Nothing+ DevNull _ -> Nothing+ SigD _ nM -> nM+ CtxName -> Nothing -- | Determine if the number of normal/literal/function inputs of a blackbox -- context at least matches the number of argument that is expected by the@@ -430,13 +476,15 @@ renderElem b (IF c t f) = do iw <- iwWidth+ hdl <- gets hdlKind syn <- hdlSyn+ enums <- renderEnums xOpt <- aggressiveXOptBB- let c' = check (coerce xOpt) iw syn c+ let c' = check (coerce xOpt) iw hdl syn enums c if c' > 0 then renderTemplate b t else renderTemplate b f where- check :: Bool -> Int -> HdlSyn -> Element -> Int- check xOpt iw syn c' = case c' of+ check :: Bool -> Int -> HDL -> HdlSyn -> RenderEnums -> Element -> Int+ check xOpt iw hdl syn enums c' = case c' of (Size e) -> typeSize (lineToType b [e]) (Length e) -> case lineToType b [e] of (Vector n _) -> n@@ -476,6 +524,15 @@ Literal {} -> 1 BlackBoxE {} -> 1 _ -> 0+ (IsScalar n) -> let (_,ty,_) = bbInputs b !! n+ isScalar _ Bit = 1+ isScalar _ Bool = 1+ isScalar VHDL Integer = 1+ isScalar VHDL (Sum _ _) = case enums of+ RenderEnums True -> 1+ RenderEnums False -> 0+ isScalar _ _ = 0+ in isScalar hdl ty (IsUndefined n) -> let (e, _, _) = bbInputs b !! n@@ -539,14 +596,14 @@ | t1 == Text.pack t2 -> 1 | otherwise -> 0 Nothing -> error $ $(curLoc) ++ "Expected a string literal: " ++ show e- (And es) -> if all (/=0) (map (check xOpt iw syn) es)+ (And es) -> if all (/=0) (map (check xOpt iw hdl syn enums) es) then 1 else 0- CmpLE e1 e2 -> if check xOpt iw syn e1 <= check xOpt iw syn e2+ CmpLE e1 e2 -> if check xOpt iw hdl syn enums e1 <= check xOpt iw hdl syn enums e2 then 1 else 0- _ -> error $ $(curLoc) ++ "IF: condition must be: SIZE, LENGTH, IW64, LIT, ISLIT, or ISARG"-+ _ -> error $ $(curLoc) ++ "IF: condition must be: SIZE, LENGTH, LIT, DEPTH, IW64, VIVADO, OTHERSYN, ISVAR, ISLIT, ISUNDEFINED, ISACTIVEENABLE, ACTIVEEDGE, ISSYNC, ISINITDEFINED, ISACTIVEHIGH, STRCMP, AND, ISSCALAR or CMPLE."+ ++ "\nGot: " ++ show c' renderElem b e = fmap const (renderTag b e) parseFail :: Text -> BlackBoxTemplate@@ -607,7 +664,7 @@ fmap renderOneLine . getAp . expr False . fst $ bbResult "~RESULT" b renderTag b (Arg n) = do let (e,_,_) = bbInputs b !! n- renderOneLine <$> getAp (expr False e)+ renderOneLine <$> getAp (expr True e) renderTag b (Const n) = do let (e,_,_) = bbInputs b !! n@@ -726,9 +783,9 @@ return (Text.pack (show s')) _ -> do e2 <- getAp (prettyElem e)- error $ $(curLoc) ++ "argument of ~FILEPATH:" ++ show e2 ++ "does not reduce to a string"+ error $ $(curLoc) ++ "argument of ~FILE:" ++ show e2 ++ "does not reduce to a string" _ -> do e' <- getAp (prettyElem e)- error $ $(curLoc) ++ "~FILEPATH expects a ~LIT[N] argument, but got: " ++ show e'+ error $ $(curLoc) ++ "~FILE expects a ~LIT[N] argument, but got: " ++ show e' renderTag b (IncludeName n) = case indexMaybe (bbQsysIncName b) n of Just nm -> return (Text.fromStrict nm) _ -> error $ $(curLoc) ++ "~INCLUDENAME[" ++ show n ++ "] does not correspond to any index of the 'includes' field that is specified in the primitive definition"@@ -933,6 +990,7 @@ renderOneLine <$> (string "~SEL" <> brackets (string e') <> brackets (int i)) prettyElem (IsLit i) = renderOneLine <$> (string "~ISLIT" <> brackets (int i)) prettyElem (IsVar i) = renderOneLine <$> (string "~ISVAR" <> brackets (int i))+prettyElem (IsScalar i) = renderOneLine <$> (string "~ISSCALAR" <> brackets (int i)) prettyElem (IsActiveHigh i) = renderOneLine <$> (string "~ISACTIVEHIGH" <> brackets (int i)) prettyElem (IsActiveEnable i) = renderOneLine <$> (string "~ISACTIVEENABLE" <> brackets (int i)) prettyElem (IsUndefined i) = renderOneLine <$> (string "~ISUNDEFINED" <> brackets (int i))@@ -1039,6 +1097,7 @@ Sel e _ -> go e IsLit _ -> [] IsVar _ -> []+ IsScalar _ -> [] Tag _ -> [] Period _ -> [] LongestPeriod -> []@@ -1123,6 +1182,7 @@ IndexType _ -> Nothing IsActiveHigh _ -> Nothing IsVar _ -> Nothing+ IsScalar _ -> Nothing IW64 -> Nothing Length _ -> Nothing MaxIndex _ -> Nothing
src/Clash/Netlist/Types.hs view
@@ -74,7 +74,7 @@ import Clash.Core.Var (Attr', Id) import Clash.Core.TyCon (TyConMap) import Clash.Core.VarEnv (VarEnv)-import Clash.Driver.Types (BindingMap, ClashOpts)+import Clash.Driver.Types (BindingMap, ClashEnv(..), ClashOpts(..)) import Clash.Netlist.BlackBox.Types (BlackBoxTemplate) import Clash.Primitives.Types (CompiledPrimMap) import Clash.Signal.Internal@@ -270,7 +270,8 @@ -- | Environment of the NetlistMonad data NetlistEnv = NetlistEnv- { _prefixName :: Text+ { _clashEnv :: ClashEnv+ , _prefixName :: Text -- ^ Prefix for instance/register names , _suffixName :: Text -- ^ Postfix for instance/register names@@ -294,15 +295,10 @@ , _components :: ComponentMap -- ^ Cached components. Is an insertion ordered map to preserve a topologically -- sorted component list for the manifest file.- , _primitives :: CompiledPrimMap- -- ^ Primitive Definitions , _typeTranslator :: CustomReprs -> TyConMap -> Type -> Strict.State HWMap (Maybe (Either String FilteredHWType)) -- ^ Hardcoded Type -> HWType translator- , _tcCache :: TyConMap- -- ^ TyCon cache , _curCompNm :: !(Identifier,SrcSpan)- , _intWidth :: Int , _seenIds :: IdentifierSet -- ^ All names currently in scope. , _seenComps :: IdentifierSet@@ -335,9 +331,6 @@ , _hdlDir :: FilePath , _curBBlvl :: Int -- ^ The current scoping level assigned to black box contexts- , _customReprs :: CustomReprs- , _clashOpts :: ClashOpts- -- ^ Settings Clash was called with , _isTestBench :: Bool -- ^ Whether we're compiling a testbench (suppresses some warnings) , _backEndITE :: Bool@@ -823,6 +816,21 @@ Lens.makeLenses ''NetlistEnv Lens.makeLenses ''NetlistState++intWidth :: Lens.Getter NetlistEnv Int+intWidth = clashEnv . Lens.to (opt_intWidth . envOpts)++customReprs :: Lens.Getter NetlistEnv CustomReprs+customReprs = clashEnv . Lens.to envCustomReprs++tcCache :: Lens.Getter NetlistEnv TyConMap+tcCache = clashEnv . Lens.to envTyConMap++primitives :: Lens.Getter NetlistEnv CompiledPrimMap+primitives = clashEnv . Lens.to envPrimitives++clashOpts :: Lens.Getter NetlistEnv ClashOpts+clashOpts = clashEnv . Lens.to envOpts -- | Structures that hold an 'IdentifierSet' class HasIdentifierSet s where
src/Clash/Netlist/Util.hs view
@@ -2,7 +2,7 @@ Copyright : (C) 2012-2016, University of Twente, 2017 , Myrtle Software Ltd 2017-2018, Google Inc.- 2021 , QBayLogic B.V.+ 2021-2022, QBayLogic B.V. License : BSD2 (see the file LICENSE) Maintainer : QBayLogic B.V. <devops@qbaylogic.com> @@ -218,8 +218,8 @@ unsafeCoreTypeToHWTypeM loc ty = do (_,cmpNm) <- Lens.use curCompNm tt <- Lens.use typeTranslator- reprs <- Lens.use customReprs- tcm <- Lens.use tcCache+ reprs <- Lens.view customReprs+ tcm <- Lens.view tcCache htm0 <- Lens.use htyCache let (hty,htm1) = runState (unsafeCoreTypeToHWType cmpNm loc tt reprs tcm ty) htm0 htyCache Lens..= htm1@@ -241,8 +241,8 @@ -> NetlistMonad (Maybe FilteredHWType) coreTypeToHWTypeM ty = do tt <- Lens.use typeTranslator- reprs <- Lens.use customReprs- tcm <- Lens.use tcCache+ reprs <- Lens.view customReprs+ tcm <- Lens.view tcCache htm0 <- Lens.use htyCache let (hty,htm1) = runState (coreTypeToHWType tt reprs tcm ty) htm0 htyCache Lens..= htm1@@ -708,7 +708,7 @@ -> Term -> NetlistMonad HWType termHWType loc e = do- m <- Lens.use tcCache+ m <- Lens.view tcCache let ty = inferCoreTypeOf m e stripFiltered <$> unsafeCoreTypeToHWTypeM loc ty @@ -719,7 +719,7 @@ -- ^ Term to convert to HWType -> NetlistMonad (Maybe FilteredHWType) termHWTypeM e = do- m <- Lens.use tcCache+ m <- Lens.view tcCache let ty = inferCoreTypeOf m e coreTypeToHWTypeM ty @@ -854,7 +854,7 @@ -- 'Clash.Normalize.Transformations.setupMultiResultPrim'. goMulti :: PrimInfo -> CompiledPrimitive -> NetlistMonad [(Id, Id)] goMulti pInfo (BlackBoxHaskell{function=(_, function)}) = do- tcm <- Lens.use tcCache+ tcm <- Lens.view tcCache let mpInfo@MultiPrimInfo{mpi_resultTypes} = multiPrimInfo' tcm pInfo let (args1, resIds) = splitMultiPrimArgs mpInfo args funRes <- preserveVarEnv (function False (primName pInfo) args1 mpi_resultTypes)@@ -1659,7 +1659,7 @@ go (TickDecl (Comment (Text.pack (showSDocUnsafe (ppr sp)))):decls) ticks go decls (NameMod m nm0:ticks) = do- tcm <- Lens.use tcCache+ tcm <- Lens.view tcCache case runExcept (tyLitShow tcm nm0) of Right nm1 -> local (modName m nm1) (go decls ticks) _ -> go decls ticks@@ -1681,7 +1681,7 @@ :: Text -> NetlistMonad Text affixName nm0 = do- NetlistEnv pre suf _ <- ask+ NetlistEnv _ pre suf _ <- ask let nm1 = if Text.null pre then nm0 else pre <> "_" <> nm0 nm2 = if Text.null suf then nm1 else nm1 <> "_" <> suf return nm2
src/Clash/Normalize/Transformations/DEC.hs view
@@ -1,6 +1,7 @@ {-| Copyright : (C) 2015-2016, University of Twente,- 2021, QBayLogic B.V.+ 2021-2022, QBayLogic B.V.+ 2022, LumiGuide Fietsdetectie B.V. License : BSD2 (see the file LICENSE) Maintainer : QBayLogic B.V. <devops@qbaylogic.com> @@ -28,6 +29,7 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecursiveDo #-}+{-# LANGUAGE ViewPatterns #-} {-# LANGUAGE TemplateHaskell #-} module Clash.Normalize.Transformations.DEC@@ -38,7 +40,7 @@ import Control.Lens ((^.), _1) import qualified Control.Lens as Lens import qualified Control.Monad as Monad-import Data.Bifunctor (second)+import Data.Bifunctor (first, second) import Data.Bits ((.&.), complement) import Data.Coerce (coerce) import qualified Data.Either as Either@@ -77,9 +79,10 @@ import Clash.Core.Name (nameOcc) import Clash.Core.Term ( Alt, LetBinding, Pat(..), PrimInfo(..), Term(..), TickInfo(..)- , collectArgs, collectArgsTicks, mkApps, mkTicks, patIds)+ , collectArgs, collectArgsTicks, mkApps, mkTicks, patIds, stripTicks) import Clash.Core.TyCon (TyConMap, TyConName, tyConDataCons)-import Clash.Core.Type (Type, isPolyFunTy, mkTyConApp, splitFunForallTy)+import Clash.Core.Type+ (Type, TypeView (..), isPolyFunTy, mkTyConApp, splitFunForallTy, tyView) import Clash.Core.Util (mkInternalVar, mkSelectorCase, sccLetBindings) import Clash.Core.Var (isGlobalId, isLocalId, varName) import Clash.Core.VarEnv@@ -471,9 +474,10 @@ -- ^ Case-tree of arguments belonging to the applied term. -> NormalizeSession (Term,[Term]) mkDisjointGroup inScope (fun,(seen,cs)) = do+ tcm <- Lens.view tcCache let argss = Foldable.toList cs argssT = zip [0..] (List.transpose argss)- (sharedT,distinctT) = List.partition (areShared inScope . snd) argssT+ (sharedT,distinctT) = List.partition (areShared tcm inScope . fmap (first stripTicks) . snd) argssT shared = map (second head) sharedT distinct = map (Either.lefts) (List.transpose (map snd distinctT)) cs' = fmap (zip [0..]) cs@@ -482,7 +486,6 @@ (if null shared then cs' else fmap (filter (`notElem` shared)) cs')- tcm <- Lens.view tcCache (distinctCaseM,distinctProjections) <- case distinct of -- only shared arguments: do nothing. [] -> return (Nothing,[])@@ -548,10 +551,19 @@ -- | Arguments are shared between invocations if: -- -- * They contain _no_ references to locally-bound variables--- * Are all equal-areShared :: InScopeSet -> [Either Term Type] -> Bool-areShared _ [] = True-areShared inScope xs@(x:_) = noFV1 && allEqual xs+-- * Are either:+-- 1. All equal+-- 2. A proof of an equality: we don't care about the shape of a proof.+--+-- Whether we have `Refl : True ~ True` or `SomeAxiom : (1 <=? 2) ~ True`+-- it doesn't matter, since when we normalize both sides we always end+-- up with a proof of `True ~ True`.+-- Since DEC only fires for applications where all the type arguments+-- are equal, we can deduce that all equality arguments witness the same+-- equality, hence we don't have to care about the shape of the proof.+areShared :: TyConMap -> InScopeSet -> [Either Term Type] -> Bool+areShared _ _ [] = True+areShared tcm inScope xs@(x:_) = noFV1 && (isProof x || allEqual xs) where noFV1 = case x of Right ty -> getAll (Lens.foldMapOf (typeFreeVars' isLocallyBound IntSet.empty)@@ -560,6 +572,11 @@ (const (All False)) tm) isLocallyBound v = isLocalId v && v `notElemInScopeSet` inScope++ isProof (Left co) = case tyView (inferCoreTypeOf tcm co) of+ TyConApp (nameOcc -> "GHC.Types.~") _ -> True+ _ -> False+ isProof _ = False -- | Create a list of arguments given a map of positions to common arguments, -- and a list of arguments
src/Clash/Primitives/DSL.hs view
@@ -1,6 +1,6 @@ {-| Copyright : (C) 2019, Myrtle Software Ltd.- 2020-2021, QBayLogic B.V.+ 2020-2022, QBayLogic B.V. 2021, Myrtle.ai License : BSD2 (see the file LICENSE) Maintainer : QBayLogic B.V. <devops@qbaylogic.com>@@ -280,7 +280,7 @@ -- to them. If given expression is not an identifier, an intermediate variable -- will be used to assign the given expression to which is subsequently indexed. unvec- :: Backend backend+ :: (HasCallStack, Backend backend) => Text -- ^ Name hint for intermediate signal -> TExpr@@ -422,7 +422,8 @@ -- -- TODO: Implement for (System)Verilog unsignedFromBitVector- :: Size+ :: HasCallStack+ => Size -> Text -- ^ Name hint for intermediate signal -> TExpr@@ -519,7 +520,7 @@ TExpr ty (DataCon ty (DC (ty,0)) (map eex els)) -- | Create an n-tuple of 'TExpr'-tuple :: [TExpr] -> TExpr+tuple :: HasCallStack => [TExpr] -> TExpr tuple [] = error $ "nTuple: Cannot create empty tuple" tuple [_] = -- If we don't put this in: tuple . untuple /= id
src/Clash/Primitives/Sized/ToInteger.hs view
@@ -1,5 +1,5 @@ {-|- Copyright : (C) 2020 QBayLogic+ Copyright : (C) 2020,2022 QBayLogic B.V. License : BSD2 (see the file LICENSE) Maintainer : QBayLogic B.V. <devops@qbaylogic.com> @@ -70,7 +70,7 @@ toIntegerBB hdl hty _isD _primName args _ty = do case args of (Right (LitTy (NumTy i)):_) -> do- iw <- Lens.use intWidth+ iw <- Lens.view intWidth let i1 = width i when (fromInteger i1 > iw) $ do (_,sp) <- Lens.use curCompNm
src/Clash/Primitives/Sized/Vector.hs view
@@ -1,5 +1,5 @@ {-|- Copyright : (C) 2020-2021 QBayLogic+ Copyright : (C) 2020-2022 QBayLogic B.V. License : BSD2 (see the file LICENSE) Maintainer : QBayLogic B.V. <devops@qbaylogic.com> @@ -58,7 +58,7 @@ -- | Blackbox function for 'Clash.Sized.Vector.iterateI' iterateBBF :: HasCallStack => BlackBoxFunction iterateBBF _isD _primName args _resTy = do- tcm <- Lens.use tcCache+ tcm <- Lens.view tcCache pure (Right (meta tcm, bb)) where bb = BBFunction "Clash.Primitives.Sized.Vector.iterateBBF" 0 iterateTF@@ -115,7 +115,7 @@ -- | Blackbox function for 'Clash.Sized.Vector.fold' foldBBF :: HasCallStack => BlackBoxFunction foldBBF _isD _primName args _resTy = do- tcm <- Lens.use tcCache+ tcm <- Lens.view tcCache pure (Right (meta tcm, bb)) where bb = BBFunction "Clash.Primitives.Sized.Vector.foldTF" 0 foldTF
src/Clash/Primitives/Verification.hs view
@@ -70,7 +70,7 @@ bindMaybe _ (Var vId) = pure (id2identifier vId, []) bindMaybe Nothing t = bindMaybe (Just "s") t bindMaybe (Just nm) t = do- tcm <- Lens.use tcCache+ tcm <- Lens.view tcCache newId <- Id.make (Text.pack nm) (expr0, decls) <- mkExpr False Concurrent (NetlistId newId (inferCoreTypeOf tcm t)) t pure