Skip to content

Commit

Permalink
Build UGN table for targets.
Browse files Browse the repository at this point in the history
  • Loading branch information
rslawson committed Feb 26, 2025
1 parent 55ccbd7 commit b10b0ae
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 3 deletions.
4 changes: 2 additions & 2 deletions bittide-instances/src/Bittide/Instances/Hitl/Demo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ dut refClk refRst skyClk rxNs rxPs allProgrammed miso jtagIn =
txDatas = mux <$> txSamplingsDelayed <*> switchDataOut <*> repeat localCounter

switchDataOut :: Vec 7 (Signal GthTx (BitVector 64))
switchDataOut = repeat (pure 0) -- TBD: connect switch
switchDataOut = repeat (pure 0x4444444444444444) -- TBD: connect switch
txStarts :: Vec 7 (Signal GthTx Bool)
txStarts = repeat handshakesCompleteTx

Expand All @@ -412,7 +412,7 @@ dut refClk refRst skyClk rxNs rxPs allProgrammed miso jtagIn =
handshakeRstTx = unsafeFromActiveLow handshakesCompleteTx

localCounter :: Signal GthTx (BitVector 64)
localCounter = register bittideClk handshakeRstTx enableGen 0 (localCounter + 1)
localCounter = register bittideClk handshakeRstTx enableGen 0x3333333333333333 (localCounter + 1)

-- Step 5, wait for stable buffers:
allStable :: Signal Basic125 Bool
Expand Down
41 changes: 41 additions & 0 deletions bittide-instances/src/Bittide/Instances/Hitl/Driver/Demo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,44 @@ driverFunc testName targets = do
else inner new
inner innerInit

muGetUgns ::
(HwTarget, DeviceInfo) -> ProcessStdIoHandles -> VivadoM [(Unsigned 64, Unsigned 64)]
muGetUgns (_, d) gdb = do
let
mmioAddrs :: [String]
mmioAddrs =
[ "0x10000000"
, "0x20000000"
, "0x30000000"
, "0x40000000"
, "0x50000000"
, "0x60000000"
, "0x70000000"
]

readUgnMmio :: String -> IO (Unsigned 64, Unsigned 64)
readUgnMmio addr = do
let
startString = "START OF UGN (" <> addr <> ")"
endString = "END OF UGN (" <> addr <> ")"
Gdb.runCommands
gdb.stdinHandle
[ "printf \"" <> startString <> "\\n\""
, "x/2xg " <> addr
, "printf \"" <> endString <> "\\n\""
]
_ <-
tryWithTimeout "Waiting for GDB to be ready for UGN readout" 15_000_000
$ readUntil gdb.stdoutHandle startString
gdbRead <-
tryWithTimeout "Reading UGN over GDB" 15_000_000 $ readUntil gdb.stdoutHandle endString
-- Temporary debug print of this so I can get a proper parsing setup going later:
putStrLn $ "GDB output: {{\n" <> gdbRead <> "}}"
return (0, 0)

liftIO $ putStrLn $ "Getting UGNs for device " <> show d.deviceId
liftIO $ mapM readUgnMmio mmioAddrs

liftIO
$ putStrLn
"All programmed pin may be asserted from previous test - deasserting on all targets."
Expand Down Expand Up @@ -346,6 +384,9 @@ driverFunc testName targets = do
$ putStrLn
[i|Test case #{testName} stabilised on #{sCount} of #{L.length targets} targets|]

liftIO $ putStrLn "Doing GDB checks for each MU"
_ <- zipWithM muGetUgns targets muGdbs

let
finalExit =
fromMaybe ExitSuccess
Expand Down
6 changes: 5 additions & 1 deletion bittide/src/Bittide/CaptureUgn.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ captureUgn localCounter = Circuit go
where
go ((wbM2S, linkIn), _) = ((wbS2M, pure ()), bittideData)
where
state = C.regEn (0, 0) trigger (bundle (pack <$> localCounter, fromMaybe 0 <$> linkIn))
state =
C.regEn
(0x1111111111111111, 0x2222222222222222)
trigger
(bundle (pack <$> localCounter, fromMaybe 0 <$> linkIn))
stateVec = concatMap swapWords . bitCoerce <$> state

-- Swap the two words of a 64-bit Bitvector to match the word order of
Expand Down

0 comments on commit b10b0ae

Please sign in to comment.