things still typecheck
This commit is contained in:
parent
989c4e9616
commit
b4c7537a85
34
bs/Bus.bs
34
bs/Bus.bs
|
@ -1,25 +1,14 @@
|
||||||
package Bus(a) where
|
package Bus(mkBus) where
|
||||||
|
|
||||||
import Types
|
import Types
|
||||||
import BusTypes
|
import BusTypes
|
||||||
import TagEngine
|
import TagEngine
|
||||||
import Vector
|
import Vector
|
||||||
|
import Util
|
||||||
|
import Arbiter
|
||||||
|
|
||||||
interface (TestType :: * -> *) t = {}
|
clientRequest :: Arbiter.ArbiterClient_IFC -> Action
|
||||||
-- doSomething :: t -> Action
|
clientRequest ifc = ifc.request
|
||||||
|
|
||||||
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 { }
|
|
||||||
|
|
||||||
mkBus :: Vector numClients (BusClient inFlightTransactions)
|
mkBus :: Vector numClients (BusClient inFlightTransactions)
|
||||||
-> Vector numServers (BusServer inFlightTransactions numClients)
|
-> Vector numServers (BusServer inFlightTransactions numClients)
|
||||||
|
@ -28,8 +17,13 @@ mkBus clientVec serverVec = do
|
||||||
tagEngineByClient :: Vector numClients (TagEngine inFlightTransactions)
|
tagEngineByClient :: Vector numClients (TagEngine inFlightTransactions)
|
||||||
tagEngineByClient <- replicateM mkTagEngine
|
tagEngineByClient <- replicateM mkTagEngine
|
||||||
|
|
||||||
|
arbiterByServer :: Vector numServers (Arbiter_IFC numClients)
|
||||||
|
arbiterByServer <- replicateM (mkArbiter False)
|
||||||
|
|
||||||
|
addRules |>
|
||||||
|
rules
|
||||||
|
"placeholder rule": when True ==> do
|
||||||
|
let selectedArbiter = (select arbiterByServer 0)
|
||||||
|
mapM_ clientRequest selectedArbiter.clients
|
||||||
|
|
||||||
return $ interface Empty { }
|
return $ interface Empty { }
|
||||||
|
|
||||||
|
|
||||||
a :: UInt 5
|
|
||||||
a = 3
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
package BusTypes(
|
package BusTypes(
|
||||||
ClientTagType,
|
MkClientTagType,
|
||||||
BusClient(..), BusServer(..),
|
BusClient(..), BusServer(..),
|
||||||
BusRequest(..), BusResponse(..),
|
BusRequest(..), BusResponse(..),
|
||||||
ReadRequest(..), ReadResponse(..), WriteRequest(..), WriteResponse(..),
|
ReadRequest(..), ReadResponse(..), WriteRequest(..), WriteResponse(..),
|
||||||
|
@ -10,7 +10,7 @@ import Types
|
||||||
import Vector
|
import Vector
|
||||||
import TagEngine
|
import TagEngine
|
||||||
|
|
||||||
type ClientTagType a = (UInt (TLog a))
|
type MkClientTagType a = (UInt (TLog a))
|
||||||
|
|
||||||
data BusError
|
data BusError
|
||||||
= UnMapped
|
= UnMapped
|
||||||
|
@ -72,33 +72,27 @@ data BusResponse
|
||||||
-- by the arbiter until the client is ready to accept the response.
|
-- by the arbiter until the client is ready to accept the response.
|
||||||
-- In other words, the response method should be guarded by the client.
|
-- In other words, the response method should be guarded by the client.
|
||||||
interface (BusClient :: # -> *) inFlightTransactions =
|
interface (BusClient :: # -> *) inFlightTransactions =
|
||||||
dequeueRequest :: TagType inFlightTransactions
|
dequeueRequest :: MkTagType inFlightTransactions
|
||||||
-> ActionValue BusRequest
|
-> ActionValue BusRequest
|
||||||
enqueueResponse :: (BusResponse, TagType inFlightTransactions)
|
enqueueResponse :: (BusResponse, MkTagType inFlightTransactions)
|
||||||
-> Action
|
-> Action
|
||||||
|
|
||||||
-- # BusServer.dequeueResponse
|
-- # BusServer.dequeueResponse
|
||||||
-- * If the arbiter is able to successfully call `dequeueResponse`, then
|
-- * If the arbiter is able to successfully call `dequeueResponse`, then
|
||||||
-- the BusServer's internal logici must update such that it understand
|
-- the BusServer's internal logic must update such that it understands
|
||||||
-- the response has been handed off.
|
-- the response has been handed off.
|
||||||
-- # BusServer.peekClientTagDestination
|
-- # BusServer.peekClientTagDestination
|
||||||
-- * The arbiter looks at (peekClientTagDestination :: clientTagType) to
|
-- * The arbiter looks at (peekClientTagDestination :: MkClientTagType) to
|
||||||
-- determine whether or not it is currently safe whether to dequeue the
|
-- 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 as well as where to route the response should it dequeue the
|
||||||
-- response.
|
-- response.
|
||||||
-- * `peekClientTagDestination` should be guarded on whether or not there is
|
-- * `peekClientTagDestination` should be guarded on whether or not there is
|
||||||
-- a valid response available.
|
-- a valid response available.
|
||||||
interface (BusServer :: # -> # -> *) inFlightTransactions numClients =
|
interface (BusServer :: # -> # -> *) inFlightTransactions numClients =
|
||||||
enqueueRequest :: (TagType inFlightTransactions, BusRequest)
|
enqueueRequest :: (MkTagType inFlightTransactions, BusRequest)
|
||||||
-> Action
|
-> Action
|
||||||
dequeueResponse :: ActionValue (
|
dequeueResponse :: ActionValue (
|
||||||
ClientTagType numClients,
|
MkClientTagType numClients,
|
||||||
BusResponse, transactionTagType
|
BusResponse, transactionTagType
|
||||||
)
|
)
|
||||||
peekClientTagDestination :: clientTagType
|
peekClientTagDestination :: MkClientTagType numClients
|
||||||
|
|
||||||
type Token = UInt 5
|
|
||||||
type Numeric = 5
|
|
||||||
|
|
||||||
a :: UInt 5
|
|
||||||
a = 3
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
package TagEngine(
|
package TagEngine(
|
||||||
TagType,
|
MkTagType,
|
||||||
TagEngine(..),
|
TagEngine(..),
|
||||||
Util.BasicResult(..),
|
Util.BasicResult(..),
|
||||||
mkTagEngine) where
|
mkTagEngine) where
|
||||||
|
@ -10,11 +10,11 @@ import FIFO
|
||||||
import FIFOF
|
import FIFOF
|
||||||
import SpecialFIFOs
|
import SpecialFIFOs
|
||||||
|
|
||||||
type TagType a = (UInt (TLog a))
|
type MkTagType numTags = (UInt (TLog numTags))
|
||||||
|
|
||||||
interface (TagEngine :: # -> *) numTags =
|
interface (TagEngine :: # -> *) numTags =
|
||||||
requestTag :: ActionValue (TagType numTags)
|
requestTag :: ActionValue (MkTagType numTags)
|
||||||
retireTag :: (TagType numTags) -> Action
|
retireTag :: (MkTagType numTags) -> Action
|
||||||
|
|
||||||
-- The tag engine returns a tag that is unique for the duration of
|
-- The tag engine returns a tag that is unique for the duration of
|
||||||
-- the lifetime of the tag. Useful when you need to tag transactions
|
-- the lifetime of the tag. Useful when you need to tag transactions
|
||||||
|
@ -45,7 +45,7 @@ mkTagEngine = do
|
||||||
debugOnce <- mkReg True
|
debugOnce <- mkReg True
|
||||||
|
|
||||||
-- Rules
|
-- Rules
|
||||||
addRules $
|
addRules |>
|
||||||
rules
|
rules
|
||||||
"debug_initial_state": when debugOnce ==> do
|
"debug_initial_state": when debugOnce ==> do
|
||||||
$display "tagUsage: " (fshow (readVReg tagUsage))
|
$display "tagUsage: " (fshow (readVReg tagUsage))
|
||||||
|
@ -78,9 +78,9 @@ mkTagEngine = do
|
||||||
(Nothing, Nothing) -> action {}
|
(Nothing, Nothing) -> action {}
|
||||||
|
|
||||||
-- Interface
|
-- Interface
|
||||||
return $
|
return |>
|
||||||
interface TagEngine
|
interface TagEngine
|
||||||
requestTag :: ActionValue (TagType numTags)
|
requestTag :: ActionValue (MkTagType numTags)
|
||||||
requestTag = do
|
requestTag = do
|
||||||
case initialTagDistributor of
|
case initialTagDistributor of
|
||||||
Just 0 -> do
|
Just 0 -> do
|
||||||
|
@ -101,7 +101,7 @@ mkTagEngine = do
|
||||||
-- so it is advisable that the caller of `retireTag` only attempt to retire valid tags.
|
-- so it is advisable that the caller of `retireTag` only attempt to retire valid tags.
|
||||||
-- Internally, the tagEngine will keep a correct and consistent state since TagEngine
|
-- Internally, the tagEngine will keep a correct and consistent state since TagEngine
|
||||||
-- validates tags before attempting to retire them.
|
-- validates tags before attempting to retire them.
|
||||||
retireTag :: (TagType numTags) -> Action
|
retireTag :: (MkTagType numTags) -> Action
|
||||||
retireTag tag =
|
retireTag tag =
|
||||||
do
|
do
|
||||||
let
|
let
|
||||||
|
|
Loading…
Reference in a new issue