Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various small changes #904

Merged
merged 10 commits into from
Nov 5, 2019
Merged
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@
* Clash's internal type family solver now recognizes `AppendSymbol` and `CmpSymbol`
* Added `Clash.Magic.suffixNameFromNat`: can be used in cases where `suffixName` is too slow
* Added `Clash.Class.AutoReg`. Improves the chances of synthesis tools inferring clock-gated registers, when used. See [#873](https://github.com/clash-lang/clash-compiler/pull/873).

* New internal features:
* [#821](https://github.com/clash-lang/clash-compiler/pull/821): Add `DebugTry`: print name of all tried transformations, even if they didn't succeed
* [#856](https://github.com/clash-lang/clash-compiler/pull/856): Add `-fclash-debug-transformations`: only print debug info for specific transformations
* [#879](https://github.com/clash-lang/clash-compiler/pull/879): Add `-fclash-no-catch-errors`: don't try and catch errors in Clash compiler; let GHC handle it instead

* Fixes issues:
* [#810](https://github.com/clash-lang/clash-compiler/issues/810): Verilog backend now correctly specifies type of `BitVector 1`
Expand All @@ -48,10 +47,12 @@
* TH code for auto deriving bit representations now produces nicer error messages ([7190793](https://github.com/clash-lang/clash-compiler/commit/7190793928545f85157f9b8d4b8ec2edb2cd8a26))
* Adds '--enable-shared-executables' for nix builds; this should make Clash run _much_ faster ([#894](https://github.com/clash-lang/clash-compiler/pull/894))
* Custom bit representations can now mark fields as zero-width without crashing the compiler ([#898](https://github.com/clash-lang/clash-compiler/pull/898))

* Error on unparsed trailing garbage in JSON "files"

* Deprecations & removals:
* Removed support for GHC 8.2 ([#842](https://github.com/clash-lang/clash-compiler/pull/842))
* Removed support for older cabal versions, only Cabal >=2.2 supported ([#851](https://github.com/clash-lang/clash-compiler/pull/851))
* Reset and Enable constructors are now only exported from Clash.Signal.Internal

## 1.0.0 *September 3rd 2019*
* 10x - 50x faster compile times
Expand Down
5 changes: 2 additions & 3 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,5 @@ package clash-lib
flags: debug

optional-packages:
clash-cosim/clash-cosim.cabal,
clash-term/clash-term.cabal,
clash-cores/clash-cores.cabal
./clash-cosim
./clash-cores
18 changes: 0 additions & 18 deletions clash-cores/.gitignore

This file was deleted.

16 changes: 0 additions & 16 deletions clash-cores/.travis.yml

This file was deleted.

18 changes: 0 additions & 18 deletions clash-cores/cabal.project

This file was deleted.

11 changes: 0 additions & 11 deletions clash-cores/stack.yaml

This file was deleted.

7 changes: 1 addition & 6 deletions clash-ghc/src-bin-841/Clash/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,7 @@ main' postLoadMode dflags0 args flagWarnings clashOpts = do
GHC.printException e
liftIO $ exitWith (ExitFailure 1)) $ do
clashOpts' <- liftIO (readIORef clashOpts)
let
clash fun =
if opt_catchErrors clashOpts' then
gcatch (fun clashOpts srcs) (handleClashException dflags6 clashOpts')
else
fun clashOpts srcs
let clash fun = gcatch (fun clashOpts srcs) (handleClashException dflags6 clashOpts')
case postLoadMode of
ShowInterface f -> liftIO $ doShowIface dflags6 f
DoMake -> doMake srcs
Expand Down
7 changes: 1 addition & 6 deletions clash-ghc/src-bin-861/Clash/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,7 @@ main' postLoadMode dflags0 args flagWarnings clashOpts = do
GHC.printException e
liftIO $ exitWith (ExitFailure 1)) $ do
clashOpts' <- liftIO (readIORef clashOpts)
let
clash fun =
if opt_catchErrors clashOpts' then
gcatch (fun clashOpts srcs) (handleClashException dflags6 clashOpts')
else
fun clashOpts srcs
let clash fun = gcatch (fun clashOpts srcs) (handleClashException dflags6 clashOpts')
case postLoadMode of
ShowInterface f -> liftIO $ doShowIface dflags6 f
DoMake -> doMake srcs
Expand Down
7 changes: 1 addition & 6 deletions clash-ghc/src-bin-881/Clash/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,7 @@ main' postLoadMode dflags0 args flagWarnings clashOpts = do
GHC.printException e
liftIO $ exitWith (ExitFailure 1)) $ do
clashOpts' <- liftIO (readIORef clashOpts)
let
clash fun =
if opt_catchErrors clashOpts' then
gcatch (fun clashOpts srcs) (handleClashException dflags6 clashOpts')
else
fun clashOpts srcs
let clash fun = gcatch (fun clashOpts srcs) (handleClashException dflags6 clashOpts')
case postLoadMode of
ShowInterface f -> liftIO $ doShowIface dflags6 f
DoMake -> doMake srcs
Expand Down
4 changes: 0 additions & 4 deletions clash-ghc/src-ghc/Clash/GHC/ClashFlags.hs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ flagsClash r = [
, defFlag "fclash-no-escaped-identifiers" $ NoArg (liftEwM (setNoEscapedIds r))
, defFlag "fclash-compile-ultra" $ NoArg (liftEwM (setUltra r))
, defFlag "fclash-force-undefined" $ OptIntSuffix (setUndefined r)
, defFlag "fclash-no-catch-errors" $ NoArg (liftEwM (setNoCatchErrors r))
]

-- | Print deprecated flag warning
Expand Down Expand Up @@ -147,9 +146,6 @@ setNoCache r = modifyIORef r (\c -> c {opt_cachehdl = False})
setNoIDirCheck :: IORef ClashOpts -> IO ()
setNoIDirCheck r = modifyIORef r (\c -> c {opt_checkIDir = False})

setNoCatchErrors :: IORef ClashOpts -> IO ()
setNoCatchErrors r = modifyIORef r (\c -> c {opt_catchErrors = False})

setNoClean :: IORef ClashOpts -> IO ()
setNoClean r = modifyIORef r (\c -> c {opt_cleanhdl = False})

Expand Down
4 changes: 2 additions & 2 deletions clash-ghc/src-ghc/Clash/GHC/LoadModules.hs
Original file line number Diff line number Diff line change
Expand Up @@ -643,14 +643,14 @@ wantedLanguageExtensions df =
, LangExt.TemplateHaskellQuotes
, LangExt.TypeApplications
, LangExt.TypeFamilies
, LangExt.TypeOperators
#if __GLASGOW_HASKELL__ < 806
, LangExt.TypeInType
#endif
, LangExt.TypeOperators
]
unwanted = [ LangExt.ImplicitPrelude
, LangExt.MonomorphismRestriction
#if MIN_VERSION_ghc(8,6,0)
#if __GLASGOW_HASKELL__ >= 806
, LangExt.StarIsType
#endif
, LangExt.Strict
Expand Down
4 changes: 2 additions & 2 deletions clash-ghc/src-ghc/Clash/GHC/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ handleClashException df opts e = case fromException e of
| otherwise = empty
throwOneError (mkPlainErrMsg df sp (text s $$ srcInfo' $$ showExtra (opt_errorExtra opts) eM))
_ -> case fromException e of
Just (ErrorCall msg) ->
throwOneError (mkPlainErrMsg df noSrcSpan (text "Clash error call:" $$ text msg))
Just (ErrorCallWithLocation _ _) ->
throwOneError (mkPlainErrMsg df noSrcSpan (text "Clash error call:" $$ text (show e)))
_ -> case fromException e of
Just (e' :: SourceError) -> do
GHC.printException e'
Expand Down
7 changes: 0 additions & 7 deletions clash-lib/src/Clash/Driver/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,6 @@ data ClashOpts = ClashOpts { opt_inlineLimit :: Int
-- * /Just (Just x)/: replace undefined's by /x/ in
-- the HDL
, opt_checkIDir :: Bool
, opt_catchErrors :: Bool
-- ^ Whether to catch errors in Clash. Settings this
-- to false might cause 'please report as GHC bug' to
-- appear. On the flipside, it might generate more
-- informative error messages when debugging the
-- compiler - especially on profiling builds.
}


Expand Down Expand Up @@ -123,7 +117,6 @@ defClashOpts
, opt_ultra = False
, opt_forceUndefined = Nothing
, opt_checkIDir = True
, opt_catchErrors = True
}

-- | Information about the generated HDL between (sub)runs of the compiler
Expand Down
2 changes: 1 addition & 1 deletion clash-lib/src/Clash/Netlist/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ unsafeCoreTypeToHWType
-> State HWMap FilteredHWType
unsafeCoreTypeToHWType sp loc builtInTranslation reprs m ty =
either (\msg -> throw (ClashException sp (loc ++ msg) Nothing)) id <$>
coreTypeToHWType builtInTranslation reprs m ty
coreTypeToHWType builtInTranslation reprs m ty

-- | Same as @unsafeCoreTypeToHWTypeM@, but discards void filter information
unsafeCoreTypeToHWTypeM'
Expand Down
10 changes: 9 additions & 1 deletion clash-lib/src/Data/Aeson/Extra.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import Data.List (intercalate)
import Data.Aeson (FromJSON, Result (..), fromJSON, json)
import Data.Attoparsec.Lazy (Result (..), parse)
import Data.ByteString.Lazy (ByteString)
import qualified Data.ByteString.Lazy as BS
import qualified Data.ByteString.Lazy.Char8 as BSChar
import System.FilePath ()

import Clash.Util (ClashException(..))
Expand Down Expand Up @@ -55,8 +57,12 @@ decodeOrErr
-> a
decodeOrErr path contents =
case parse json contents of
Done _ v ->
Done leftover v ->
case fromJSON v of
Success _ | BS.any notWhitespace leftover ->
clashError ("After parsing " ++ show path
++ ", found unparsed trailing garbage:\n"
++ BSChar.unpack leftover)
Success a ->
a
Error msg ->
Expand All @@ -77,3 +83,5 @@ decodeOrErr path contents =
where
loc = mkGeneralSrcSpan $ mkFastString path
clashError msg = throw $ ClashException loc msg Nothing
notWhitespace c = BS.notElem c whitespace
where whitespace = BSChar.pack " \t\n\r"
2 changes: 1 addition & 1 deletion clash-prelude/src/Clash/Annotations/Primitive.hs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ data HDL
-- {\-\# ANN example (InlinePrimitive VHDL $ unindent [i|
-- [ { \"BlackBox\" :
-- { "name" : "InlinePrimitive.example"
-- , "kind": "Declaration"
-- , "kind": \"Declaration\"
-- , "template" :
-- "-- begin InlinePrimitive example:
-- ~GENSYM[example][0] : block
Expand Down
4 changes: 2 additions & 2 deletions clash-prelude/src/Clash/Explicit/Signal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ module Clash.Explicit.Signal
, initBehavior
, resetPolarity
-- ** Enabling
, Enable(..)
, Enable
leonschoorl marked this conversation as resolved.
Show resolved Hide resolved
, toEnable
, fromEnable
, enableGen
Expand All @@ -202,7 +202,7 @@ module Clash.Explicit.Signal
, unsafeSynchronizer
, veryUnsafeSynchronizer
-- * Reset
, Reset(..)
, Reset
leonschoorl marked this conversation as resolved.
Show resolved Hide resolved
, unsafeToReset
, unsafeFromReset
, unsafeToHighPolarity
Expand Down
4 changes: 2 additions & 2 deletions clash-prelude/src/Clash/Explicit/Testbench.hs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ import Clash.Promoted.Symbol (SSymbol (..))
import Clash.Explicit.Signal
(Clock, Reset, System, Signal, clockPeriod, toEnable, fromList, register,
unbundle, unsafeSynchronizer, veryUnsafeSynchronizer)
import Clash.Signal.Internal (Clock (..))
import Clash.Signal.Internal (Clock (..), Reset (..))
import Clash.Signal
(mux, DomainResetKind, ResetKind(Asynchronous), KnownDomain, Reset(..),
(mux, DomainResetKind, ResetKind(Asynchronous), KnownDomain,
Enable)
import Clash.Sized.Index (Index)
import Clash.Sized.Internal.BitVector
Expand Down
4 changes: 2 additions & 2 deletions clash-prelude/src/Clash/Signal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ module Clash.Signal
, unsafeSynchronizer
#endif
-- * Reset
, Reset(..)
, Reset
leonschoorl marked this conversation as resolved.
Show resolved Hide resolved
, unsafeToReset
, unsafeFromReset
, unsafeToHighPolarity
Expand All @@ -153,7 +153,7 @@ module Clash.Signal
, E.resetSynchronizer
, holdReset
-- ** Enabling
, Enable(..)
, Enable
leonschoorl marked this conversation as resolved.
Show resolved Hide resolved
, toEnable
, fromEnable
, S.enableGen
Expand Down
20 changes: 17 additions & 3 deletions clash-prelude/src/Clash/Signal/Bundle.hs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,25 @@ import Clash.Sized.RTree (RTree, lazyT)
-- data D = A | B
--
-- instance Bundle D where
-- type 'Unbundled'' clk D = 'Signal'' clk D
-- 'bundle' _ s = s
-- 'unbundle' _ s = s
-- type 'Unbundled' clk D = 'Signal' clk D
-- 'bundle' s = s
-- 'unbundle' s = s
-- @
--
-- For custom product types you'll have to write the instance manually:
-- @
-- data Pair a b = MkPair { getA :: a, getB :: b }
--
-- instance Bundle (Pair a b) where
-- type Unbundled dom (Pair a b) = Pair (Signal dom a) (Signal dom b)
--
-- -- bundle :: Pair (Signal dom a) (Signal dom b) -> Signal dom (Pair a b)
-- bundle (MkPair as bs) = MkPair <$> as <*> bs
--
-- -- unbundle :: Signal dom (Pair a b) -> Pair (Signal dom a) (Signal dom b)
-- unbundle pairs = MkPair (getA <$> pairs) (getB <$> pairs)
-- @

class Bundle a where
type Unbundled (dom :: Domain) a = res | res -> dom a
type Unbundled dom a = Signal dom a
Expand Down
6 changes: 3 additions & 3 deletions clash-prelude/src/Clash/Signal/Delayed/Bundle.hs
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ import GHC.TypeLits (Nat)
-- data D = A | B
--
-- instance Bundle D where
-- type 'Unbundled' dom delay D = 'DSignal' dom d D
-- 'bundle' _ s = s
-- 'unbundle' _ s = s
-- type 'Unbundled' dom delay D = 'DSignal' dom delay D
-- 'bundle' s = s
-- 'unbundle' s = s
-- @
--
class Bundle a where
Expand Down
12 changes: 6 additions & 6 deletions clash-prelude/src/Clash/Tutorial.hs
Original file line number Diff line number Diff line change
Expand Up @@ -892,14 +892,14 @@ import "Clash.Intel.ClockGen"
'createDomain' vSystem{vName=\"Dom50\", vPeriod=50000}

topEntity
:: Clock \"DomInput\"
-> Signal \"DomInput\" Bool
-> Signal \"Dom50\" Bit
-> Signal \"Dom50\" (BitVector 8)
:: Clock DomInput
-> Signal DomInput Bool
-> Signal Dom50 Bit
-> Signal Dom50 (BitVector 8)
topEntity clk rst =
'exposeClockResetEnable' ('mealy' blinkerT (1,False,0) . Clash.Prelude.isRising 1) pllOut rstSync 'enableGen'
where
(pllOut,pllStable) = 'Clash.Intel.ClockGen.altpll' @"Dom50" (SSymbol @"altpll50") clk ('Clash.Signal.unsafeFromLowPolarity' rst)
(pllOut,pllStable) = 'Clash.Intel.ClockGen.altpll' \@Dom50 (SSymbol \@\"altpll50\") clk ('Clash.Signal.unsafeFromLowPolarity' rst)
rstSync = 'Clash.Signal.resetSynchronizer' pllOut ('Clash.Signal.unsafeFromLowPolarity' pllStable) enableGen

blinkerT (leds,mode,cntr) key1R = ((leds',mode',cntr'),leds)
Expand Down Expand Up @@ -2434,7 +2434,7 @@ topEntity
topEntity clk rst =
exposeClockReset (mealy blinkerT (1,False,0) . isRising 1) pllOut rstSync
where
(pllOut,pllStable) = altpll \@Dom50 (SSymbol \@ \"altpll50\") clk rst
(pllOut,pllStable) = altpll \@Dom50 (SSymbol \@\"altpll50\") clk rst
rstSync = resetSynchronizer pllOut (unsafeToAsyncReset pllStable)

blinkerT (leds,mode,cntr) key1R = ((leds',mode',cntr'),leds)
Expand Down
10 changes: 8 additions & 2 deletions clash-term/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@ For detailed documentation and example visualizations, see the following [README

## Usage Instructions

1. Run `clash` with the 'history' flag, which will write the rewrite history in `history.dat`:
0. Enable the `history` flag on the clash-lib package, by adding to your cabal.project.local:
```
package clash-lib
flags: history
```

1. Run `clash`, which will write the rewrite history in `history.dat`:
```bash
> cabal new-run -- clash --vhdl -f history DebugName examples/ALU.hs
> cabal new-run -- clash --vhdl examples/ALU.hs
```

2. The rewrite history has now been dumped to the file system, in `history.dat`.
Expand Down
Loading