Type system progress on bus design

This commit is contained in:
Yehowshua Immanuel 2025-04-08 13:05:34 -04:00
parent 2d5cf48c54
commit da761f6e4e
2 changed files with 61 additions and 18 deletions

View file

@ -3,5 +3,18 @@ package Bus(a) where
import Types import Types
import BusTypes import BusTypes
interface (TestType :: * -> *) t = {}
-- doSomething :: t -> Action
mkTestType :: (Bits t n, Arith t, Eq t) => Module (TestType t)
mkTestType = do
return $ interface TestType {}
mkTestTop :: Module Empty
mkTestTop = do
testType :: TestType (UInt 5)
testType <- mkTestType
return $ interface Empty { }
a :: UInt 5 a :: UInt 5
a = 3 a = 3

View file

@ -1,12 +1,12 @@
package BusTypes( package BusTypes(
BusVal(..), BusClient(..), BusServer(..),
BusError(..), BusRequest(..), BusResponse(..),
TransactionSize(..), ReadRequest(..), ReadResponse(..), WriteRequest(..), WriteResponse(..),
ReadRequest(..), BusVal(..), BusError(..), TransactionSize(..)
WriteRequest(..)
) where ) where
import Types import Types
import Vector
data BusError data BusError
= UnMapped = UnMapped
@ -48,21 +48,51 @@ data BusResponse
| BusWriteResponse WriteResponse | BusWriteResponse WriteResponse
deriving (Bits, Eq, FShow) deriving (Bits, Eq, FShow)
interface BusMaster = -- # BusClient.dequeueRequest
-- The Bus arbiter will call the Bus Master's request method -- * The Bus arbiter will call the Bus Client's request method if it is
-- if and only if it's the Bus Master's turn to make a request, and the Bus Master -- the Bus Client's turn to make a request, or if another client forfits
-- has a request to make. -- its turn.
-- It is up to the BusMaster to guard it's request method such that calling -- * The BusClient must guard its request method such that calling its
-- it's request method is only valid when the BusMaster has a request to make. -- request method is only valid when the BusClient has a request to make.
-- This has implications about for the implementor of BusMaster, namely, that it -- * This has implications about for the implementor of BusClient,
-- should hold its request until it's request method gets called. -- namely, that it should hold its request until it's request method
request :: BusRequest -- gets called. The arbiter tags the request so that the client can
-- From the masters's perspective, the response should not be called by the -- later correctly correlate the response.
-- arbiter until the master is ready to accept the response. In other words, -- * Although the tag is technically passed in as an argument from the
-- response should be guarded by the client. -- arbiter to the client's request method, given that methods are
response :: BusResponse -> Action -- atomic in Bluespec, this is effectively equivalent to tagging the
-- transaction from the client's perspective. Thus, the client must
-- take care to appropiately store the tag.
-- # BusClient.enqueueResponse
-- * From the client's perspective, the response should not be called
-- by the arbiter until the client is ready to accept the response.
-- In other words, the response method should be guarded by the client.
interface (BusClient :: * -> *) transactionTagType =
dequeueRequest :: transactionTagType -> ActionValue BusRequest
enqueueResponse :: (BusResponse, transactionTagType) -> Action
-- # BusServer.dequeueResponse
-- * If the arbiter is able to successfully call `dequeueResponse`, then
-- the BusServer's internal logici must update such that it understand
-- the response has been handed off.
-- # BusServer.peekClientTagDestination
-- * The arbiter looks at (peekClientTagDestination :: clientTagTye) to
-- determine whether or not it is currently safe whether to dequeue the
-- response as well as where to route the response should it dequeue the
-- response.
-- * `peekClientTagDestination` should be guarded on whether or not there is
-- a valid response available.
interface (BusServer :: * -> * -> *) transactionTagType clientTagType =
enqueueRequest :: (transactionTagType, BusRequest) -> Action
dequeueResponse :: ActionValue (clientTagType, BusResponse, transactionTagType)
peekClientTagDestination :: clientTagTye
interface (Bus :: # -> # -> * -> * -> *) numClients numServers transactionTagType clientTagType =
clients :: Vector numClients (BusClient transactionTagType)
servers :: Vector numServers (BusServer transactionTagType clientTagType)
type Token = UInt 5 type Token = UInt 5
type Numeric = 5
a :: UInt 5 a :: UInt 5
a = 3 a = 3