Skip to content

Commit

Permalink
With #659 now merged, these instances can be cleaned up.
Browse files Browse the repository at this point in the history
  • Loading branch information
rslawson committed Nov 1, 2024
1 parent 1f20d62 commit d8c8f04
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 73 deletions.
43 changes: 3 additions & 40 deletions bittide/src/Bittide/ClockControl/DebugRegister.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ module Bittide.ClockControl.DebugRegister (
debugRegisterWb,
) where

import GHC.Records (HasField (..))

import Clash.Prelude hiding (PeriodToCycles)

import Protocols
Expand All @@ -23,19 +21,14 @@ import Bittide.ClockControl (SpeedChange)
import qualified Bittide.ClockControl.Callisto.Types as T
import Bittide.Wishbone
import Clash.Explicit.Signal.Extra (changepoints)
import Clash.Signal.TH.Extra (deriveSignalHasFields)
import Clash.Sized.Vector.ToTuple (vecToTuple)

data DebugRegisterCfg = DebugRegisterCfg
{ reframingEnabled :: Bool
}

instance
HasField
"reframingEnabled"
(Signal dom DebugRegisterCfg)
(Signal dom Bool)
where
getField = fmap reframingEnabled
deriveSignalHasFields ''DebugRegisterCfg

{- | Debug register data
This record type contains debugging information that is reported from the CPU or
Expand All @@ -56,37 +49,7 @@ data DebugRegisterData = DebugRegisterData
, updatePeriodMax :: Unsigned 32
}

instance
HasField
"reframingState"
(Signal dom DebugRegisterData)
(Signal dom (Maybe T.ReframingState))
where
getField = fmap reframingState

instance
HasField
"updatePeriod"
(Signal dom DebugRegisterData)
(Signal dom (Unsigned 32))
where
getField = fmap updatePeriod

instance
HasField
"updatePeriodMin"
(Signal dom DebugRegisterData)
(Signal dom (Unsigned 32))
where
getField = fmap updatePeriodMin

instance
HasField
"updatePeriodMax"
(Signal dom DebugRegisterData)
(Signal dom (Unsigned 32))
where
getField = fmap updatePeriodMax
deriveSignalHasFields ''DebugRegisterData

-- | Used just to match the discriminants of the 'ReframingState' type.
data ReframingStateKind = Detect | Wait | Done deriving (Generic, NFDataX, BitPack)
Expand Down
35 changes: 2 additions & 33 deletions bittide/src/Bittide/ClockControl/Registers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

module Bittide.ClockControl.Registers where

import GHC.Records (HasField (..))

import Clash.Prelude hiding (PeriodToCycles)

import Protocols
Expand All @@ -16,6 +14,7 @@ import Bittide.ClockControl
import Bittide.ClockControl.StabilityChecker
import Bittide.Wishbone
import Clash.Functor.Extra
import Clash.Signal.TH.Extra (deriveSignalHasFields)
import Clash.Sized.Vector.ToTuple (vecToTuple)

data ClockControlData (nLinks :: Nat) = ClockControlData
Expand All @@ -26,37 +25,7 @@ data ClockControlData (nLinks :: Nat) = ClockControlData
}
deriving (Generic, NFDataX, ShowX, Show)

instance
HasField
"clockMod"
(Signal dom (ClockControlData nLinks))
(Signal dom (Maybe SpeedChange))
where
getField = fmap clockMod

instance
HasField
"stabilityIndications"
(Signal dom (ClockControlData nLinks))
(Signal dom (Vec nLinks StabilityIndication))
where
getField = fmap stabilityIndications

instance
HasField
"allStable"
(Signal dom (ClockControlData nLinks))
(Signal dom Bool)
where
getField = fmap allStable

instance
HasField
"allSettled"
(Signal dom (ClockControlData nLinks))
(Signal dom Bool)
where
getField = fmap allSettled
deriveSignalHasFields ''ClockControlData

{- | A wishbone accessible clock control interface.
This interface receives the link mask and 'RelDataCount's from all links.
Expand Down

0 comments on commit d8c8f04

Please sign in to comment.