Skip to content

Commit 0caac67

Browse files
Merge pull request #591 from bittide/lucas/bump-clash-2
Bump Clash (once again)
2 parents 1631db0 + 79fd659 commit 0caac67

File tree

22 files changed

+100
-80
lines changed

22 files changed

+100
-80
lines changed

.github/scripts/cache.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
CLEAR_AFTER=f"{CLEAR_AFTER_DAYS}d00h00m00s"
5353
TOUCH_AFTER=datetime.timedelta(days=1)
5454

55-
GLOBAL_CACHE_BUST = 2
55+
GLOBAL_CACHE_BUST = 3
5656

5757
CARGO_CACHE_BUST = 2
5858
CARGO_KEY_PREFIX = f"cargo-g{GLOBAL_CACHE_BUST}-l{CARGO_CACHE_BUST}-"

.github/workflows/ci.yml

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
run:
4646
shell: git-nix-shell {0} --option connect-timeout 360 --pure --keep "GITHUB_SHA" --keep "S3_PASSWORD"
4747
container:
48-
image: ghcr.io/clash-lang/nixos-bittide-hardware:2024-07-30
48+
image: ghcr.io/clash-lang/nixos-bittide-hardware:2024-08-06
4949
options: --memory=11g
5050
steps:
5151
- name: Checkout
@@ -80,7 +80,7 @@ jobs:
8080
shell: git-nix-shell {0} --option connect-timeout 360
8181

8282
container:
83-
image: ghcr.io/clash-lang/nixos-bittide-hardware:2024-07-30
83+
image: ghcr.io/clash-lang/nixos-bittide-hardware:2024-08-06
8484
options: --memory=11g
8585

8686
steps:
@@ -114,6 +114,10 @@ jobs:
114114
.github/scripts/cabal-gild.sh check
115115
git diff --exit-code
116116
117+
- name: Check that we don't introduce accidental infinite loops in type checkers
118+
run: |
119+
! grep --include=*.hs -E -r '\-fconstraint-solver-iterations *= *0'
120+
117121
build:
118122
name: Build dependencies
119123
runs-on: [self-hosted, compute]
@@ -122,7 +126,7 @@ jobs:
122126
shell: git-nix-shell {0} --option connect-timeout 360 --pure --keep "GITHUB_SHA" --keep "S3_PASSWORD"
123127

124128
container:
125-
image: ghcr.io/clash-lang/nixos-bittide-hardware:2024-07-30
129+
image: ghcr.io/clash-lang/nixos-bittide-hardware:2024-08-06
126130
options: --memory=11g
127131

128132
steps:
@@ -162,7 +166,7 @@ jobs:
162166
shell: git-nix-shell {0} --option connect-timeout 360 --pure --keep "GITHUB_OUTPUT"
163167

164168
container:
165-
image: ghcr.io/clash-lang/nixos-bittide-hardware:2024-07-30
169+
image: ghcr.io/clash-lang/nixos-bittide-hardware:2024-08-06
166170
options: --memory=11g
167171

168172
steps:
@@ -202,7 +206,7 @@ jobs:
202206
fail-fast: false
203207

204208
container:
205-
image: ghcr.io/clash-lang/nixos-bittide-hardware:2024-07-30
209+
image: ghcr.io/clash-lang/nixos-bittide-hardware:2024-08-06
206210
options: --memory=11g
207211

208212
steps:
@@ -252,7 +256,7 @@ jobs:
252256
needs: [build, lint, cc-sim-topologies-matrix, cc-sim-topologies, bittide-instances-hardware-in-the-loop]
253257

254258
container:
255-
image: ghcr.io/clash-lang/nixos-bittide-hardware:2024-07-30
259+
image: ghcr.io/clash-lang/nixos-bittide-hardware:2024-08-06
256260
options: --memory=11g
257261

258262
steps:
@@ -325,7 +329,7 @@ jobs:
325329
needs: [build, lint]
326330

327331
container:
328-
image: ghcr.io/clash-lang/nixos-bittide-hardware:2024-07-30
332+
image: ghcr.io/clash-lang/nixos-bittide-hardware:2024-08-06
329333
options: --memory=11g
330334

331335
steps:
@@ -352,7 +356,7 @@ jobs:
352356
needs: [build, lint]
353357

