Skip to content

Commit

Permalink
Extend the single TX clock domain notion throughout the rest of bittide
Browse files Browse the repository at this point in the history
Fixes #696
  • Loading branch information
leonschoorl committed Jan 15, 2025
1 parent 2387b4f commit 0696368
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 32 deletions.
4 changes: 2 additions & 2 deletions bittide-instances/src/Bittide/Instances/Hitl/FullMeshHwCc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ fullMeshHwTest refClk sysClk IlaControl{syncRst = rst, ..} rxNs rxPs miso =

callistoResult =
callistoClockControlWithIla @LinkCount @CccBufferSize
(head transceivers.txClocks)
transceivers.txClock
sysClk
clockControlReset
clockControlConfig
Expand Down Expand Up @@ -384,7 +384,7 @@ fullMeshHwTest refClk sysClk IlaControl{syncRst = rst, ..} rxNs rxPs miso =
domainDiffs =
domainDiffCounterExt sysClk clockControlReset
<$> transceivers.rxClocks
<*> transceivers.txClocks
<*> repeat transceivers.txClock

-- | Top entity for this test. See module documentation for more information.
fullMeshHwCcWithRiscvTest ::
Expand Down
27 changes: 13 additions & 14 deletions bittide-instances/src/Bittide/Instances/Hitl/FullMeshSwCc.hs
Original file line number Diff line number Diff line change
Expand Up @@ -244,25 +244,24 @@ fullMeshHwTest refClk sysClk IlaControl{syncRst = rst, ..} rxNs rxPs miso =
, txReadys = txAllStables
, rxReadys = repeat (pure True)
}
txAllStables = zipWith (xpmCdcSingle sysClk) transceivers.txClocks (repeat allStable1)
txAllStables = repeat txAllStable
txAllStable = xpmCdcSingle sysClk transceivers.txClock allStable1
allStable1 = sticky sysClk syncRst allStable0
txResets2 =
zipWith
orReset
map
(orReset (unsafeFromActiveLow txAllStable))
transceivers.txResets
(map unsafeFromActiveLow txAllStables)

txCounters = zipWith txCounter transceivers.txClocks txResets2
txCounters = map (txCounter transceivers.txClock) txResets2
txCounter txClk txRst = result
where
result = register txClk txRst enableGen (0xaabbccddeeff1234 :: BitVector 64) (result + 1)
-- see NOTE [magic start values]

-- rxFifos :: Vec LinkCount (_, _, _, _, _Signal GthRx (Maybe (BitVector 64)))
rxFifos =
zipWith4
go
transceivers.txClocks
zipWith3
(go transceivers.txClock)
transceivers.rxClocks
txResets2
transceivers.rxDatas
Expand All @@ -273,9 +272,9 @@ fullMeshHwTest refClk sysClk IlaControl{syncRst = rst, ..} rxNs rxPs miso =
(fillLvls, fifoUnderflowsTx, fifoOverflowsTx, _ebMode, rxCntrs) = unzip5 rxFifos

fifoOverflowsFree :: Vec LinkCount (Signal Basic125 Overflow)
fifoOverflowsFree = zipWith (flip xpmCdcSingle sysClk) transceivers.txClocks fifoOverflowsTx
fifoOverflowsFree = map (xpmCdcSingle transceivers.txClock sysClk) fifoOverflowsTx
fifoUnderflowsFree :: Vec LinkCount (Signal Basic125 Underflow)
fifoUnderflowsFree = zipWith (flip xpmCdcSingle sysClk) transceivers.txClocks fifoUnderflowsTx
fifoUnderflowsFree = map (xpmCdcSingle transceivers.txClock sysClk) fifoUnderflowsTx

ugns :: Vec LinkCount (Signal GthTx (BitVector 64))
ugns =
Expand All @@ -293,9 +292,9 @@ fullMeshHwTest refClk sysClk IlaControl{syncRst = rst, ..} rxNs rxPs miso =
-- If you see 0x99999999.......... and it's counting up, then you're receiving Nothing,
-- but your counter is running.

ugnStable1sec = zipWith3 (stableForMs (SNat @1000)) transceivers.txClocks transceivers.txResets ugns
ugnStable1sec = zipWith (stableForMs (SNat @1000) transceivers.txClock) transceivers.txResets ugns

freeUgnDatas = zipWith5 go transceivers.txClocks (repeat sysClk) ugns fillLvls ugnStable1sec
freeUgnDatas = zipWith4 (go transceivers.txClock) (repeat sysClk) ugns fillLvls ugnStable1sec
where
go clkIn clkOut ugn fillLvl stable =
regMaybe
Expand Down Expand Up @@ -366,7 +365,7 @@ fullMeshHwTest refClk sysClk IlaControl{syncRst = rst, ..} rxNs rxPs miso =

callistoResult =
callistoClockControlWithIla @LinkCount @CccBufferSize
(head transceivers.txClocks)
transceivers.txClock
sysClk
clockControlReset
clockControlConfig
Expand Down Expand Up @@ -541,7 +540,7 @@ fullMeshHwTest refClk sysClk IlaControl{syncRst = rst, ..} rxNs rxPs miso =
domainDiffs =
domainDiffCounterExt sysClk clockControlReset
<$> transceivers.rxClocks
<*> transceivers.txClocks
<*> repeat transceivers.txClock

