Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove KnowDomain #2589

Draft
wants to merge 27 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
02015b0
Cleanup clash-lib.cabal
leonschoorl Sep 25, 2023
930f1ce
Improve blackbox error message
leonschoorl Sep 1, 2023
280dec1
Refactor Test.Tasty.Clash
leonschoorl Oct 11, 2023
b2d85eb
Split out YAML primitive field custom sorting code
leonschoorl Sep 19, 2023
c5f2368
Fix prettyElem bugs
leonschoorl Oct 17, 2023
8e7a228
Make Element polymorphic in the type used to represent arguments
leonschoorl Sep 7, 2023
25f21f2
Add prim-yaml-to-inlineyaml tool
leonschoorl Sep 7, 2023
c6f7316
Allow blackbox templates to get domain info from Clock,Reset,Enable,etc
leonschoorl Oct 2, 2023
c08b624
Put a KnownDomain constraint inside of Clock and Reset
leonschoorl Oct 2, 2023
55b117e
Add class HasKnownDomain
leonschoorl Oct 11, 2023
d9b940e
Add ZKnownDomain dummy contraint
leonschoorl Oct 2, 2023
bfe4968
Remove KnownDomain from clash-lib/prims
leonschoorl Oct 5, 2023
d52aef3
Clash.*.ClockGen PLLs
leonschoorl Oct 9, 2023
b585e18
Remove KnownDomain from Clash.(Explicit.)Verification
leonschoorl Oct 9, 2023
0df8aa5
Remove KnownDomain from Clash.Explicit.SimIO
leonschoorl Oct 11, 2023
1d3e7f7
Remove now unused KnownDomain constraints
leonschoorl Oct 6, 2023
8d6c648
Remove KnownDomain from Tutorial
leonschoorl Oct 11, 2023
1902d62
Simplify Clash.Primitives.DSL.unsafeToActive[High,Low]
leonschoorl Oct 9, 2023
e98bbe9
clash-cores
leonschoorl Oct 10, 2023
133d6bb
Remove various other KnownDomains
leonschoorl Oct 11, 2023
7e352ab
Remove KnownDomain from HiddenClock and HiddenReset
leonschoorl Oct 18, 2023
ed8ade6
Remove unused KnownDomains from tests/
leonschoorl Oct 11, 2023
5454fee
Add ExtractClockDom and ExtractResetDom
leonschoorl Oct 12, 2023
f08bdc0
Move YAML prims with dummy ZKnownDomain constraints into inline yaml
leonschoorl Oct 17, 2023
c896f21
Remove dummy constraint ZKnownDomain
leonschoorl Oct 17, 2023
e28b372
Apply CLASH_MULTIPLE_HIDDEN to clash-prelude:doctests
leonschoorl Oct 19, 2023
8dae71e
Fix readNew doctest example
leonschoorl Oct 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ write-ghc-environment-files: always
-- index state, to go along with the cabal.project.freeze file. update the index
-- state by running `cabal update` twice and looking at the index state it
-- displays to you (as the second update will be a no-op)
index-state: 2023-09-12T05:36:44Z
index-state: 2023-10-18T12:11:41Z

-- For some reason the `clash-testsuite` executable fails to run without
-- this, as it cannot find the related library...
Expand Down Expand Up @@ -81,4 +81,3 @@ package recursion-schemes

package regex-tdfa
optimization: 2

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import Prelude
bbTF :: TemplateFunction
bbTF = TemplateFunction used valid bbTemplate
where
used = [3..6]
used = [2..5]
valid = const True