354358
container:
355-
image: ghcr.io/clash-lang/nixos-bittide-hardware:2024-07-30
359+
image: ghcr.io/clash-lang/nixos-bittide-hardware:2024-08-06
356360
options: --memory=11g
357361

358362
steps:
@@ -393,7 +397,7 @@ jobs:
393397
run:
394398
shell: git-nix-shell {0} --option connect-timeout 360 --pure --keep "GITHUB_SHA" --keep "S3_PASSWORD"
395399
container:
396-
image: ghcr.io/clash-lang/nixos-bittide-hardware:2024-07-30
400+
image: ghcr.io/clash-lang/nixos-bittide-hardware:2024-08-06
397401
options: --memory=11g
398402
needs: [build]
399403

@@ -418,7 +422,7 @@ jobs:
418422
run:
419423
shell: git-nix-shell {0} --option connect-timeout 360 --pure --keep "GITHUB_SHA" --keep "S3_PASSWORD"
420424
container:
421-
image: ghcr.io/clash-lang/nixos-bittide-hardware:2024-07-30
425+
image: ghcr.io/clash-lang/nixos-bittide-hardware:2024-08-06
422426
options: --memory=11g
423427
needs: [build]
424428

@@ -446,7 +450,7 @@ jobs:
446450
run:
447451
shell: git-nix-shell {0} --option connect-timeout 360 --pure --keep "GITHUB_SHA" --keep "S3_PASSWORD"
448452
container:
449-
image: ghcr.io/clash-lang/nixos-bittide-hardware:2024-07-30
453+
image: ghcr.io/clash-lang/nixos-bittide-hardware:2024-08-06
450454
options: --memory=11g
451455
needs: [build]
452456

@@ -472,7 +476,7 @@ jobs:
472476
run:
473477
shell: git-nix-shell {0} --option connect-timeout 360 --pure --keep "GITHUB_SHA" --keep "S3_PASSWORD"
474478
container:
475-
image: ghcr.io/clash-lang/nixos-bittide-hardware:2024-07-30
479+
image: ghcr.io/clash-lang/nixos-bittide-hardware:2024-08-06
476480
options: --memory=11g
477481
needs: [build]
478482

@@ -505,7 +509,7 @@ jobs:
505509
needs: [build, lint]
506510

507511
container:
508-
image: ghcr.io/clash-lang/nixos-bittide-hardware:2024-07-30
512+
image: ghcr.io/clash-lang/nixos-bittide-hardware:2024-08-06
509513
options: --memory=11g
510514

511515
steps:
@@ -532,7 +536,7 @@ jobs:
532536
needs: [build, lint]
533537

534538
container:
535-
image: ghcr.io/clash-lang/nixos-bittide-hardware:2024-07-30
539+
image: ghcr.io/clash-lang/nixos-bittide-hardware:2024-08-06
536540
options: --memory=11g
537541

538542
steps:
@@ -558,7 +562,7 @@ jobs:
558562
shell: git-nix-shell {0} --option connect-timeout 360 --pure --keep "GITHUB_OUTPUT"
559563

560564
container:
561-
image: ghcr.io/clash-lang/nixos-bittide-hardware:2024-07-30
565+
image: ghcr.io/clash-lang/nixos-bittide-hardware:2024-08-06
562566
options: --memory=11g
563567

564568
steps:
@@ -591,7 +595,7 @@ jobs:
591595
shell: git-nix-shell {0} --option connect-timeout 360 --pure --keep "GITHUB_OUTPUT"
592596

593597
container:
594-
image: ghcr.io/clash-lang/nixos-bittide-hardware:2024-07-30
598+
image: ghcr.io/clash-lang/nixos-bittide-hardware:2024-08-06
595599
options: --memory=11g
596600

597601
steps:
@@ -634,7 +638,7 @@ jobs:
634638
fail-fast: false
635639

636640
container:
637-
image: ghcr.io/clash-lang/nixos-bittide-hardware:2024-07-30
641+
image: ghcr.io/clash-lang/nixos-bittide-hardware:2024-08-06
638642
volumes:
639643
- /opt/tools:/opt/tools
640644
options: --init --mac-address="6c:5a:b0:6c:13:0b" --memory=11g
@@ -714,7 +718,7 @@ jobs:
714718
fail-fast: false
715719

