Skip to content

Commit

Permalink
Flip sign of fsToPpm output (#606)
Browse files Browse the repository at this point in the history
Fixes fallout from #602

Found as part of writing a regression test for #604
  • Loading branch information
martijnbastiaan authored Aug 21, 2024
1 parent f1bfb20 commit 2bb79f6
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions bittide-experiments/src/Bittide/Plot.hs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ import Bittide.ClockControl.Callisto (ReframingState (..))
import Bittide.ClockControl.StabilityChecker qualified as SC (StabilityIndication (..))
import Bittide.Topology

{- $setup
>>> import Clash.Prelude
>>> import Data.Proxy
-}

{- | 'Bittide.ClockControl.Callisto.ReframingState' reduced to its
stages.
-}
Expand Down Expand Up @@ -136,10 +141,17 @@ fsToMs (Femtoseconds fs) =
fs `div` 1_000_000_000_000

{- | Convert femtoseconds to parts per million, where femtoseconds represents
the relative shortening or lengthening of a clock period.
the relative shortening or lengthening of a clock period. Note that a positive
value for the input results in a negative output. This is because a /shorter/
period results in /more/ clock ticks per time span.
>>> fsToPpm (Proxy @System) 400
-40.0
>>> fsToPpm (Proxy @System) (-400)
40.0
-}
fsToPpm :: (KnownDomain dom) => Proxy dom -> Double -> Double
fsToPpm refDom fs = fs / onePpm
fsToPpm refDom fs = -1 * (fs / onePpm)
where
onePpm = case clockPeriodFs refDom of
Femtoseconds f -> fromIntegral f / 1_000_000
Expand Down

0 comments on commit 2bb79f6

Please sign in to comment.