clash-lang / clash-lang/clash-protocols

`IdleCircuit` should be split up

Open
#154 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
25
Forks
12
PR merge metrics
No merged PRs in 30d

Description

`IdleCircuit` is currently defined as:

```haskell
{- | Idle state of a Circuit. Aims to provide no data for both the forward and
backward direction. Transactions are not acknowledged.
-}
class (Protocol p) => IdleCircuit p where
idleFwd :: Proxy p -> Fwd (p :: Type)
idleBwd :: Proxy p -> Bwd (p :: Type)
```

I.e., it forces instances to define both their _Fwd_ and _Bwd_ to be defined simultaneously. This doesn't make sense for protocols such as `CSignal`. I think it should be split up in:

```haskell
class (Protocol p) => IdleFwd p where
idleFwd :: Proxy p -> Fwd (p :: Type)

class (Protocol p) => IdleBwd p where
idleBwd :: Proxy p -> Bwd (p :: Type)

idleSource :: forall p. (IdleFwd p) => Circuit () p
idleSource = Circuit $ const ((), idleFwd $ Proxy @p)

idleSink :: forall p. (IdleBwd p) => Circuit p ()
idleSink = Circuit $ const (idleBwd $ Proxy @p, ())
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by locating the IdleCircuit class, its idleFwd and idleBwd methods, and all affected instances and call sites. Trace how protocols such as CSignal use the current combined constraint before assessing the split. Done means forward-only and backward-only protocols can define the relevant idle behavior without requiring the other direction, with all affected references updated and the project checks passing.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
distributed-systems
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.