Skip to content

Commit

Permalink
Df: registerBwd now places only a single register on the data path
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanG077 committed Mar 14, 2024
1 parent 7a451a7 commit ae93aee
Showing 1 changed file with 28 additions and 10 deletions.
38 changes: 28 additions & 10 deletions src/Protocols/Df.hs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ module Protocols.Df
, forceResetSanity
, dataToMaybe
, maybeToData
, hasData
, fromData
, toData
) where

-- base
Expand Down Expand Up @@ -152,6 +155,21 @@ maybeToData :: Maybe a -> Data a
maybeToData Nothing = NoData
maybeToData (Just a) = Data a

-- | True if `Data` contains a value
hasData :: Data a -> Bool
hasData NoData = False
hasData (Data _) = True

-- | Extract value from `Data`, Bottom on `NoData`
fromData :: (HasCallStack, C.NFDataX a) => Data a -> a
fromData NoData = deepErrorX "fromData: NoData"

Check failure on line 165 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.6.4 / clash 1.8.1

Variable not in scope: deepErrorX :: String -> a

Check failure on line 165 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.2.8 / clash 1.8.1

• Variable not in scope: deepErrorX :: String -> a

Check failure on line 165 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.0.2 / clash 1.6.1

• Variable not in scope: deepErrorX :: String -> a

Check failure on line 165 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 8.10.7 / clash 1.6.1

• Variable not in scope: deepErrorX :: [Char] -> a

Check failure on line 165 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.0.2 / clash 1.8.1

• Variable not in scope: deepErrorX :: String -> a

Check failure on line 165 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 8.10.7 / clash 1.8.1

• Variable not in scope: deepErrorX :: [Char] -> a

Check failure on line 165 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.4.8 / clash 1.8.1

Variable not in scope: deepErrorX :: String -> a
fromData (Data a) = a

-- | Construct a `Data` if bool is True, `NoData` otherwise
toData :: Bool -> a -> Data a
toData False _ = NoData
toData True a = Data a

instance (C.KnownDomain dom, C.NFDataX a, C.ShowX a, Show a) => Simulate (Df dom a) where
type SimulateFwdType (Df dom a) = [Data a]
type SimulateBwdType (Df dom a) = [Ack]
Expand Down Expand Up @@ -632,7 +650,7 @@ roundrobinCollect Parallel
| Maybe.isJust (dataToMaybe dat) = Just (i, dat)
| otherwise = Nothing

-- | Place register on /forward/ part of a circuit.
-- | Place register on /forward/ part of a circuit. This adds combinational delay on the /backward/ path
registerFwd ::
forall dom a .
(C.NFDataX a, C.HiddenClockResetEnable dom) =>
Expand All @@ -645,21 +663,21 @@ registerFwd
oAck = Maybe.isNothing (dataToMaybe s0) || iAck
s1 = if oAck then iDat else s0

-- | Place register on /backward/ part of a circuit. This is implemented using a
-- in-logic two-element shift register.
-- | Place register on /backward/ part of a circuit. This adds combinational delay on the /forward/ path
registerBwd ::
forall dom a .
(C.NFDataX a, C.HiddenClockResetEnable dom) =>
Circuit (Df dom a) (Df dom a)
registerBwd
= forceResetSanity |> Circuit (C.mealyB go (NoData, NoData))
= forceResetSanity |> Circuit go
where
go (ra0, rb) (iDat, Ack iAck) =
(s, (Ack oAck, rb))
where
oAck = Maybe.isNothing (dataToMaybe ra0)
ra1 = if oAck then iDat else ra0
s = if Maybe.isNothing (dataToMaybe rb) || iAck then (NoData, ra1) else (ra1, rb)
go (iDat, iAck) = (Ack <$> oAck, oDat)
where
oAck = regEn True vldOut (coerce <$> iAck)

Check failure on line 676 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.6.4 / clash 1.8.1

Variable not in scope: regEn :: Bool -> f1 Bool -> f2 b0 -> f1 Bool

Check failure on line 676 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.2.8 / clash 1.8.1

• Variable not in scope: regEn :: Bool -> f Bool -> f1 b0 -> f Bool

Check failure on line 676 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.0.2 / clash 1.6.1

• Variable not in scope: regEn :: Bool -> f Bool -> f1 b0 -> f Bool

Check failure on line 676 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 8.10.7 / clash 1.6.1

• Variable not in scope: regEn :: Bool -> f Bool -> f1 b0 -> f Bool

Check failure on line 676 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.0.2 / clash 1.8.1

• Variable not in scope: regEn :: Bool -> f Bool -> f1 b0 -> f Bool

Check failure on line 676 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 8.10.7 / clash 1.8.1

