Skip to content

Commit 2efc4a0

Browse files
committed
Make i2c core's domain polymorph
1 parent 7d5af18 commit 2efc4a0

File tree

3 files changed

+32
-28
lines changed

3 files changed

+32
-28
lines changed

clash-cores/src/Clash/Cores/I2C.hs

+20-18
Original file line numberDiff line numberDiff line change
@@ -40,30 +40,32 @@ import Clash.Cores.I2C.ByteMaster
4040
}) #-}
4141
-- | Core for I2C communication
4242
i2c ::
43+
forall dom .
44+
KnownDomain dom =>
4345
-- | Input Clock
44-
Clock System ->
46+
Clock dom ->
4547
-- | Low level reset
46-
Reset System ->
48+
Reset dom ->
4749
-- | Statemachine reset
48-
Signal System Bool ->
50+
Signal dom Bool ->
4951
-- | BitMaster enable
50-
Signal System Bool ->
52+
Signal dom Bool ->
5153
-- | Clock divider
52-
Signal System (Unsigned 16) ->
54+
Signal dom (Unsigned 16) ->
5355
-- | Start signal
54-
Signal System Bool ->
56+
Signal dom Bool ->
5557
-- | Stop signal
56-
Signal System Bool ->
58+
Signal dom Bool ->
5759
-- | Read signal
58-
Signal System Bool ->
60+
Signal dom Bool ->
5961
-- | Write signal
60-
Signal System Bool ->
62+
Signal dom Bool ->
6163
-- | Ack signal
62-
Signal System Bool ->
64+
Signal dom Bool ->
6365
-- | Input data
64-
Signal System (BitVector 8) ->
66+
Signal dom (BitVector 8) ->
6567
-- | I2C input signals (SCL, SDA)
66-
Signal System (Bit, Bit) ->
68+
Signal dom (Bit, Bit) ->
6769
-- |
6870
-- 1. Received data
6971
-- 2. Command acknowledgement
@@ -75,12 +77,12 @@ i2c ::
7577
-- 6.2 SCL Output enable`
7678
-- 6.3 SDA
7779
-- 6.4 SDA Output enable
78-
( Signal System (BitVector 8)
79-
, Signal System Bool
80-
, Signal System Bool
81-
, Signal System Bool
82-
, Signal System Bool
83-
, Signal System (Bit, Bool, Bit, Bool))
80+
( Signal dom (BitVector 8)
81+
, Signal dom Bool
82+
, Signal dom Bool
83+
, Signal dom Bool
84+
, Signal dom Bool
85+
, Signal dom (Bit, Bool, Bit, Bool))
8486
i2c clk arst rst ena clkCnt start stop read write ackIn din i2cI = (dout,hostAck,busy,al,ackOut,i2cO)
8587
where
8688
(hostAck,ackOut,dout,bitCtrl) = byteMaster clk arst enableGen (rst,start,stop,read,write,ackIn,din,bitResp)

clash-cores/src/Clash/Cores/I2C/BitMaster.hs

+6-5
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,12 @@ type BitMasterO = (BitRespSig,Bool,I2COut)
8181
]
8282
}) #-}
8383
bitMaster
84-
:: Clock System
85-
-> Reset System
86-
-> Enable System
87-
-> Unbundled System BitMasterI
88-
-> Unbundled System BitMasterO
84+
:: KnownDomain dom
85+
=> Clock dom
86+
-> Reset dom
87+
-> Enable dom
88+
-> Unbundled dom BitMasterI
89+
-> Unbundled dom BitMasterO
8990
bitMaster = exposeClockResetEnable (mealyB bitMasterT bitMasterInit)
9091
-- See: https://github.com/clash-lang/clash-compiler/pull/2511
9192
{-# CLASH_OPAQUE bitMaster #-}

clash-cores/src/Clash/Cores/I2C/ByteMaster.hs

+6-5
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,12 @@ type ByteMasterO = (Bool,Bool,BitVector 8,BitCtrlSig)
7676
-- The outgoing bitCtrl' controls the 'bitMaster' whose 'bitResp' should be supplied
7777
-- as last input.
7878
byteMaster
79-
:: Clock System
80-
-> Reset System
81-
-> Enable System
82-
-> Unbundled System ByteMasterI
83-
-> Unbundled System ByteMasterO
79+
:: KnownDomain dom
80+
=> Clock dom
81+
-> Reset dom
82+
-> Enable dom
83+
-> Unbundled dom ByteMasterI
84+
-> Unbundled dom ByteMasterO
8485
byteMaster = exposeClockResetEnable (mealyB byteMasterT byteMasterInit)
8586
-- See: https://github.com/clash-lang/clash-compiler/pull/2511
8687
{-# CLASH_OPAQUE byteMaster #-}

0 commit comments

Comments
 (0)