Skip to content

Commit 6eaaa8e

Browse files
committed
Add show instance to Axi4Lite types
1 parent f548839 commit 6eaaa8e

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

src/Protocols/Axi4/Common.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ data SKeepStrobe (strobeType :: KeepStrobe) where
7272
SNoStrobe :: SKeepStrobe 'NoStrobe
7373

7474
-- | Extracts Nat from 'IdWidth', 'AddrWidth', and 'LengthWidth'
75-
type family Width (a :: k) :: Nat where
76-
Width ('IdWidth n) = n
77-
Width ('AddrWidth n) = n
78-
Width ('LengthWidth n) = n
75+
type family Width (a :: k) :: Nat --where
76+
type instance Width ('IdWidth n) = n
77+
type instance Width ('AddrWidth n) = n
78+
type instance Width ('LengthWidth n) = n
7979

8080
-- | Enables or disables 'BurstMode'
8181
type family BurstType (keepBurst :: KeepBurst) where

src/Protocols/Axi4/Lite/Axi4Lite.hs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ import Control.DeepSeq
1717
-- | AXI4 Lite busses are always either 32 bit or 64 bit.
1818
data BusWidth = Width32 | Width64 deriving (Show, Eq)
1919

20+
type instance Width 'Width32 = 32
21+
type instance Width 'Width64 = 64
22+
2023
-- | AXI4 Lite defines a strobe signal to signify which bytes of the input
2124
-- signal should be committed to memory. The strobe signal is encoded in
2225
-- the 'Maybe' data type. Strobing is mandatory in AXI4 Lite.
@@ -178,6 +181,13 @@ data M2S_Axi4Lite
178181
m2s_rd :: M2S_ReadData bw
179182
}
180183

184+
deriving instance
185+
( Show (ReadBusWidthType bw)
186+
, Show (WriteBusWidthType bw)
187+
, KnownNat (Width aw)
188+
, KnownNat (Width bw))
189+
=> Show (M2S_Axi4Lite aw bw)
190+
181191
-- | Product type of the types of the five different channels in the direction of slave to master.
182192
data S2M_Axi4Lite
183193
(aw :: AddrWidth)
@@ -190,6 +200,13 @@ data S2M_Axi4Lite
190200
s2m_rd :: S2M_ReadData bw
191201
}
192202

203+
deriving instance
204+
( Show (ReadBusWidthType bw)
205+
, Show (WriteBusWidthType bw)
206+
, KnownNat (Width aw)
207+
, KnownNat (Width bw))
208+
=> Show (S2M_Axi4Lite aw bw)
209+
193210
-- | Type for the full AXI4 Lite protocol.
194211
data Axi4Lite
195212
(dom :: C.Domain)

0 commit comments

Comments
 (0)