Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
62 commits
Select commit Hold shift + click to select a range
3f5bc61
Use `addressableBytesWb` in `wbStorage`
lmbollen Jan 20, 2026
a525d64
Use `addressableBytesWb` in `wbStorage`
lmbollen Jan 20, 2026
48bbfb5
Use `addressableBytesWb` in `wbStorage`
lmbollen Jan 20, 2026
84c7f3a
Use `addressableBytesWb` in `wbStorage`
lmbollen Jan 20, 2026
5c199f0
Use `addressableBytesWb` in `wbStorage`
lmbollen Jan 20, 2026
59ed724
Use `addressableBytesWb` in `wbStorage`
lmbollen Jan 20, 2026
9254574
Use `addressableBytesWb` in `wbStorage`
lmbollen Jan 20, 2026
6db7187
Use `addressableBytesWb` in `wbStorage`
lmbollen Jan 20, 2026
0018d1f
Use `addressableBytesWb` in `wbStorage`
lmbollen Jan 20, 2026
7e43c5c
Use `addressableBytesWb` in `wbStorage`
lmbollen Jan 20, 2026
4f1796e
Use `addressableBytesWb` in `wbStorage`
lmbollen Jan 20, 2026
e11711c
Use `addressableBytesWb` in `wbStorage`
lmbollen Jan 20, 2026
0c48eb0
Use `addressableBytesWb` in `wbStorage`
lmbollen Jan 20, 2026
f801a64
Use `addressableBytesWb` in `wbStorage`
lmbollen Jan 20, 2026
40a0081
Add types and test for implementing ringbuffer abstractions in rust
lmbollen Dec 18, 2025
fc6e77e
Increase `ScatterGather` test instance memory size in preparation for…
lmbollen Jan 8, 2026
6f2d36a
Add `smoltcp` `Device` implementation for pairs of `TransmitRingbuffe…
lmbollen Jan 8, 2026
d1fcea0
Add ringbuffer smoltcp loopback test
lmbollen Jan 8, 2026
ae17b97
Add timing peripheral to `ScatterGather` test architecture
lmbollen Jan 9, 2026
9b9a006
Lower smoltcp simtest frequency.
lmbollen Jan 9, 2026
c8e911c
Use timer peripheral in `ringbuffer_smoltcp_test`
lmbollen Jan 9, 2026
2a1a88a
Change `Device` implementation for ringbuffers to operate on `Ip` ins…
lmbollen Jan 9, 2026
d1cf2cd
Optimize ringbuffer interactions in smoltcp device
lmbollen Jan 9, 2026
e8d909c
Simplify ringbuffer_smoltcp test
lmbollen Jan 9, 2026
7d1d2a8
Actually test out of range in `testIncreaseBuswidth`
lmbollen Mar 5, 2026
0f62f04
Refactor ringbuffer tests
lmbollen Mar 5, 2026
245016f
Change `release_max_level_info` to `release_max_level_trace`
lmbollen Mar 9, 2026
73cfe4b
Rewrite `ringbuffer-smoltcp` to use new networking infra
lmbollen Mar 9, 2026
e024fcf
Add `waitForLineAny`
lmbollen Mar 9, 2026
b6e9baf
Add inbound UGN collection test
lmbollen Mar 9, 2026
1a00c51
Add debug.json
lmbollen Mar 9, 2026
ea89f0a
Set MANAGER_DNA
lmbollen Mar 9, 2026
9d37fa2
Add panic handler
lmbollen Mar 9, 2026
d9954e1
Add logging
lmbollen Mar 9, 2026
e3ace71
Sequential ugn collection
lmbollen Mar 9, 2026
e2ce418
More logging
lmbollen Mar 9, 2026
3d46687
small change
lmbollen Mar 9, 2026
b492139
Bump tests
lmbollen Mar 10, 2026
c2f92f7
Clear txs before alignment
lmbollen Mar 11, 2026
4660bff
Add polling traces
lmbollen Mar 11, 2026
43c0592
More ringbuffer logging
lmbollen Mar 11, 2026
905d27d
Increase duration
lmbollen Mar 11, 2026
d5628f7
Use Aligned and fix some things
lmbollen Mar 11, 2026
ce03ccc
Less tracing in ringbuffers
lmbollen Mar 11, 2026
f65fca6
Use macros
lmbollen Mar 11, 2026
1d31983
Print device MTUs
lmbollen Mar 11, 2026
e4eb1c9
First step then poll
lmbollen Mar 11, 2026
3e834c1
Simplify
lmbollen Mar 11, 2026
85991a4
Add exception handler
lmbollen Mar 11, 2026
2cf0375
bound MTU to 1500
lmbollen Mar 11, 2026
2b986f0
Print alignment info
lmbollen Mar 11, 2026
356b5fb
Trace later
lmbollen Mar 11, 2026
e4e67a1
Add smoltcp::ringbuffer logging
lmbollen Mar 11, 2026
3c4b599
Instrument ringbuffer implementations with more logging
lmbollen Mar 11, 2026
945bd3c
more device logging
lmbollen Mar 11, 2026
0c5d1e2
More CSR options
lmbollen Mar 12, 2026
34c3807
Increase management unit memory sizes
lmbollen Mar 12, 2026
d412635
Add `CargoBuildType` argument to `initGdb
lmbollen Mar 12, 2026
37c7a7c
Add breakpoints to management unit
lmbollen Mar 12, 2026
d5bb42a
Export `start` and `stop` from `Gdb
lmbollen Mar 12, 2026
91bf1b0
Get CPU state when stopping GDB
lmbollen Mar 12, 2026
a912dd6
fixup! Use Aligned and fix some things
lmbollen Mar 16, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/synthesis/debug.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[
{"top": "softUgnDemoTest", "stage": "test", "cc_report": true}
]
2 changes: 1 addition & 1 deletion bittide-cpus/data/Riscv32imc0.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ object Riscv32imc0 extends App {
),

new CsrPlugin(
CsrPluginConfig.smallest.copy(
CsrPluginConfig.all.copy(
ebreakGen = true,
mtvecAccess = CsrAccess.READ_WRITE,
withPrivilegedDebug = true
Expand Down
2 changes: 1 addition & 1 deletion bittide-cpus/data/Riscv32imc1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ object Riscv32imc1 extends App {
),

new CsrPlugin(
CsrPluginConfig.smallest.copy(
CsrPluginConfig.all.copy(
ebreakGen = true,
mtvecAccess = CsrAccess.READ_WRITE,
withPrivilegedDebug = true
Expand Down
2 changes: 1 addition & 1 deletion bittide-cpus/data/Riscv32imc2.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ object Riscv32imc2 extends App {
),

new CsrPlugin(
CsrPluginConfig.smallest.copy(
CsrPluginConfig.all.copy(
ebreakGen = true,
mtvecAccess = CsrAccess.READ_WRITE,
withPrivilegedDebug = true
Expand Down
2 changes: 1 addition & 1 deletion bittide-cpus/data/Riscv32imc3.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ object Riscv32imc3 extends App {
),

new CsrPlugin(
CsrPluginConfig.smallest.copy(
CsrPluginConfig.all.copy(
ebreakGen = true,
mtvecAccess = CsrAccess.READ_WRITE,
withPrivilegedDebug = true
Expand Down
13 changes: 13 additions & 0 deletions bittide-extra/src/Project/Chan.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module Project.Chan where

import Prelude hiding (filter)

import Control.Concurrent.Async (async, waitAnyCancel)
import Control.Concurrent.Chan
import Data.ByteString (ByteString)
import Debug.Trace
Expand Down Expand Up @@ -46,3 +47,15 @@ Do not use on Handles that might return non-ASCII characters.
-}
readUntilLine :: Chan ByteString -> String -> IO [String]
readUntilLine h = readUntilLineWith h readChan

{- | Wait for a line to appear on any channel and return its index.
Only use in combination with sensible timeouts.
-}
waitForLineAny :: (HasCallStack) => [Chan ByteString] -> String -> IO Int
waitForLineAny chans expected = do
asyncs <-
mapM
(\(idx, chan) -> async $ waitForLine chan expected >> pure idx)
(zip [0 :: Int ..] chans)
(_, idx) <- waitAnyCancel asyncs
pure idx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ driverFunc _name targets = do
<> show (L.length <$> allTapInfos)

Gdb.withGdbs (L.length targets) $ \gdbs -> do
liftIO $ zipWithConcurrently3_ (initGdb hitlDir "clock-board") gdbs peTapInfos targets
liftIO $ zipWithConcurrently3_ (initGdb hitlDir "clock-board" Release) gdbs peTapInfos targets
liftIO $ mapConcurrently_ ((assertEither =<<) . Gdb.loadBinary) gdbs

let picocomStarts = liftIO <$> L.zipWith (initPicocom hitlDir) targets [0 ..]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ muConfig ::
muConfig =
PeConfig
{ cpu = Riscv32imc.vexRiscv1
, depthI = SNat @(Div (128 * 1024) 4)
, depthD = SNat @(Div (64 * 1024) 4)
, depthI = SNat @(Div (320 * 1024) 4)
, depthD = SNat @(Div (80 * 1024) 4)
, initI = Nothing
, initD = Nothing
, iBusTimeout = d0
Expand Down
131 changes: 117 additions & 14 deletions bittide-instances/src/Bittide/Instances/Hitl/SoftUgnDemo/Driver.hs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ driver testName targets = do

Gdb.withGdbs (L.length targets) $ \bootGdbs -> do
liftIO
$ zipWithConcurrently3_ (initGdb hitlDir "switch-demo1-boot") bootGdbs bootTapInfos targets
$ zipWithConcurrently3_ (initGdb hitlDir "switch-demo1-boot" Release) bootGdbs bootTapInfos targets
liftIO $ mapConcurrently_ ((assertEither =<<) . Gdb.loadBinary) bootGdbs
liftIO $ mapConcurrently_ Gdb.continue bootGdbs
liftIO
Expand Down Expand Up @@ -102,11 +102,11 @@ driver testName targets = do
<> show (L.length <$> allTapInfos)

Gdb.withGdbs (L.length targets) $ \ccGdbs -> do
liftIO $ zipWithConcurrently3_ (initGdb hitlDir "clock-control") ccGdbs ccTapInfos targets
liftIO $ zipWithConcurrently3_ (initGdb hitlDir "clock-control" Release) ccGdbs ccTapInfos targets
liftIO $ mapConcurrently_ ((assertEither =<<) . Gdb.loadBinary) ccGdbs

Gdb.withGdbs (L.length targets) $ \muGdbs -> do
liftIO $ zipWithConcurrently3_ (initGdb hitlDir "soft-ugn-mu") muGdbs muTapInfos targets
liftIO $ zipWithConcurrently3_ (initGdb hitlDir "soft-ugn-mu" Release) muGdbs muTapInfos targets
liftIO $ mapConcurrently_ ((assertEither =<<) . Gdb.loadBinary) muGdbs

brackets picocomStarts (liftIO . snd) $ \(L.map fst -> picocoms) -> do
Expand All @@ -131,17 +131,6 @@ driver testName targets = do
hardwareRoundtrips = calculateRoundtripLatencies $ L.concat hardwareUgns
_ <- liftIO $ do
putStrLn "\n=== Hardware UGN Roundtrip Latencies ==="
mapM print hardwareRoundtrips
liftIO
$ T.tryWithTimeoutOn
T.PrintActionTime
"Waiting for calendar initialization"
(30_000_000)
goDumpCcSamples
$ forConcurrently_ picocoms
$ \pico ->
waitForLine pico "[MU] All calendars initialized"

softwareUgnsPerNode <-
liftIO
$ T.tryWithTimeoutOn
Expand Down Expand Up @@ -222,3 +211,117 @@ driver testName targets = do
liftIO goDumpCcSamples

pure ExitSuccess

driver2 ::
(HasCallStack) =>
String ->
[(HwTarget, DeviceInfo)] ->
VivadoM ExitCode
driver2 testName targets = do
liftIO
. putStrLn
$ "Running driver function for targets "
<> show ((\(_, info) -> info.deviceId) <$> targets)

projectDir <- liftIO $ findParentContaining "cabal.project"
let hitlDir = projectDir </> "_build/hitl" </> testName

forM_ targets (assertProbe "probe_test_start")

let
-- BOOT / MU / CC IDs
expectedJtagIds = [0x0514C001, 0x1514C001, 0x2514C001]
toInitArgs (_, deviceInfo) targetIndex =
Ocd.InitOpenOcdArgs{deviceInfo, expectedJtagIds, hitlDir, targetIndex}
initArgs = L.zipWith toInitArgs targets [0 ..]
optionalBootInitArgs = L.repeat def{Ocd.logPrefix = "boot-", Ocd.initTcl = "vexriscv_boot_init.tcl"}
openOcdBootStarts = liftIO <$> L.zipWith Ocd.initOpenOcd initArgs optionalBootInitArgs

let picocomStarts = liftIO <$> L.zipWith (initPicocom hitlDir) targets [0 ..]
brackets picocomStarts (liftIO . snd) $ \(L.map fst -> picocoms) -> do
-- Start OpenOCD that will program the boot CPU
brackets openOcdBootStarts (liftIO . (.cleanup)) $ \initOcdsData -> do
let bootTapInfos = parseBootTapInfo <$> initOcdsData

Gdb.withGdbs (L.length targets) $ \bootGdbs -> do
liftIO
$ zipWithConcurrently3_ (initGdb hitlDir "switch-demo1-boot" Release) bootGdbs bootTapInfos targets
liftIO $ mapConcurrently_ ((assertEither =<<) . Gdb.loadBinary) bootGdbs
liftIO $ mapConcurrently_ Gdb.continue bootGdbs
liftIO
$ T.tryWithTimeout T.PrintActionTime "Waiting for done" 60_000_000
$ forConcurrently_ picocoms
$ \pico ->
waitForLine pico "[BT] Going into infinite loop.."

let
optionalInitArgs = L.repeat def
openOcdStarts = liftIO <$> L.zipWith Ocd.initOpenOcd initArgs optionalInitArgs

-- Start OpenOCD instances for all CPUs
brackets openOcdStarts (liftIO . (.cleanup)) $ \initOcdsData -> do
let
allTapInfos = parseTapInfo expectedJtagIds <$> initOcdsData

_bootTapInfos, muTapInfos, ccTapInfos :: [Ocd.TapInfo]
(_bootTapInfos, muTapInfos, ccTapInfos)
| all (== L.length expectedJtagIds) (L.length <$> allTapInfos)
, [boots, mus, ccs] <- L.transpose allTapInfos =
(boots, mus, ccs)
| otherwise =
error
$ "Unexpected number of OpenOCD taps initialized. Expected: "
<> show (L.length expectedJtagIds)
<> ", but got: "
<> show (L.length <$> allTapInfos)

gdbStarts = liftIO <$> fmap (const Gdb.start) targets
gdbCleanupAction gdb = do
putStrLn "Retrieving final CPU state"
Gdb.interruptCommand gdb
Gdb.runCommand gdb
. unlines
$ [ "printf \"Final CPU state\\n\""
, "i r"
, "bt"
]
Gdb.stop gdb

brackets gdbStarts (liftIO . gdbCleanupAction) $ \ccGdbs -> do
-- Gdb.withGdbs (L.length targets) $ \ccGdbs -> do
liftIO $ zipWithConcurrently3_ (initGdb hitlDir "clock-control" Release) ccGdbs ccTapInfos targets
liftIO $ mapConcurrently_ ((assertEither =<<) . Gdb.loadBinary) ccGdbs

brackets gdbStarts (liftIO . gdbCleanupAction) $ \muGdbs -> do
-- Gdb.withGdbs (L.length targets) $ \muGdbs -> do
liftIO
$ zipWithConcurrently3_ (initGdb hitlDir "soft-ugn-demo-mu-2" Release) muGdbs muTapInfos targets
liftIO $ mapConcurrently_ ((assertEither =<<) . Gdb.loadBinary) muGdbs

brackets picocomStarts (liftIO . snd) $ \(L.map fst -> picocoms) -> do
let goDumpCcSamples = dumpCcSamples hitlDir (defCcConf (natToNum @FpgaCount)) ccGdbs

_ <- liftIO $ do
mapConcurrently
( \gdb -> do
Gdb.setBreakpoints gdb ["_start_trap_rust"]
Gdb.setBreakpointHook gdb
)
muGdbs

liftIO $ mapConcurrently_ Gdb.continue ccGdbs
liftIO $ mapConcurrently_ Gdb.continue muGdbs

liftIO
$ T.tryWithTimeoutOn
T.PrintActionTime
"Waiting for CPU test status"
(360_000_000)
goDumpCcSamples
$ forConcurrently_ picocoms
$ \pico ->
waitForLine pico "[MU] Demo complete."

liftIO goDumpCcSamples

pure ExitSuccess
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ tests =
, externalHdl = []
, testCases =
[ HitlTestCase
{ name = "Bittide_Demo_DUT"
{ name = "Bittide_Demo_DUT_mu2"
, parameters = paramForHwTargets allHwTargets ()
, postProcData = ()
}
]
, mDriverProc = Just Driver.driver
, mDriverProc = Just Driver.driver2
, mPostProc = Nothing
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,16 @@ dumpCcSamples hitlDir ccConf ccGdbs = do
initGdb ::
FilePath ->
String ->
CargoBuildType ->
Gdb ->
Ocd.TapInfo ->
(HwTarget, DeviceInfo) ->
IO ()
initGdb hitlDir binName gdb tapInfo (hwT, _d) = do
initGdb hitlDir binName buildType gdb tapInfo (hwT, _d) = do
Gdb.setLogging gdb
$ hitlDir
</> "gdb-" <> binName <> "-" <> show (getTargetIndex hwT) <> ".log"
Gdb.setFile gdb $ firmwareBinariesDir "riscv32imc" Release </> binName
Gdb.setFile gdb $ firmwareBinariesDir "riscv32imc" buildType </> binName
Gdb.setTarget gdb tapInfo.gdbPort
Gdb.setTimeout gdb Nothing
Gdb.runCommand gdb "echo connected to target device"
Expand Down Expand Up @@ -376,7 +377,7 @@ driver testName targets = do

Gdb.withGdbs (L.length targets) $ \bootGdbs -> do
liftIO
$ zipWithConcurrently3_ (initGdb hitlDir "switch-demo1-boot") bootGdbs bootTapInfos targets
$ zipWithConcurrently3_ (initGdb hitlDir "switch-demo1-boot" Release) bootGdbs bootTapInfos targets
liftIO $ mapConcurrently_ ((assertEither =<<) . Gdb.loadBinary) bootGdbs
liftIO $ mapConcurrently_ Gdb.continue bootGdbs
liftIO
Expand Down Expand Up @@ -407,12 +408,12 @@ driver testName targets = do
<> show (L.length <$> allTapInfos)

Gdb.withGdbs (L.length targets) $ \ccGdbs -> do
liftIO $ zipWithConcurrently3_ (initGdb hitlDir "clock-control") ccGdbs ccTapInfos targets
liftIO $ zipWithConcurrently3_ (initGdb hitlDir "clock-control" Release) ccGdbs ccTapInfos targets
liftIO $ mapConcurrently_ ((assertEither =<<) . Gdb.loadBinary) ccGdbs

Gdb.withGdbs (L.length targets) $ \muGdbs -> do
liftIO
$ zipWithConcurrently3_ (initGdb hitlDir "switch-demo1-mu") muGdbs muTapInfos targets
$ zipWithConcurrently3_ (initGdb hitlDir "switch-demo1-mu" Release) muGdbs muTapInfos targets
liftIO $ mapConcurrently_ ((assertEither =<<) . Gdb.loadBinary) muGdbs

let goDumpCcSamples = dumpCcSamples hitlDir (defCcConf (natToNum @FpgaCount)) ccGdbs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ driver testName targets = do

Gdb.withGdbs (L.length targets) $ \bootGdbs -> do
liftIO
$ zipWithConcurrently3_ (initGdb hitlDir "switch-demo1-boot") bootGdbs bootTapInfos targets
$ zipWithConcurrently3_ (initGdb hitlDir "switch-demo1-boot" Release) bootGdbs bootTapInfos targets
liftIO $ mapConcurrently_ ((assertEither =<<) . Gdb.loadBinary) bootGdbs
liftIO $ mapConcurrently_ Gdb.continue bootGdbs
liftIO
Expand Down Expand Up @@ -101,17 +101,17 @@ driver testName targets = do
<> show (L.length <$> allTapInfos)

Gdb.withGdbs (L.length targets) $ \ccGdbs -> do
liftIO $ zipWithConcurrently3_ (initGdb hitlDir "clock-control") ccGdbs ccTapInfos targets
liftIO $ zipWithConcurrently3_ (initGdb hitlDir "clock-control" Release) ccGdbs ccTapInfos targets
liftIO $ mapConcurrently_ ((assertEither =<<) . Gdb.loadBinary) ccGdbs

Gdb.withGdbs (L.length targets) $ \muGdbs -> do
liftIO
$ zipWithConcurrently3_ (initGdb hitlDir "switch-demo2-mu") muGdbs muTapInfos targets
$ zipWithConcurrently3_ (initGdb hitlDir "switch-demo2-mu" Release) muGdbs muTapInfos targets
liftIO $ mapConcurrently_ ((assertEither =<<) . Gdb.loadBinary) muGdbs

Gdb.withGdbs (L.length targets) $ \gppeGdbs -> do
liftIO
$ zipWithConcurrently3_ (initGdb hitlDir "switch-demo2-gppe") gppeGdbs gppeTapInfos targets
$ zipWithConcurrently3_ (initGdb hitlDir "switch-demo2-gppe" Release) gppeGdbs gppeTapInfos targets
liftIO $ mapConcurrently_ ((assertEither =<<) . Gdb.loadBinary) gppeGdbs

brackets picocomStarts (liftIO . snd) $ \(L.map fst -> picocoms) -> do
Expand Down
Loading
Loading