Skip to content

Commit cb93b41

Browse files
Various small fixes - part 11 (#2152)
Various small fixes Improve `Show BlackBox`. Add parentheses for proper precedence for `BBTemplate`. It showed in `show (BlackBoxE ... (BBTemplate ...) ...)`, where the parentheses were missing, making it a surprising read. Co-authored-by: Leon Schoorl <[email protected]>
1 parent 5454b93 commit cb93b41

File tree

12 files changed

+35
-21
lines changed

12 files changed

+35
-21
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ git checkout 1.2
6262

6363
Note that release branches might contain non-released patches.
6464

65-
## GHC compatability
65+
## GHC compatibility
6666
| | Linux | Windows | macOS |
6767
|------|-------|---------|-------|
6868
| 8.6 | ✔️ | ✔️ | ✔️ |

clash-lib/src/Clash/Driver/Types.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ data ClashOpts = ClashOpts
338338
, opt_color :: OverridingBool
339339
-- ^ Show colors in debug output
340340
--
341-
-- Command line flag: -fclash-no-prim-warn
341+
-- Command line flag: -fdiagnostics-color
342342
, opt_intWidth :: Int
343343
-- ^ Set the bit width for the Int/Word/Integer types. The only allowed values
344344
-- are 32 or 64.

clash-lib/src/Clash/Netlist/Types.hs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Copyright : (C) 2012-2016, University of Twente,
33
2017 , Myrtle Software Ltd,
44
2017-2018, Google Inc.
5-
2020-2021, QBayLogic B.V.
5+
2020-2022, QBayLogic B.V.
66
License : BSD2 (see the file LICENSE)
77
Maintainer : QBayLogic B.V. <[email protected]>
88
@@ -740,9 +740,11 @@ data TemplateFunction where
740740
-> TemplateFunction
741741

742742
instance Show BlackBox where
743-
show (BBTemplate t) = "BBTemplate " <> show t
744-
show (BBFunction nm hsh _) =
745-
"<TemplateFunction(nm=" ++ show nm ++ ", hash=" ++ show hsh ++ ")>"
743+
showsPrec d (BBTemplate t) =
744+
showParen (d > 10) $ ("BBTemplate " ++) . showsPrec 11 t
745+
showsPrec _ (BBFunction nm hsh _) =
746+
("<TemplateFunction(nm=" ++) . shows nm . (", hash=" ++) . shows hsh .
747+
(")>" ++)
746748

747749
instance NFData TemplateFunction where
748750
rnf (TemplateFunction is f _) = rnf is `seq` f `seq` ()

clash-lib/src/Clash/Primitives/DSL.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module Clash.Primitives.DSL
2525
BlackBoxHaskellOpts(..)
2626
, blackBoxHaskell
2727

28-
-- * declarations
28+
-- * Declarations
2929
, BlockState (..)
3030
, TExpr
3131
, declaration
@@ -139,10 +139,10 @@ instance Default BlackBoxHaskellOpts where
139139
-- | Create a blackBoxHaskell primitive. To be used as part of an annotation:
140140
--
141141
-- @
142-
-- {-# ANN myFunction (blackBoxHaskell 'myFunction 'myBBF def{_ignoredArguments=[2,3]}) #-}
142+
-- {-\# ANN myFunction (blackBoxHaskell 'myFunction 'myBBF def{_ignoredArguments=[1,2]}) \#-}
143143
-- @
144144
--
145-
-- [2,3] would mean this blackbox __ignores__ its second and third argument.
145+
-- @[1,2]@ would mean this blackbox __ignores__ its second and third argument.
146146
blackBoxHaskell
147147
:: Name
148148
-- ^ blackbox name

clash-prelude/src/Clash/Class/AutoReg/Internal.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{-|
22
Copyright : (C) 2019 , Google Inc.,
3-
2021 , QBayLogic B.V.
3+
2021-2022, QBayLogic B.V.,
44
2021-2022, Myrtle.ai
55
License : BSD2 (see the file LICENSE)
66
Maintainer : QBayLogic B.V. <[email protected]>
@@ -107,7 +107,7 @@ import Control.Lens.Internal.TH (bndrName)
107107
class NFDataX a => AutoReg a where
108108
-- | For documentation see class 'AutoReg'.
109109
--
110-
-- This is version with explicit clock/reset/enable,
110+
-- This is the version with explicit clock\/reset\/enable inputs,
111111
-- "Clash.Prelude" exports an implicit version of this: 'Clash.Prelude.autoReg'
112112
autoReg
113113
:: (HasCallStack, KnownDomain dom)

clash-prelude/src/Clash/Explicit/BlockRam.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,8 @@ module Clash.Explicit.BlockRam
416416
, RamOp(..)
417417
-- * Internal
418418
, blockRam#
419+
, blockRamU#
420+
, blockRam1#
419421
, trueDualPortBlockRam#
420422
)
421423
where

clash-prelude/src/Clash/Explicit/Mealy.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ let macT s (x,y) = (s',s)
8080
-- -> 'Signal' dom Int
8181
-- dualMac clk rst en (a,b) (x,y) = s1 + s2
8282
-- where
83-
-- s1 = 'mealy' clk rst en mac 0 ('bundle' (a,x))
84-
-- s2 = 'mealy' clk rst en mac 0 ('bundle' (b,y))
83+
-- s1 = 'mealy' clk rst en macT 0 ('bundle' (a,x))
84+
-- s2 = 'mealy' clk rst en macT 0 ('bundle' (b,y))
8585
-- @
8686
mealy
8787
:: ( KnownDomain dom

clash-prelude/src/Clash/Explicit/Moore.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ import Clash.XException (NFDataX)
7272
-- -> 'Signal' dom Int
7373
-- dualMac clk rst en (a,b) (x,y) = s1 + s2
7474
-- where
75-
-- s1 = 'moore' clk rst en mac id 0 ('bundle' (a,x))
76-
-- s2 = 'moore' clk rst en mac id 0 ('bundle' (b,y))
75+
-- s1 = 'moore' clk rst en macT id 0 ('bundle' (a,x))
76+
-- s2 = 'moore' clk rst en macT id 0 ('bundle' (b,y))
7777
-- @
7878
moore
7979
:: ( KnownDomain dom

clash-prelude/src/Clash/Num/Overflowing.hs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1+
{-|
2+
Copyright : (C) 2021-2022, QBayLogic B.V.
3+
License : BSD2 (see the file LICENSE)
4+
Maintainer : QBayLogic B.V. <[email protected]>
5+
-}
6+
17
{-# LANGUAGE DeriveAnyClass #-}
28
{-# LANGUAGE FlexibleContexts #-}
39
{-# LANGUAGE TypeFamilies #-}
410
{-# LANGUAGE UndecidableInstances #-}
511

612
module Clash.Num.Overflowing
7-
( Overflowing(fromOverflowing, hasOverflowed)
13+
( Overflowing
14+
, fromOverflowing
15+
, hasOverflowed
816
, toOverflowing
917
, clearOverflow
1018
) where
@@ -31,7 +39,9 @@ import Clash.XException (NFDataX, ShowX)
3139
--
3240
data Overflowing a = Overflowing
3341
{ fromOverflowing :: a
42+
-- ^ Retrieve the value
3443
, hasOverflowed :: Bool
44+
-- ^ 'True' when a computation has overflowed
3545
}
3646
deriving stock (Generic, Show)
3747
deriving anyclass (Binary, Hashable, NFData, NFDataX, ShowX)

clash-prelude/src/Clash/Prelude/Mealy.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ let macT s (x,y) = (s',s)
7171
-- -> 'Signal' dom Int
7272
-- dualMac (a,b) (x,y) = s1 + s2
7373
-- where
74-
-- s1 = 'mealy' mac 0 ('Clash.Signal.bundle' (a,x))
75-
-- s2 = 'mealy' mac 0 ('Clash.Signal.bundle' (b,y))
74+
-- s1 = 'mealy' macT 0 ('Clash.Signal.bundle' (a,x))
75+
-- s2 = 'mealy' macT 0 ('Clash.Signal.bundle' (b,y))
7676
-- @
7777
mealy
7878
:: ( HiddenClockResetEnable dom

0 commit comments

Comments
 (0)