Skip to content

Commit bde9655

Browse files
committed
Remove Synthesize annotations from i2c core
To allow for polymorphism in the domain. Also added `i2cTop` which is a monomorphic i2c core with `makeTopEntity`
1 parent 9155b96 commit bde9655

File tree

4 files changed

+6
-83
lines changed

4 files changed

+6
-83
lines changed

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

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,8 @@ import Clash.Prelude hiding (read)
66

77
import Clash.Cores.I2C.BitMaster
88
import Clash.Cores.I2C.ByteMaster
9+
import Clash.Annotations.TH
910

10-
{-# ANN i2c
11-
(Synthesize
12-
{ t_name = "i2c"
13-
, t_inputs = [ PortName "clk"
14-
, PortName "arst"
15-
, PortName "rst"
16-
, PortName "ena"
17-
, PortName "clkCnt"
18-
, PortName "start"
19-
, PortName "stop"
20-
, PortName "read"
21-
, PortName "write"
22-
, PortName "ackIn"
23-
, PortName "din"
24-
, PortProduct "i2c"
25-
[ PortName "sda"
26-
, PortName "sdaEn"]
27-
]
28-
, t_output = PortProduct ""
29-
[ PortName "dout"
30-
, PortName "hostAck"
31-
, PortName "busy"
32-
, PortName "al"
33-
, PortName "ackOut"
34-
, PortProduct "i2cO"
35-
[ PortName "scl"
36-
, PortName "sclOEn"
37-
, PortName "sda"
38-
, PortName "sdaOEn"
39-
]]
40-
}) #-}
4111
-- | Core for I2C communication
4212
i2c ::
4313
forall dom .
@@ -90,3 +60,6 @@ i2c clk arst rst ena clkCnt start stop read write ackIn din i2cI = (dout,hostAck
9060
(_cmdAck,al,_dbout) = unbundle bitResp
9161
-- See: https://github.com/clash-lang/clash-compiler/pull/2511
9262
{-# CLASH_OPAQUE i2c #-}
63+
64+
i2cTop = i2c @System
65+
makeTopEntity 'i2cTop

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

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -52,34 +52,7 @@ type BitMasterI = (Bool,Bool,Unsigned 16,BitCtrlSig,I2CIn)
5252
-- 3. Contains the SCL and SDA output signals
5353
type BitMasterO = (BitRespSig,Bool,I2COut)
5454

55-
{-# ANN bitMaster
56-
(Synthesize
57-
{ t_name = "bitmaster"
58-
, t_inputs = [ PortName "clk"
59-
, PortName "arst"
60-
, PortName "gen"
61-
, PortProduct ""
62-
[ PortName "rst"
63-
, PortName "ena"
64-
, PortName "clkCnt"
65-
, PortProduct ""
66-
[ PortName "cmd"
67-
, PortName "din" ]
68-
, PortName "i2cI" ]
69-
]
70-
, t_output = PortProduct ""
71-
[ PortProduct ""
72-
[ PortName "cmdAck"
73-
, PortName "al"
74-
, PortName "dout" ]
75-
, PortName "busy"
76-
, PortProduct "i2c"
77-
[ PortName "sda"
78-
, PortName "sdaEn"
79-
, PortName "scl"
80-
, PortName "sclEn" ]
81-
]
82-
}) #-}
55+
8356
bitMaster
8457
:: KnownDomain dom
8558
=> Clock dom

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

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -48,29 +48,6 @@ type ByteMasterI = (Bool,Bool,Bool,Bool,Bool,Bool,BitVector 8,BitRespSig)
4848
-- 4 Bitmaster control signals
4949
type ByteMasterO = (Bool,Bool,BitVector 8,BitCtrlSig)
5050

51-
{-# ANN byteMaster
52-
(Synthesize
53-
{ t_name = "bytemaster"
54-
, t_inputs = [ PortName "clk"
55-
, PortName "arst"
56-
, PortName "gen"
57-
, PortProduct ""
58-
[ PortName "rst"
59-
, PortName "start"
60-
, PortName "stop"
61-
, PortName "read"
62-
, PortName "write"
63-
, PortName "ackIn"
64-
, PortName "din"
65-
, PortName "bitResp" ]
66-
]
67-
, t_output = PortProduct ""
68-
[ PortName "hostAck"
69-
, PortName "ackOut"
70-
, PortName "dout"
71-
, PortName "bitCtrl"
72-
]
73-
}) #-}
7451
-- | Byte level controller, takes care of correctly executing i2c communication
7552
-- based on the supplied control signals. It should be instantiated alongside 'bitMaster'.
7653
-- The outgoing bitCtrl' controls the 'bitMaster' whose 'bitResp' should be supplied

clash-cores/test/Test/Cores/I2C.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ system0 clk arst = bundle (registerFile,done,fault)
3131
-- See: https://github.com/clash-lang/clash-compiler/pull/2511
3232
{-# CLASH_OPAQUE system0 #-}
3333

34-
{-# ANN system Synthesize { t_name = "system", t_inputs = [], t_output = PortName "" } #-}
34+
{-# ANN system (defSyn "system") #-}
3535
system :: Signal System (Vec 16 (Unsigned 8), Bool, Bool)
3636
system = system0 systemClockGen resetGen
3737

0 commit comments

Comments
 (0)