clash-lang / clash-lang/clash-protocols
Wishbone constraint random testing
- Dominant language
- Haskell
- Stars
- 25
- Forks
- 12
- PR merge metrics
- No merged PRs in 30d
Description
This issue is meant to start a discussion, not as a way to dictate how things should be.
## Wishbone master testing
In full wishbone, a slave can respond to a master in four ways:
1. ACK, complete the request
2. ERR, indicate the request is faulty
3. RTY (optional), indicates the device is not ready and the cycle should be retried
4. STALL (optional), stop taking in new requests
This means a slave can exist in four configurations:
* Minimal: ACK and ERR
* RTY only: ACK, ERR, and RTY
* Stall only: ACK, ERR, and STALL
* Full: ACK, ERR, RTY, and STALL
```haskell
import Data.Type.Bool
import Data.Type.Equality
data SlaveConf = Minimal | RTY_Only | Stall_Only | Full
data SSlaveConf (conf :: SlaveConf) where
SMinimal :: SSlaveConf 'Minimal
SRTY_Only :: SSlaveConf 'RTY_Only
SStall_Only :: SSlaveConf 'Stall_Only
SFull :: SSlaveConf 'Full
data WishboneS2M (conf :: SlaveConf) bytes =
WishboneM2S
{ dat_o :: BitVector (8 * bytes)
, ack_o :: Bool
, err_o :: Bool
, rty_o :: If (conf == 'RTY_Only || conf == 'Full) Bool ()
, stall_o :: If (conf == 'Stall_Only || conf == 'Full) Bool ()
}
data Wait = Stall Word | DelayResp Word
genWaitCycles :: SSlaveConf conf -> Gen [Wait]
genWaitCycles = -- only generate stalls for slaves that support them
data M2SResp = ACK | ERR | RTY
m2sResp :: SlaveConf conf -> [Wait] -> Gen [M2SResp]
m2sResp =
-- generate valid responses according to the slave configuration
--
-- To figure out:
-- When a slave supports stalls, and we delay our response
-- i.e. accept transactions, do we then need to ACK them all?
-- or can some be ERR or RTY?
wishBoneSlave ::
-- | Slave configuration (fixed/given)
SSlaveConf conf ->
-- | Responses to CYC + STB high (generated)
[M2SResp] ->
-- | Data to return on ACK high (generated)
[BitVector (bytes * 8) ->
-- | Wait cycle duration when CYC + STB are high (generated)
[Wait] ->
-- | M2S
Signal dom (WishboneM2S conf bytes addrWidth) ->
-- | S2M
Signal dom (WishboneS2M conf bytes)
wishBoneSlave ... = ...
-- ACK, RTY, and ERR are `undefined` when there's no active cycle
--
-- When the slave supports stalls, and we're told to delay the response
-- Collect sufficient responses and data
```
To then generate a constraint random slave I imagine:
```haskell
createSlave slaveConf genData = do
waitCycles <- genWaitCycles slaveConf
-- Ensure we generate enough responses for the number of wait cycles
-- in case stalls are supported
responses <- m2sResp slaveConf waitCyles
-- Generate the data for all ACKs
respData <- genData responses
return (wishBoneSlave slaveConf responses respData waitCycles)
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the proposed genWaitCycles, m2sResp, wishBoneSlave, and createSlave signatures in the issue. Resolve how ACK, ERR, RTY, STALL, delays, and returned data should be generated for each SlaveConf, then define completion criteria for constraint-random Wishbone slave testing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- embedded-iot, testing
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100