716720
container:
717-
image: ghcr.io/clash-lang/nixos-bittide-hardware:2024-07-30
721+
image: ghcr.io/clash-lang/nixos-bittide-hardware:2024-08-06
718722
volumes:
719723
- /opt/tools:/opt/tools
720724
- /dev:/dev

bittide-instances/src/Bittide/Instances/Domains.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
module Bittide.Instances.Domains where
88

9-
import Clash.Explicit.Prelude
9+
import Clash.Explicit.Prelude hiding (PeriodToCycles)
1010

1111
import Bittide.ClockControl
1212
import Bittide.Arithmetic.Time

bittide-instances/src/Bittide/Instances/Hitl/FincFdec.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import Clash.Explicit.Prelude
1515
import Clash.Prelude (withClockResetEnable)
1616
import Clash.Xilinx.ClockGen (clockWizardDifferential)
1717

18-
import Bittide.Arithmetic.Time
1918
import Bittide.Counter (domainDiffCounter)
2019
import Bittide.ClockControl (SpeedChange(NoChange, SlowDown, SpeedUp), speedChangeToFincFdec)
2120
import Bittide.ClockControl.Si539xSpi (si539xSpi, ConfigState(Finished))

bittide-instances/src/Bittide/Instances/Hitl/FullMeshHwCc.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ module Bittide.Instances.Hitl.FullMeshHwCc
3333
) where
3434

3535
import Clash.Prelude (withClockResetEnable)
36-
import Clash.Explicit.Prelude
36+
import Clash.Explicit.Prelude hiding (PeriodToCycles)
3737
import qualified Clash.Explicit.Prelude as E
3838

3939
import Data.Maybe (fromMaybe)

