Skip to content

Commit 5aeff85

Browse files
Change type Bwd (CSignal dom a) from Signal dom () to ()
There is no reason it should be a `Signal` on the backwards, it just leads to syntactic noise.
1 parent 456a45f commit 5aeff85

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

clash-protocols-base/src/Protocols/Plugin.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ instance (C.KnownNat n) => Protocol (C.Vec n a) where
6464
-- XXX: Type families with Signals on LHS are currently broken on Clash:
6565
instance Protocol (CSignal dom a) where
6666
type Fwd (CSignal dom a) = C.Signal dom a
67-
type Bwd (CSignal dom a) = C.Signal dom ()
67+
type Bwd (CSignal dom a) = ()
6868

6969
-- | @circuit-notation@ plugin repurposed for "Protocols".
7070
plugin :: GHC.Plugin

clash-protocols/src/Protocols/Df.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -960,9 +960,9 @@ unsafeFromMaybe = circuit $ \maybes -> do
960960
idC -< (as1, droppeds)
961961
where
962962
go2 ::
963-
(Signal dom (Maybe a), (Signal dom Ack, Signal dom ())) ->
964-
(Signal dom (), (Signal dom (Maybe a), Signal dom (C.Unsigned n)))
965-
go2 (fwdA, (ackB, _)) = (C.pure (), C.mealyB go1 (Nothing, 0) (fwdA, ackB))
963+
(Signal dom (Maybe a), (Signal dom Ack, ())) ->
964+
((), (Signal dom (Maybe a), Signal dom (C.Unsigned n)))
965+
go2 (fwdA, (ackB, _)) = ((), C.mealyB go1 (Nothing, 0) (fwdA, ackB))
966966

967967
go1 ::
968968
(Maybe a, C.Unsigned n) ->

clash-protocols/src/Protocols/Internal.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ instance (C.KnownNat n, Backpressure a) => Backpressure (C.Vec n a) where
104104
boolsToBwd _ bs = C.repeat (boolsToBwd (Proxy @a) bs)
105105

106106
instance Backpressure (CSignal dom a) where
107-
boolsToBwd _ _ = pure ()
107+
boolsToBwd _ _ = ()
108108

109109
{- | Right-to-left circuit composition.
110110
@@ -350,7 +350,7 @@ instance (C.KnownDomain dom) => Simulate (CSignal dom a) where
350350
type SimulateChannels (CSignal dom a) = 1
351351

352352
simToSigFwd Proxy list = C.fromList_lazy list
353-
simToSigBwd Proxy () = pure ()
353+
simToSigBwd Proxy () = ()
354354
sigToSimFwd Proxy sig = C.sample_lazy sig
355355
sigToSimBwd Proxy _ = ()
356356

@@ -368,7 +368,7 @@ instance (C.NFDataX a, C.ShowX a, Show a, C.KnownDomain dom) => Drivable (CSigna
368368
in Circuit (\_ -> ((), fwd1))
369369

370370
sampleC SimulationConfig{resetCycles, ignoreReset} (Circuit f) =
371-
let sampled = CE.sample_lazy (snd (f ((), pure ())))
371+
let sampled = CE.sample_lazy (snd (f ((), ())))
372372
in if ignoreReset then drop resetCycles sampled else sampled
373373

374374
{- | Simulate a circuit. Includes samples while reset is asserted.

clash-protocols/src/Protocols/PacketStream/Base.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ unsafeFromCSignal ::
317317
Circuit
318318
(CSignal dom (Maybe (PacketStreamM2S dataWidth meta)))
319319
(PacketStream dom dataWidth meta)
320-
unsafeFromCSignal = Circuit (\(fwdInS, _) -> (pure (), fwdInS))
320+
unsafeFromCSignal = Circuit (\(fwdInS, _) -> ((), fwdInS))
321321

322322
-- | Converts a 'PacketStream' into a 'CSignal': always acknowledges.
323323
toCSignal ::
@@ -359,7 +359,7 @@ unsafeAbortOnBackpressureC ::
359359
(CSignal dom (Maybe (PacketStreamM2S dataWidth meta)))
360360
(PacketStream dom dataWidth meta)
361361
unsafeAbortOnBackpressureC =
362-
Circuit $ \(fwdInS, bwdInS) -> (pure (), go <$> bundle (fwdInS, bwdInS))
362+
Circuit $ \(fwdInS, bwdInS) -> ((), go <$> bundle (fwdInS, bwdInS))
363363
where
364364
go (fwdIn, bwdIn) =
365365
fmap (\pkt -> pkt{_abort = _abort pkt || not (_ready bwdIn)}) fwdIn

clash-protocols/src/Protocols/Wishbone/Standard.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ crossbarSwitch ::
9090
crossbarSwitch = Circuit go
9191
where
9292
go ((route, bundle -> m2ss0), bundle -> s2ms0) =
93-
((pure (), unbundle s2ms1), unbundle m2ss1)
93+
(((), unbundle s2ms1), unbundle m2ss1)
9494
where
9595
m2ss1 = scatter @_ @_ @_ @_ @0 (repeat emptyWishboneM2S) <$> route <*> m2ss0
9696
s2ms1 = gather <$> s2ms0 <*> route

clash-protocols/tests/Tests/Protocols/Df.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ prop_toMaybeFromMaybe =
560560
Df.forceResetSanity
561561
|> Df.toMaybe
562562
|> Df.unsafeFromMaybe
563-
|> Circuit (first (,pure ()) . swap . first (fmap go) . first C.bundle)
563+
|> Circuit (first (,()) . swap . first (fmap go) . first C.bundle)
564564
where
565565
go :: (Maybe Int, C.Unsigned 64) -> Maybe (Int, C.Unsigned 64)
566566
go (a, b) = liftA2 (,) a (Just b)

0 commit comments

Comments
 (0)