• Variable not in scope: regEn :: Bool -> f Bool -> f1 b0 -> f Bool

Check failure on line 676 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.4.8 / clash 1.8.1

Variable not in scope: regEn :: Bool -> f1 Bool -> f2 b0 -> f1 Bool
vldOut = (hasData <$> iDat) .||. (fmap not oAck)

Check failure on line 677 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.6.4 / clash 1.8.1

Variable not in scope: (.||.) :: f1 Bool -> f1 Bool -> f1 Bool

Check failure on line 677 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.2.8 / clash 1.8.1

• Variable not in scope: (.||.) :: f Bool -> f Bool -> f Bool

Check failure on line 677 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.0.2 / clash 1.6.1

• Variable not in scope: (.||.) :: f Bool -> f Bool -> f Bool

Check failure on line 677 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 8.10.7 / clash 1.6.1

• Variable not in scope: (.||.) :: f Bool -> f Bool -> f Bool

Check failure on line 677 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.0.2 / clash 1.8.1

• Variable not in scope: (.||.) :: f Bool -> f Bool -> f Bool

Check failure on line 677 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 8.10.7 / clash 1.8.1

• Variable not in scope: (.||.) :: f Bool -> f Bool -> f Bool

Check failure on line 677 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.4.8 / clash 1.8.1

Variable not in scope: (.||.) :: f1 Bool -> f1 Bool -> f1 Bool
iDatX0 = fromDataX <$> iDat

Check failure on line 678 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.6.4 / clash 1.8.1

Variable not in scope: fromDataX :: Data a1 -> a3

Check failure on line 678 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.2.8 / clash 1.8.1

• Variable not in scope: fromDataX :: Data a1 -> a3

Check failure on line 678 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.0.2 / clash 1.6.1

• Variable not in scope: fromDataX :: Data a1 -> a3

Check failure on line 678 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 8.10.7 / clash 1.6.1

• Variable not in scope: fromDataX :: Data a1 -> a3

Check failure on line 678 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.0.2 / clash 1.8.1

• Variable not in scope: fromDataX :: Data a1 -> a3

Check failure on line 678 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 8.10.7 / clash 1.8.1

• Variable not in scope: fromDataX :: Data a1 -> a3

Check failure on line 678 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.4.8 / clash 1.8.1

Variable not in scope: fromDataX :: Data a1 -> a3
iDatX1 = regEn (errorX "registerBwd") oAck iDatX0

Check failure on line 679 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.6.4 / clash 1.8.1

Variable not in scope: regEn :: t0 -> f1 Bool -> f1 a3 -> f1 a3

Check failure on line 679 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.6.4 / clash 1.8.1

Variable not in scope: errorX :: String -> t0

Check failure on line 679 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.2.8 / clash 1.8.1

• Variable not in scope: regEn :: t0 -> f Bool -> f a3 -> f a3

Check failure on line 679 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.2.8 / clash 1.8.1

• Variable not in scope: errorX :: String -> t0

Check failure on line 679 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.0.2 / clash 1.6.1

• Variable not in scope: regEn :: t0 -> f Bool -> f a3 -> f a3

Check failure on line 679 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.0.2 / clash 1.6.1

• Variable not in scope: errorX :: String -> t0

Check failure on line 679 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 8.10.7 / clash 1.6.1

• Variable not in scope: regEn :: t0 -> f Bool -> f a3 -> f a3

Check failure on line 679 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 8.10.7 / clash 1.6.1

• Variable not in scope: errorX :: [Char] -> t0

Check failure on line 679 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.0.2 / clash 1.8.1

• Variable not in scope: regEn :: t0 -> f Bool -> f a3 -> f a3

Check failure on line 679 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.0.2 / clash 1.8.1

• Variable not in scope: errorX :: String -> t0

Check failure on line 679 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 8.10.7 / clash 1.8.1

• Variable not in scope: regEn :: t0 -> f Bool -> f a3 -> f a3

Check failure on line 679 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 8.10.7 / clash 1.8.1

• Variable not in scope: errorX :: [Char] -> t0

Check failure on line 679 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.4.8 / clash 1.8.1

Variable not in scope: regEn :: t0 -> f1 Bool -> f1 a3 -> f1 a3

Check failure on line 679 in src/Protocols/Df.hs

View workflow job for this annotation

GitHub Actions / Cabal tests - ghc 9.4.8 / clash 1.8.1

Variable not in scope: errorX :: String -> t0
oDat = toData <$> vldOut <*> (C.mux oAck iDatX0 iDatX1)

-- | A fifo buffer with user-provided depth. Uses blockram to store data. Can
-- handle simultaneous write and read (full throughput rate).
Expand Down

0 comments on commit ae93aee

Please sign in to comment.