bittide-instances/src/Bittide/Instances/Hitl/FullMeshSwCc.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
-- SPDX-FileCopyrightText: 2023-2024 Google LLC
22
--
33
-- SPDX-License-Identifier: Apache-2.0
4+
{-# LANGUAGE FlexibleContexts #-}
5+
{-# LANGUAGE NamedFieldPuns #-}
46
{-# LANGUAGE NumericUnderscores #-}
7+
{-# LANGUAGE OverloadedRecordDot #-}
58
{-# LANGUAGE OverloadedStrings #-}
69
{-# LANGUAGE RecordWildCards #-}
7-
{-# LANGUAGE OverloadedRecordDot #-}
8-
{-# LANGUAGE NamedFieldPuns #-}
910

1011
{-# OPTIONS_GHC -fplugin=Protocols.Plugin #-}
1112
{-# OPTIONS_GHC -fconstraint-solver-iterations=20 #-}
@@ -33,7 +34,7 @@ module Bittide.Instances.Hitl.FullMeshSwCc
3334

3435
import qualified Prelude as P
3536
import Clash.Prelude (withClockResetEnable)
36-
import Clash.Explicit.Prelude
37+
import Clash.Explicit.Prelude hiding (PeriodToCycles)
3738
import qualified Clash.Explicit.Prelude as E
3839

3940
import Data.Maybe (fromMaybe)

bittide-instances/src/Bittide/Instances/Hitl/HwCcTopologies.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ module Bittide.Instances.Hitl.HwCcTopologies
3434
) where
3535

3636
import Clash.Prelude (withClockResetEnable)
37-
import Clash.Explicit.Prelude
37+
import Clash.Explicit.Prelude hiding (PeriodToCycles)
3838
import qualified Clash.Explicit.Prelude as E
3939

4040
import Data.Bifunctor (bimap)

bittide-instances/src/Bittide/Instances/Hitl/IlaPlot.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ module Bittide.Instances.Hitl.IlaPlot
4747

4848
import GHC.Stack (HasCallStack)
4949

50-
import Clash.Explicit.Prelude
50+
import Clash.Explicit.Prelude hiding (PeriodToCycles)
5151
import Clash.Explicit.Signal.Extra
5252
import Clash.Sized.Extra (concatUnsigneds)
5353

54-
import Bittide.Arithmetic.Time (Seconds, Milliseconds, PeriodToCycles, trueFor)
54+
import Bittide.Arithmetic.Time (PeriodToCycles, trueFor)
5555
import Bittide.ClockControl (SpeedChange(..), RelDataCount, ClockControlConfig)
5656
import Bittide.ClockControl.Callisto
5757
(CallistoResult(..), ReframingState(..), callistoClockControl)

bittide-instances/src/Bittide/Instances/Hitl/SyncInSyncOut.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
--
6363
module Bittide.Instances.Hitl.SyncInSyncOut where
6464

65-
import Clash.Explicit.Prelude
65+
import Clash.Explicit.Prelude hiding (PeriodToCycles)
6666

6767
import Bittide.Arithmetic.Time
6868
import Bittide.Hitl (HitlTests, allFpgas, hitlVioBool, noConfigTest)

bittide-instances/src/Bittide/Instances/Pnr/Si539xSpi.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import Clash.Prelude
1111

1212
import Clash.Annotations.TH (makeTopEntity)
1313

14-
import Bittide.Arithmetic.Time
1514
import Bittide.ClockControl
1615
import Bittide.ClockControl.Callisto
1716
import Bittide.ClockControl.Si5395J

bittide/src/Bittide/Arithmetic/Time.hs

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,51 @@
22
--
33
-- SPDX-License-Identifier: Apache-2.0
44
{-# LANGUAGE FlexibleInstances,MultiParamTypeClasses,TemplateHaskell #-}
5+
{-# LANGUAGE NumericUnderscores #-}
56
{-# OPTIONS_GHC -Wno-orphans #-}
67
module Bittide.Arithmetic.Time where
78

89
import GHC.Stack (HasCallStack)
9-
import Clash.Explicit.Prelude hiding (natVal)
10+
import Clash.Explicit.Prelude hiding (natVal, PeriodToCycles)
1011

1112
import Clash.Class.Counter (countSucc, Counter)
1213
import Clash.Signal.Internal (Femtoseconds (Femtoseconds), mapFemtoseconds)
13-
import Data.Data (Proxy(Proxy))
14+
import Data.Data (Proxy(..))
1415
import Data.Int (Int64)
1516
import Data.Kind (Type)
1617

1718
import GHC.TypeNats (natVal)
1819
import GHC.TypeLits.KnownNat (KnownNat1 (..),SNatKn(..), nameToSymbol)
1920

20-
-- | Gets time in 'Picoseconds' from time in 'Seconds'.
21-
type Seconds (s :: Nat) = Milliseconds (1000 * s)
22-
-- | Gets time in 'Picoseconds' from time in 'Milliseconds'.
23-
type Milliseconds (ms :: Nat) = Microseconds (1000 * ms)
24-
-- | Gets time in 'Picoseconds' from time in 'Microseconds'.
25-
type Microseconds (us :: Nat) = Nanoseconds (1000 * us)
26-
-- | Gets time in 'Picoseconds' from time in 'Nanoseconds'.
27-
type Nanoseconds (ns :: Nat) = Picoseconds (1000 * ns)
28-
-- | Gets time in 'Picoseconds' from time in 'Picoseconds', essentially 'id'.
29-
type Picoseconds (ps :: Nat) = ps
30-
31-
-- Make ghc-typelits-knownnat look through the Picoseconds type alias
21+
-- | XXX: We currently retain this in favor of @clash-prelude@s 'PeriodToCycles'
22+
-- until @1 <= DomainPeriod dom@ is trivially true. Related issue:
23+
-- https://github.com/clash-lang/ghc-typelits-extra/issues/56
24+
--
25+
--Number of clock cycles required at the clock frequency of @dom@ before a minimum @period@ has passed.
26+
-- Is always at least one.
27+
type PeriodToCycles dom period = Max 1 (DivRU period (Max 1 (DomainPeriod dom)))
28+
29+
-- Make ghc-typelits-knownnat look through time related type aliases.
30+
-- https://github.com/clash-lang/ghc-typelits-knownnat/issues/53
3231
instance (KnownNat ps) => KnownNat1 $(nameToSymbol ''Picoseconds) ps where
3332
natSing1 = SNatKn (natVal (Proxy @ps))
3433
{-# NOINLINE natSing1 #-}
3534

36-
-- | Number of clock cycles required at the clock frequency of @dom@ before a minimum @period@ has passed.
37-
-- Is always at least one.
38-
type PeriodToCycles dom period = Max 1 (DivRU period (Max 1 (DomainPeriod dom)))
35+
instance (KnownNat ps) => KnownNat1 $(nameToSymbol ''Nanoseconds) ps where
36+
natSing1 = SNatKn (natVal (Proxy @(1_000 * ps)))
37+
{-# NOINLINE natSing1 #-}
38+
39+
instance (KnownNat ps) => KnownNat1 $(nameToSymbol ''Microseconds) ps where
40+
natSing1 = SNatKn (natVal (Proxy @(1_000_000 * ps)))
41+
{-# NOINLINE natSing1 #-}
3942

40-
-- | The domain's clock frequency in Hertz, calculated based on the period stored in ps.
41-
-- This might lead to rounding errors.
42-
type DomainFrequency dom = Div (Seconds 1) (DomainPeriod dom)
43+
instance (KnownNat ps) => KnownNat1 $(nameToSymbol ''Milliseconds) ps where
44+
natSing1 = SNatKn (natVal (Proxy @(1_000_000_000 * ps)))
45+
{-# NOINLINE natSing1 #-}
46+
47+
instance (KnownNat ps) => KnownNat1 $(nameToSymbol ''Seconds) ps where
48+
natSing1 = SNatKn (natVal (Proxy @(1_000_000_000_000 * ps)))
49+
{-# NOINLINE natSing1 #-}
4350

4451
-- | 'Index' with its 'maxBound' corresponding to the number of cycles needed to
4552
-- wait for /n/ milliseconds.

bittide/src/Bittide/ClockControl.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ module Bittide.ClockControl
2222
)
2323
where
2424

25-
import Clash.Explicit.Prelude
25+
import Clash.Explicit.Prelude hiding (PeriodToCycles)
2626
import Clash.Signal.Internal (Femtoseconds(..))
2727
import Data.Aeson (ToJSON(toJSON))
2828
import Data.Proxy (Proxy(..))
@@ -32,7 +32,7 @@ import Foreign.Storable (Storable(..))
3232
import GHC.Stack (HasCallStack)
3333

3434
import Bittide.Arithmetic.Ppm
35-
import Bittide.Arithmetic.Time (PeriodToCycles, Nanoseconds, Microseconds, microseconds)
35+
import Bittide.Arithmetic.Time (PeriodToCycles, microseconds)
3636
import Bittide.ClockControl.Foreign.Sizes
3737

3838
import Data.Csv

bittide/src/Bittide/ClockControl/Si539xSpi.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
module Bittide.ClockControl.Si539xSpi where
1313

14-
import Clash.Prelude
14+
import Clash.Prelude hiding (PeriodToCycles)
1515
import Clash.Cores.SPI
1616

1717
import Data.Maybe

bittide/src/Bittide/Transceiver.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ module Bittide.Transceiver where
8989

9090
import Clash.Explicit.Prelude
9191

92-
import Bittide.Arithmetic.Time (Milliseconds, trueForSteps)
92+
import Bittide.Arithmetic.Time (trueForSteps)
9393
import Bittide.ElasticBuffer (sticky)
9494
import Clash.Cores.Xilinx.GTH (GthCore)
9595
import Clash.Cores.Xilinx.Ila (IlaConfig(advancedTriggers, depth, stages), ilaConfig, ila, Depth(D1024))

bittide/src/Bittide/Wishbone.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ module Bittide.Wishbone where
1111

1212
import Clash.Prelude
1313

14-
import Bittide.Arithmetic.Time(DomainFrequency)
1514
import Bittide.DoubleBufferedRam
1615
import Bittide.SharedTypes
1716

@@ -467,7 +466,7 @@ timeWb = Circuit $ \(wbM2S, _) -> (mealy goMealy (0,0) wbM2S, ())
467466
where
468467
goMealy (frozen, count :: Unsigned 64) wbM2S = ((nextFrozen, succ count), wbS2M)
469468
where
470-
freq = natToNum @(DomainFrequency dom) :: Unsigned 64
469+
freq = natToNum @(DomainToHz dom) :: Unsigned 64
471470
nextFrozen = if isJust (head writes) then count else frozen
472471
RegisterBank (splitAtI -> (frozenMsbs, frozenLsbs)) = getRegsBe @8 frozen
473472
RegisterBank (splitAtI -> (freqMsbs, freqLsbs)) = getRegsBe @8 freq

0 commit comments

Comments
 (0)