{- | Tracks the min/max values of the input during the last milliseconds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ topologyTest refClk sysClk sysRst IlaControl{syncRst = rst, ..} rxNs rxPs miso c

callistoResult =
callistoClockControlWithIla @LinkCount @CccBufferSize
(head transceivers.txClocks)
transceivers.txClock
sysClk
clockControlReset
clockControlConfig
Expand Down Expand Up @@ -614,7 +614,7 @@ topologyTest refClk sysClk sysRst IlaControl{syncRst = rst, ..} rxNs rxPs miso c
domainDiffs =
domainDiffCounterExt sysClk clockControlReset
<$> transceivers.rxClocks
<*> transceivers.txClocks
<*> repeat transceivers.txClock

-- | Top entity for this test. See module documentation for more information.
hwCcTopologyWithRiscvTest ::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,8 @@ transceiversStartAndObserve refClk sysClk rst myIndex rxNs rxPs miso =
-- domains of the transceivers
myIndexTxN =
fmap (zeroExtend . pack . fromMaybe 0)
<$> zipWith
(xpmCdcStable sysClk myIndex)
transceivers.txClocks
<$> map
(xpmCdcStable sysClk myIndex transceivers.txClock)
transceivers.txResets

-- check that all the received data matches with our expectations
Expand Down
5 changes: 2 additions & 3 deletions bittide-instances/src/Bittide/Instances/Hitl/Transceivers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,8 @@ goTransceiversUpTest fpgaIndex refClk sysClk rst rxNs rxPs miso =

-- Send counters
counters =
zipWith3
counter
transceivers.txClocks
zipWith
(counter transceivers.txClock)
transceivers.txResets
transceivers.txSamplings

Expand Down
16 changes: 8 additions & 8 deletions bittide/src/Bittide/Transceiver.hs
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,12 @@ defConfig =
, resetManagerConfig = ResetManager.defConfig
}

{- | Careful: the domains for each transceiver are different, even if their
{- | Careful: the domains for the rx side of each transceiver are different, even if their
types say otherwise.
-}
data Outputs n tx rx txS free = Outputs
{ txClocks :: Vec n (Clock tx)
-- ^ See 'Output.txClock'
{ txClock :: Clock tx
-- ^ Single transmit clock, shared by all links
, txResets :: Vec n (Reset tx)
-- ^ See 'Output.txReset'
, txReadys :: Vec n (Signal tx Bool)
Expand Down Expand Up @@ -200,7 +200,7 @@ data Outputs n tx rx txS free = Outputs

data Output tx rx tx1 rx1 txS free serializedData = Output
{ txOutClock :: Clock tx1
-- ^ TODO
-- ^ Must be routed through xilinxGthUserClockNetworkTx or equivalent to get usable clocks
, txReset :: Reset tx
-- ^ Reset signal for the transmit side. Clock can be unstable until this reset
-- is deasserted.
Expand All @@ -214,7 +214,7 @@ data Output tx rx tx1 rx1 txS free serializedData = Output
, txN :: Signal txS serializedData
-- ^ Transmit data (and implicitly a clock), negative
, rxOutClock :: Clock rx1
-- ^ TODO
-- ^ Must be routed through xilinxGthUserClockNetworkRx or equivalent to get usable clocks
, rxReset :: Reset rx
-- ^ Reset signal for the receive side. Clock can be unstable until this reset
-- is deasserted.
Expand Down Expand Up @@ -298,7 +298,8 @@ To do this completely clean/safe transceiverPrbsN should have two extra
forall arguments, two extra KnownDomain constrainsts.
And either some Proxy arguments or we would have to enable AllowAmbiguousTypes.
Instead I choose to sidestep that and pretend tx1/rx1 and tx/rx are the same.
Because the tx1/rx1 domains aren't visible outside 'transceiverPrbsN',
I choose to sidestep the extra complication and pretend tx1/rx1 and tx/rx are the same.
This disables the typechecking safety we'd normally get from clash,
but vivado should call us out when we make a mistake.
-}
Expand All @@ -324,7 +325,7 @@ transceiverPrbsN ::
transceiverPrbsN opts inputs@Inputs{clock, reset, refClock} =
Outputs
{ -- tx
txClocks = txClocks
txClock = txClock
, txResets = map (.txReset) outputs
, txReadys = map (.txReady) outputs
, txSamplings = map (.txSampling) outputs
Expand Down Expand Up @@ -376,7 +377,6 @@ transceiverPrbsN opts inputs@Inputs{clock, reset, refClock} =
-- see [NOTE: duplicate tx/rx domain]
txClockNw = Gth.xilinxGthUserClockNetworkTx @tx @tx txOutClk txUsrClkRst
(_txClk1s, txClock, _txClkActives) = txClockNw
txClocks = repeat txClock

rxOutClks = map (.rxOutClock) outputs
-- see [NOTE: duplicate tx/rx domain]
Expand Down

0 comments on commit 0696368

Please sign in to comment.