Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions clash-protocols.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ library
-- To be removed; we need 'Test.Tasty.Hedgehog.Extra' to fix upstream issues
, tasty >= 1.2 && < 1.5
, tasty-hedgehog >= 1.2
, tasty-th
, strict-tuple

exposed-modules:
Protocols
Expand All @@ -146,6 +148,7 @@ library
Protocols.Axi4.WriteAddress
Protocols.Axi4.WriteData
Protocols.Axi4.WriteResponse
Protocols.Axi4.Lite.Axi4Lite

Protocols.Df
Protocols.DfLike
Expand All @@ -154,6 +157,7 @@ library
Protocols.Internal
Protocols.Plugin


-- 'testProperty' is broken upstream, it reports wrong test names
-- TODO: test / upstream ^
Test.Tasty.Hedgehog.Extra
Expand Down
19 changes: 13 additions & 6 deletions src/Protocols.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,22 @@ module Protocols

-- * Simulation
, Simulate
( SimulateType
, ExpectType
( SimulateFwdType
, SimulateBwdType
, SimulateChannels
, toSimulateType
, fromSimulateType
, driveC
, sampleC
, sigToSimFwd
, sigToSimBwd
, simToSigFwd
, simToSigBwd
, stallC
)
, Drivable
( ExpectType
, toSimulateType
, fromSimulateType
, driveC
, sampleC
)
, SimulationConfig(..)
, StallAck(..)
, simulateC
Expand Down
30 changes: 24 additions & 6 deletions src/Protocols/Axi4/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ import qualified Clash.Prelude as C
import Clash.Prelude (type (^), type (-), type (*))

-- strict-tuple
import Data.Tuple.Strict (T3, T4)
import Data.Tuple.Strict (T4)

import Control.DeepSeq

-- | Simple wrapper to achieve "named arguments" when instantiating an AXI protocol
data IdWidth = IdWidth Nat
Expand Down Expand Up @@ -70,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 Expand Up @@ -102,7 +104,7 @@ type family LockType (keepLockType :: KeepLock) where

-- | Enables or disables 'Privileged', 'Secure', and 'InstructionOrData'
type family PermissionsType (keepPermissions :: KeepPermissions) where
PermissionsType 'KeepPermissions = T3 Privileged Secure InstructionOrData
PermissionsType 'KeepPermissions = (Privileged, Secure, InstructionOrData)
PermissionsType 'NoPermissions = ()

-- | Enables or disables 'Qos'
Expand Down Expand Up @@ -245,6 +247,19 @@ data Resp
| RDecodeError
deriving (Show, C.ShowX, Generic, C.NFDataX)

-- | Status of a read or write transaction on AXI4 Lite.
data RespLite
-- | Normal access success. Indicates that a normal access has been
-- successful.
= RLOkay
-- | Slave error. Used when the access has reached the slave successfully, but
-- the slave wishes to return an error condition to the originating master.
| RLSlaveError
-- | Decode error. Generated, typically by an interconnect component, to
-- indicate that there is no slave at the transaction address.
| RLDecodeError
deriving (Show, C.ShowX, Generic, C.NFDataX)

-- | Whether a resource is accessed with exclusive access or not
data AtomicAccess
= NonExclusiveAccess
Expand All @@ -260,12 +275,14 @@ data Modifiable
data Secure
= Secure
| NonSecure
deriving (Show, Generic, C.NFDataX, NFData, C.ShowX, Eq)

-- | An AXI master might support more than one level of operating privilege,
-- and extend this concept of privilege to memory access.
data Privileged
= NotPrivileged
| Privileged
deriving (Show, Generic, C.NFDataX, NFData, C.ShowX, Eq)

-- | Whether the transaction is an instruction access or a data access. The AXI
-- protocol defines this indication as a hint. It is not accurate in all cases,
Expand All @@ -276,3 +293,4 @@ data Privileged
data InstructionOrData
= Data
| Instruction
deriving (Show, Generic, C.NFDataX, NFData, C.ShowX, Eq)
Loading