diff --git a/circuit-notation.cabal b/circuit-notation.cabal index 05992d5..9f9a0a6 100644 --- a/circuit-notation.cabal +++ b/circuit-notation.cabal @@ -38,4 +38,4 @@ Test-Suite library-testsuite type: exitcode-stdio-1.0 main-is: unittests.hs hs-source-dirs: tests - build-depends: base, circuit-notation, clash-prelude >= 1.0 + build-depends: base, circuit-notation diff --git a/example/Example.hs b/example/Example.hs index 44ae480..f52b0f9 100644 --- a/example/Example.hs +++ b/example/Example.hs @@ -10,15 +10,15 @@ This file contains examples of using the Circuit Notation. -} -{-# LANGUAGE CPP #-} {-# LANGUAGE BlockArguments #-} +{-# LANGUAGE CPP #-} +{-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveFunctor #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} -{-# LANGUAGE DataKinds #-} #if __GLASGOW_HASKELL__ < 810 -{-# LANGUAGE Arrows #-} +{-# LANGUAGE Arrows #-} #endif {-# OPTIONS -fplugin=CircuitNotation #-} @@ -34,9 +34,9 @@ This file contains examples of using the Circuit Notation. module Example where -import Circuit +import Circuit -import Clash.Prelude (Signal, Vec(..)) +import Clash.Prelude (Signal, Vec (..)) idCircuit :: Circuit a a idCircuit = idC @@ -139,6 +139,14 @@ vec0 = circuit \[] -> () vec00 :: Circuit (Vec 0 a) (Vec 0 a) vec00 = circuit \[] -> [] +-- test that signals can be duplicated +dupSignalC0 :: Circuit (Signal dom Bool) (Signal dom Bool, Signal dom Bool) +dupSignalC0 = circuit $ \x -> (x, x) + +dupSignalC1 :: Circuit (Signal dom Bool) (Signal dom Bool, Signal dom Bool, Signal dom Bool) +dupSignalC1 = circuit $ \x -> do + y <- idC -< x + idC -< (y, y, x) -- -- myDesire :: Circuit Int Char -- -- myDesire = Circuit (\(aM2S,bS2M) -> let diff --git a/src/CircuitNotation.hs b/src/CircuitNotation.hs index 030e3ca..a3f3feb 100644 --- a/src/CircuitNotation.hs +++ b/src/CircuitNotation.hs @@ -657,7 +657,7 @@ checkCircuit = do when (length ss > 1) $ errM (head ss) $ "Slave port " <> show name <> " defined " <> show (length ss) <> " times" - -- if master is defined multiple times, we try to broadcast it + -- if master is defined multiple times, we broadcast it if length ms > 1 then pure [name] else pure [] diff --git a/tests/unittests.hs b/tests/unittests.hs index 5a12596..cdecba3 100644 --- a/tests/unittests.hs +++ b/tests/unittests.hs @@ -1,5 +1,3 @@ -{-# LANGUAGE Arrows #-} - -- This option is a test by itself: if we were to export a plugin with the -- wrong type or name, GHC would refuse to compile this file. {-# OPTIONS -fplugin=CircuitNotation #-} @@ -7,19 +5,6 @@ module Main where import Circuit -import Clash.Prelude main :: IO () main = pure () - -testIdCircuit :: Circuit (Signal dom Bool) (Signal dom Bool) -testIdCircuit = circuit $ \x -> x - --- test that signals can be duplicated -testDupCircuit :: Circuit (Signal dom Bool) (Signal dom Bool, Signal dom Bool) -testDupCircuit = circuit $ \x -> (x, x) - -testDup2Circuit :: Circuit (Signal dom Bool) (Signal dom Bool, Signal dom Bool, Signal dom Bool) -testDup2Circuit = circuit $ \x -> do - y <- idC -< x - idC -< (y, y, x)