Skip to content

Commit

Permalink
Add show instance to Axi4Lite types
Browse files Browse the repository at this point in the history
  • Loading branch information
PietPtr committed Mar 7, 2022
1 parent f548839 commit 6eaaa8e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Protocols/Axi4/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ data SKeepStrobe (strobeType :: KeepStrobe) where
SNoStrobe :: SKeepStrobe 'NoStrobe

-- | Extracts Nat from 'IdWidth', 'AddrWidth', and 'LengthWidth'
type family Width (a :: k) :: Nat where
Width ('IdWidth n) = n
Width ('AddrWidth n) = n
Width ('LengthWidth n) = n
type family Width (a :: k) :: Nat --where
type instance Width ('IdWidth n) = n
type instance Width ('AddrWidth n) = n
type instance Width ('LengthWidth n) = n

-- | Enables or disables 'BurstMode'
type family BurstType (keepBurst :: KeepBurst) where
Expand Down
17 changes: 17 additions & 0 deletions src/Protocols/Axi4/Lite/Axi4Lite.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ import Control.DeepSeq
-- | AXI4 Lite busses are always either 32 bit or 64 bit.
data BusWidth = Width32 | Width64 deriving (Show, Eq)

type instance Width 'Width32 = 32
type instance Width 'Width64 = 64

-- | AXI4 Lite defines a strobe signal to signify which bytes of the input
-- signal should be committed to memory. The strobe signal is encoded in
-- the 'Maybe' data type. Strobing is mandatory in AXI4 Lite.
Expand Down Expand Up @@ -178,6 +181,13 @@ data M2S_Axi4Lite
m2s_rd :: M2S_ReadData bw
}

deriving instance
( Show (ReadBusWidthType bw)
, Show (WriteBusWidthType bw)
, KnownNat (Width aw)
, KnownNat (Width bw))
=> Show (M2S_Axi4Lite aw bw)

-- | Product type of the types of the five different channels in the direction of slave to master.
data S2M_Axi4Lite
(aw :: AddrWidth)
Expand All @@ -190,6 +200,13 @@ data S2M_Axi4Lite
s2m_rd :: S2M_ReadData bw
}

deriving instance
( Show (ReadBusWidthType bw)
, Show (WriteBusWidthType bw)
, KnownNat (Width aw)
, KnownNat (Width bw))
=> Show (S2M_Axi4Lite aw bw)

-- | Type for the full AXI4 Lite protocol.
data Axi4Lite
(dom :: C.Domain)
Expand Down

0 comments on commit 6eaaa8e

Please sign in to comment.