From 39da209dbeeb4822c1aefcdbbc56846f915e9dab Mon Sep 17 00:00:00 2001 From: Martijn Bastiaan Date: Wed, 14 Aug 2024 10:55:28 +0200 Subject: [PATCH 1/3] Run `bittide-experiments:doctests` on CI --- .github/workflows/ci.yml | 4 ++++ bittide-experiments/src/Bittide/Topology.hs | 1 + 2 files changed, 5 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0e2d9d56c..87383bff3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -352,6 +352,10 @@ jobs: run: | cabal run bittide-experiments:unittests + - name: Run doctests + run: | + cabal run -- bittide-experiments:doctests + bittide-tests: name: Bittide tests runs-on: [self-hosted, compute] diff --git a/bittide-experiments/src/Bittide/Topology.hs b/bittide-experiments/src/Bittide/Topology.hs index 48306601f..2acb18063 100644 --- a/bittide-experiments/src/Bittide/Topology.hs +++ b/bittide-experiments/src/Bittide/Topology.hs @@ -45,6 +45,7 @@ module Bittide.Topology ( toDot, randomTopology, topTypeCLIParser, + pairwise, ) where import Prelude From 80b4e383f3da5123ad38727e542aaa8993481422 Mon Sep 17 00:00:00 2001 From: Martijn Bastiaan Date: Wed, 14 Aug 2024 11:43:04 +0200 Subject: [PATCH 2/3] Separate thousands with ',' in reports --- bittide-experiments/bittide-experiments.cabal | 1 + .../src/Bittide/Report/ClockControl.hs | 26 ++++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/bittide-experiments/bittide-experiments.cabal b/bittide-experiments/bittide-experiments.cabal index 4d72ae689..c22e2dcf5 100644 --- a/bittide-experiments/bittide-experiments.cabal +++ b/bittide-experiments/bittide-experiments.cabal @@ -92,6 +92,7 @@ library containers, data-default, directory, + extra, filepath, happy-dot, http-conduit, diff --git a/bittide-experiments/src/Bittide/Report/ClockControl.hs b/bittide-experiments/src/Bittide/Report/ClockControl.hs index 6281c9f12..fca6d5bda 100644 --- a/bittide-experiments/src/Bittide/Report/ClockControl.hs +++ b/bittide-experiments/src/Bittide/Report/ClockControl.hs @@ -8,10 +8,12 @@ module Bittide.Report.ClockControl ( generateReport, checkDependencies, checkIntermediateResults, + formatThousands, ) where import Data.Bool (bool) import Data.List (intercalate) +import Data.List.Extra (chunksOf) import System.Directory (doesDirectoryExist, doesFileExist, findExecutable) import System.Environment (lookupEnv) import System.FilePath (takeFileName, ()) @@ -30,6 +32,18 @@ import System.Process (callProcess, readProcess) import Bittide.Plot import Bittide.Simulate.Config +{- | Format a number with underscores every three digits. + +>>> formatThousands 123456789 +"123,456,789" +>>> formatThousands 100000000 +"100,000,000" +>>> formatThousands 1000000 +"1,000,000" +-} +formatThousands :: (Num a, Show a) => a -> String +formatThousands = reverse . intercalate "," . chunksOf 3 . reverse . show + generateReport :: -- | Document description header String -> @@ -229,17 +243,17 @@ toLatex datetime runref header clocksPdf ebsPdf topTikz ids SimConf{..} = , "\\begin{large}" , " \\begin{tabular}{rl}" , " duration \\textit{(clock cycles)}:" - , " & " <> show duration <> " \\\\" + , " & " <> formatThousands duration <> " \\\\" , " stability detector - framesize:" - , " & " <> show stabilityFrameSize <> " \\\\" + , " & " <> formatThousands stabilityFrameSize <> " \\\\" , " stability detector - margin:" - , " & \\textpm\\," <> show stabilityMargin <> " elements \\\\" + , " & \\textpm\\," <> formatThousands stabilityMargin <> " elements \\\\" , " when stable, automatically stop after \\textit{(clock cycles)}:" - , " & " <> maybe "not used" show stopAfterStable <> " \\\\" + , " & " <> maybe "not used" formatThousands stopAfterStable <> " \\\\" , " clock offsets \\textit{(fs)}:" - , " & " <> intercalate ", " (show <$> clockOffsets) <> " \\\\" + , " & " <> intercalate "; " (show <$> clockOffsets) <> " \\\\" , " startup delays \\textit{(clock cycles)}:" - , " & " <> intercalate ", " (show <$> startupDelays) <> " \\\\" + , " & " <> intercalate "; " (formatThousands <$> startupDelays) <> " \\\\" , " reframing:" , " & " <> "\\textit{" From 5287e3c63149729caa951fe273c51666a8cbcebf Mon Sep 17 00:00:00 2001 From: Martijn Bastiaan Date: Wed, 14 Aug 2024 11:44:25 +0200 Subject: [PATCH 3/3] "end of simulation" => "end of run" to prevent confusion Fixes #600 --- .github/simulation/report-template.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/simulation/report-template.tex b/.github/simulation/report-template.tex index 71bd1b756..bcda99ee7 100644 --- a/.github/simulation/report-template.tex +++ b/.github/simulation/report-template.tex @@ -66,7 +66,7 @@ & \printclockoffsets{data['clockOffsets']} \\ startup offsets (\# clock cycles): & \printstartupoffsets{data['startupOffsets']} \\ - stable at the end of simulation: + stable at the end of run: & \printbool{data['stable']} \\ \end{tabular} \end{large}