Skip to content

Commit 9f16772

Browse files
committed
Add idWithModelDf test for Axi4 Write Address channel
1 parent 028c96c commit 9f16772

File tree

1 file changed

+67
-0
lines changed
  • clash-protocols/tests/Tests/Protocols

1 file changed

+67
-0
lines changed

clash-protocols/tests/Tests/Protocols/Axi4.hs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import Test.Tasty.TH (testGroupGenerator)
2323

2424
-- clash-protocols (me!)
2525
import Protocols
26+
import Protocols.Axi4.Common
2627
import Protocols.Axi4.ReadAddress
2728
import Protocols.Axi4.ReadData
2829
import Protocols.Axi4.Stream
@@ -31,6 +32,7 @@ import Protocols.Axi4.WriteData
3132
import Protocols.Axi4.WriteResponse
3233
import Protocols.DfConv qualified as DfConv
3334
import Protocols.Hedgehog
35+
import Protocols.Internal
3436

3537
-- tests
3638
import Tests.Protocols.Df qualified as DfTest
@@ -48,6 +50,71 @@ type ConfAR =
4850
'Axi4ReadAddressConfig 'True 'True 2 2 'True 'True 'True 'True 'True 'True
4951
type ConfR = 'Axi4ReadDataConfig 'True 2
5052

53+
prop_axi4_convert_write_address_id :: Property
54+
prop_axi4_convert_write_address_id =
55+
DfTest.idWithModelDf
56+
defExpectOptions
57+
(DfTest.genData genInfo)
58+
id
59+
( C.withClockResetEnable @C.System C.clockGen C.resetGen C.enableGen $
60+
DfConv.dfConvTestBench
61+
Proxy
62+
Proxy
63+
(repeat True)
64+
(repeat Nothing)
65+
ckt
66+
)
67+
where
68+
ckt ::
69+
(C.HiddenClockResetEnable dom) =>
70+
Circuit
71+
(Axi4WriteAddress dom ConfAW Int)
72+
(Axi4WriteAddress dom ConfAW Int)
73+
ckt = DfConv.convert Proxy Proxy
74+
75+
genInfo =
76+
(,,)
77+
<$> genWriteAddrInfo
78+
<*> genBurstLen
79+
<*> genBurst
80+
genWriteAddrInfo =
81+
Axi4WriteAddressInfo
82+
<$> Gen.enumBounded
83+
<*> Gen.enumBounded
84+
<*> (toKeepType <$> Gen.enumBounded)
85+
<*> ( toKeepType
86+
<$> ( pure Bs1
87+
C.<|> pure Bs2
88+
C.<|> pure Bs4
89+
C.<|> pure Bs8
90+
C.<|> pure Bs16
91+
C.<|> pure Bs32
92+
C.<|> pure Bs64
93+
C.<|> pure Bs128
94+
)
95+
)
96+
<*> (toKeepType <$> (pure NonExclusiveAccess C.<|> pure ExclusiveAccess))
97+
<*> ( toKeepType
98+
<$> ( (,,,)
99+
<$> (pure NonBufferable C.<|> pure Bufferable)
100+
<*> (pure NonModifiable C.<|> pure Modifiable)
101+
<*> (pure OtherNoLookupCache C.<|> pure OtherLookupCache)
102+
<*> (pure NoLookupCache C.<|> pure LookupCache)
103+
)
104+
)
105+
<*> ( toKeepType
106+
<$> ( (,,)
107+
<$> (pure Privileged C.<|> pure NotPrivileged)
108+
<*> (pure Secure C.<|> pure NonSecure)
109+
<*> (pure Instruction C.<|> pure Data)
110+
)
111+
)
112+
<*> (toKeepType <$> Gen.enumBounded)
113+
<*> DfTest.genSmallInt
114+
115+
genBurstLen = pure (toKeepType 0)
116+
genBurst = toKeepType <$> (pure BmFixed C.<|> pure BmIncr C.<|> pure BmWrap)
117+
51118
-- also test out the DfConv instance for Axi4Stream
52119

53120
prop_axi4_stream_fifo_id :: Property

0 commit comments

Comments
 (0)