bbTemplate
Expand All @@ -39,7 +39,6 @@ bbTemplate
bbTemplate bbCtx
| [ _HasCallStack
, _HasBiSignalDefault
, _KnownDomain
, (intrinsicName, String, _)
, (packagePin, packagePinTy, _)
, (dOut, Bit, _)
Expand Down
2 changes: 0 additions & 2 deletions clash-cores/src/Clash/Cores/LatticeSemi/ECP5/IO.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ bidirectionalBuffer
:: forall ds dom
. ( HasCallStack
, HasBiSignalDefault ds
, KnownDomain dom
)
=> Enable dom
-- ^ output enable
Expand All @@ -56,7 +55,6 @@ bbECP5
:: forall ds dom
. ( HasCallStack
, HasBiSignalDefault ds
, KnownDomain dom
)
=> String
-> BiSignalIn ds dom 1
Expand Down
4 changes: 1 addition & 3 deletions clash-cores/src/Clash/Cores/Xilinx/BlockRam.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ tdpbram ::
forall nAddrs domA domB nBytes a .
( HasCallStack
, KnownNat nAddrs
, KnownDomain domA
, KnownDomain domB
, KnownNat nBytes
, BitSize a ~ (8 * nBytes)
, NFDataX a
Expand Down Expand Up @@ -61,7 +59,7 @@ tdpbram ::
( Signal domA a
, Signal domB a
)
tdpbram clkA enA addrA byteEnaA datA clkB enB addrB byteEnaB datB =
tdpbram clkA@ExtractClockDom enA addrA byteEnaA datA clkB@ExtractClockDom enB addrB byteEnaB datB =
-- [Note: eta port names for tdpbram]
--
-- By naming all the arguments and setting the -fno-do-lambda-eta-expansion GHC
Expand Down
6 changes: 0 additions & 6 deletions clash-cores/src/Clash/Cores/Xilinx/BlockRam/BlackBoxes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ used =
:< _risingEdgeConstraintA
:< _risingEdgeConstraintB
:< knownNatNAddrs
:< _knownDomainA
:< _knownDomainB
:< _nfDataX
:< _bitpack
:< nBytes
Expand All @@ -64,8 +62,6 @@ tdpbramBBTF bbCtx
, _risingEdgeConstraintA
, _risingEdgeConstraintB
, _knownNatNAddrs
, _knownDomainA
, _knownDomainB
, _nfDataX
, _bitpack
, (fmap fromIntegral . DSL.tExprToInteger -> Just nBytes)
Expand Down Expand Up @@ -155,8 +151,6 @@ tdpbramTclBBTF bbCtx
, _risingEdgeConstraintA
, _risingEdgeConstraintB
, DSL.tExprToInteger -> Just depth
, _knownDomainA
, _knownDomainB
, _nfDataX
, _bitpack
, DSL.tExprToInteger -> Just width
Expand Down
2 changes: 0 additions & 2 deletions clash-cores/src/Clash/Cores/Xilinx/BlockRam/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,6 @@ tdpbram# ::
, DomainActiveEdge domA ~ 'Rising
, DomainActiveEdge domB ~ 'Rising
, KnownNat nAddrs
, KnownDomain domA
, KnownDomain domB
, NFDataX a
, BitPack a
, KnownNat nBytes
Expand Down
7 changes: 2 additions & 5 deletions clash-cores/src/Clash/Cores/Xilinx/DcFifo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,7 @@ defConfig = DcConfig
-- disabled, the relevant signals will return 'XException'.
dcFifo ::
forall depth a write read .
( KnownDomain write
, KnownDomain read

, NFDataX a
( NFDataX a

, KnownNat depth
-- Number of elements should be between [2**4, 2**17] ~ [16, 131072].
Expand All @@ -156,7 +153,7 @@ dcFifo ::
-- | Read enable @rd_en@
Signal read Bool ->
FifoOut read write depth a
dcFifo DcConfig{..} wClk wRst rClk rRst writeData rEnable =
dcFifo DcConfig{..} wClk@ExtractClockDom wRst rClk@ExtractClockDom rRst writeData rEnable =
case (resetKind @write, resetKind @read) of
(SSynchronous, SSynchronous) ->
let
Expand Down
95 changes: 42 additions & 53 deletions clash-cores/src/Clash/Cores/Xilinx/DcFifo/Internal/BlackBoxes.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ import GHC.Stack (HasCallStack)
import Clash.Backend (Backend)
import Clash.Core.TermLiteral (termToDataError)
import Clash.Netlist.BlackBox.Types (BlackBoxFunction, emptyBlackBoxMeta)
import Clash.Netlist.BlackBox.Util (getDomainConf)
import Clash.Netlist.Types (TemplateFunction(..), BlackBox(BBFunction), BlackBoxContext)
import Clash.Netlist.Util (orNothing, stripVoid)
import Clash.Signal.Internal (ResetKind(..))
import Clash.Netlist.Util (orNothing)
import Clash.Signal.Internal (ResetKind(..),vResetKind)
import Clash.Promoted.Nat (snatToNum)

import qualified Clash.Primitives.DSL as DSL
Expand All @@ -51,8 +52,7 @@ import Clash.Cores.Xilinx.Internal
-- * 'dcFifoTF': instantiates IP generated in @dcFifoTclTF@
dcFifoBBF :: HasCallStack => BlackBoxFunction
dcFifoBBF _isD _primName args _resTys
| [ _knownDomainWrite, _knownDomainRead
, _nfDataX, _knownNatDepth
| [ _nfDataX, _knownNatDepth
, _constraint1, _constraint2, _hasCallStack
, either error id . termToDataError -> dcConfig
, _wClk, _wRst, _rClk, _rRst, _wData
Expand Down Expand Up @@ -93,22 +93,20 @@ dcFifoBBF _ _ args _ = error ("dcFifoBBF, bad args: " <> show args)
dcFifoTF :: HasCallStack => DcConfig n -> TemplateFunction
dcFifoTF config =
TemplateFunction
-- ( KnownDomain write -- 0
-- , KnownDomain read -- 1
-- , NFDataX a -- 2
-- , KnownNat depth -- 3
-- , 4 <= depth -- 4
-- , depth <= 17 -- 5
-- , HasCallStack -- 6
-- ( NFDataX a -- 0
-- , KnownNat depth -- 1
-- , 4 <= depth -- 2
-- , depth <= 17 -- 3
-- , HasCallStack -- 4
-- ) =>
-- DcConfig (SNat depth) -> -- 7 Note: argument passed to this function
-- Clock write -> -- 8
-- Reset write -> -- 9
-- Clock read -> -- 10
-- Reset read -> -- 11
-- Signal write (Maybe a) -> -- 12
-- Signal read Bool -> -- 13
[0, 1, 7, 8, 9, 10, 11, 12, 13]
-- DcConfig (SNat depth) -> -- 5 Note: argument passed to this function
-- Clock write -> -- 6
-- Reset write -> -- 7
-- Clock read -> -- 8
-- Reset read -> -- 9
-- Signal write (Maybe a) -> -- 10
-- Signal read Bool -> -- 11
[5, 6, 7, 8, 9, 10, 11]
(const True)
(dcFifoBBTF config)
where
Expand All @@ -119,8 +117,7 @@ dcFifoBBTF ::
BlackBoxContext ->
State s Doc
dcFifoBBTF DcConfig{..} bbCtx
| [ knownDomainWrite, knownDomainRead
, _nfDataX, _knownNatDepth
| [ _nfDataX, _knownNatDepth
, _constraint1, _constraint2, _hasCallStack
, _dcConfig
, wClk, wRst, rClk, rRst, wDataM
Expand Down Expand Up @@ -174,29 +171,23 @@ dcFifoBBTF DcConfig{..} bbCtx
rdEmptyBool <- DSL.boolFromBit "rd_empty_bool" rdEmpty
rEnableBit <- DSL.boolToBit "rd_enable" rEnable

wDomConf <- DSL.liftToBlockState $ getDomainConf (DSL.ety wClk)
wRstHigh <-
let domty = DSL.ety knownDomainWrite
in case stripVoid domty of
N.KnownDomain _ _ _ Synchronous _ _ ->
DSL.unsafeToActiveHigh "wr_rst_high" domty wRst
N.KnownDomain _ _ _ Asynchronous _ _ ->
case vResetKind wDomConf of
Synchronous ->
DSL.unsafeToActiveHigh "wr_rst_high" wRst
Asynchronous ->
error $
show 'dcFifoTF <> ": dcFifo only supports synchronous resets"
_ ->
error $ show 'dcFifoTF <> ": Bug: Not a KnownDomain " <>
"constraint, mismatch between function and its blackbox"

rDomConf <- DSL.liftToBlockState $ getDomainConf (DSL.ety rClk)
rRstHigh <-
let domty = DSL.ety knownDomainRead
in case stripVoid domty of
N.KnownDomain _ _ _ Synchronous _ _ ->
DSL.unsafeToActiveHigh "rd_rst_high" domty rRst
N.KnownDomain _ _ _ Asynchronous _ _ ->
case vResetKind rDomConf of
Synchronous ->
DSL.unsafeToActiveHigh "rd_rst_high" rRst
Asynchronous ->
error $
show 'dcFifoTF <> ": dcFifo only supports synchronous resets"
_ ->
error $ show 'dcFifoTF <> ": Bug: Not a KnownDomain " <>
"constraint, mismatch between function and its blackbox"

(rdDataCountUnsigned, rdDataCountPort) <-
if dcReadDataCount then do
Expand Down Expand Up @@ -274,22 +265,20 @@ dcFifoBBTF _ bbCtx = error ("dcFifoBBTF, bad bbCtx: " <> show bbCtx)
dcFifoTclTF :: HasCallStack => DcConfig n -> TemplateFunction
dcFifoTclTF conf =
TemplateFunction
-- ( KnownDomain write -- 0
-- , KnownDomain read -- 1
-- , NFDataX a -- 2
-- , KnownNat depth -- 3
-- , 4 <= depth -- 4
-- , depth <= 17 -- 5
-- , HasCallStack -- 6
-- ( NFDataX a -- 0
-- , KnownNat depth -- 1
-- , 4 <= depth -- 2
-- , depth <= 17 -- 3
-- , HasCallStack -- 4
-- ) =>
-- DcConfig (SNat depth) -> -- 7 Note: argument passed to this function
-- Clock write -> -- 8
-- Reset write -> -- 9
-- Clock read -> -- 10
-- Reset read -> -- 11
-- Signal write (Maybe a) -> -- 12
-- Signal read Bool -> -- 13
[7, 12]
-- DcConfig (SNat depth) -> -- 5 Note: argument passed to this function
-- Clock write -> -- 6
-- Reset write -> -- 7
-- Clock read -> -- 8
-- Reset read -> -- 9
-- Signal write (Maybe a) -> -- 10
-- Signal read Bool -> -- 11
[5, 10]
(const True)
(dcFifoTclBBTF conf)

Expand All @@ -300,7 +289,7 @@ dcFifoTclBBTF ::
State s Doc
dcFifoTclBBTF DcConfig{..} bbCtx
| [dcFifoName] <- N.bbQsysIncName bbCtx
, [ _knownDomainWrite, _knownDomainRead, _nfDataX
, [ _nfDataX
, _knownNatDepth, _constraint1, _constraint2, _hasCallStack
, _dcConfig, _wClk, _wRst, _rClk, _rRst, wDataM, _rEnable
] <- map fst (DSL.tInputs bbCtx)
Expand Down
28 changes: 10 additions & 18 deletions clash-cores/src/Clash/Cores/Xilinx/Floating/Annotations.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ vhdlBinaryPrim
-> Primitive
vhdlBinaryPrim primName tclTFName funcName =
let
_knownDomain
:< _knownNat
_knownNat
:< _hasCallStack
:< config
:< clk
Expand Down Expand Up @@ -110,8 +109,7 @@ veriBinaryPrim
-> Primitive
veriBinaryPrim primName tclTFName funcName =
let
_knownDomain
:< _knownNat
_knownNat
:< _hasCallStack
:< config
:< clk
Expand Down Expand Up @@ -148,8 +146,7 @@ vhdlFromUPrim
-> Primitive
vhdlFromUPrim primName funcName =
let tfName = 'fromUTclTF
_knownDomain
:< _knownNat
_knownNat
:< _hasCallStack
:< clk
:< en
Expand Down Expand Up @@ -186,7 +183,7 @@ vhdlFromUPrim primName funcName =
~GENSYM[#{funcName}][#{compSym}] : ~INCLUDENAME[0]
port map (
aclk => ~ARG[#{clk}],
~IF~ISACTIVEENABLE[#{en}]~THEN aclken => ~SYM[#{clk}],
~IF~ISACTIVEENABLE[#{en}]~THEN aclken => ~SYM[#{clkEnStdSym}],
~ELSE~FI s_axis_a_tvalid => '1',
s_axis_a_tdata => ~SYM[#{inpSlvSym}],
m_axis_result_tvalid => open,
Expand All @@ -208,8 +205,7 @@ veriFromUPrim
veriFromUPrim primName funcName =
let
tfName = 'fromUTclTF
_knownDomain
:< _knownNat
_knownNat
:< _hasCallStack
:< clk
:< en
Expand Down Expand Up @@ -245,8 +241,7 @@ vhdlFromSPrim
vhdlFromSPrim primName funcName =
let
tfName = 'fromSTclTF
_knownDomain
:< _knownNat
_knownNat
:< _hasCallStack
:< clk
:< en
Expand Down Expand Up @@ -283,7 +278,7 @@ vhdlFromSPrim primName funcName =
~GENSYM[#{funcName}][#{compSym}] : ~INCLUDENAME[0]
port map (
aclk => ~ARG[#{clk}],
~IF~ISACTIVEENABLE[#{en}]~THEN aclken => ~SYM[#{clk}],
~IF~ISACTIVEENABLE[#{en}]~THEN aclken => ~SYM[#{clkEnStdSym}],
~ELSE~FI s_axis_a_tvalid => '1',
s_axis_a_tdata => ~SYM[#{inpSlvSym}],
m_axis_result_tvalid => open,
Expand All @@ -305,8 +300,7 @@ veriFromSPrim
veriFromSPrim primName funcName =
let
tfName = 'fromSTclTF
_knownDomain
:< _knownNat
_knownNat
:< _hasCallStack
:< clk
:< en
Expand Down Expand Up @@ -344,8 +338,7 @@ vhdlComparePrim
-> Primitive
vhdlComparePrim primName tclTFName funcName =
let
_knownDomain
:< _knownNat
_knownNat
:< _hasCallStack
:< clock
:< enable
Expand Down Expand Up @@ -410,8 +403,7 @@ veriComparePrim
-> Primitive
veriComparePrim primName tclTFName funcName =
let
_knownDomain
:< _knownNat
_knownNat
:< _hasCallStack
:< clock
:< enable
Expand Down
Loading
Loading