potential scaffolding for new approach

This commit is contained in:
Yehowshua Immanuel 2025-04-15 14:15:49 -04:00
parent 180eeeefbe
commit f3acae0c1c

View file

@ -25,11 +25,6 @@ dummyRule =
"test rule": when True ==> do "test rule": when True ==> do
$display "test rule" $display "test rule"
data DispatchFromClient inFlightTransactions numServers
= DispatchRequest (TaggedBusRequest inFlightTransactions) (MkServerIdx numServers)
| BypassResponse (TaggedBusResponse inFlightTransactions)
deriving (Bits, Eq, FShow)
-- we need a way to make serverMap safer... -- we need a way to make serverMap safer...
mkBus :: (Addr -> Maybe (MkServerIdx numServers)) mkBus :: (Addr -> Maybe (MkServerIdx numServers))
-> Module (Bus inFlightTransactions numClients numServers) -> Module (Bus inFlightTransactions numClients numServers)
@ -48,13 +43,6 @@ mkBus serverMap = do
responseArbiterByClient :: Vector numClients (Arbiter.Arbiter_IFC (TAdd numServers 1)) responseArbiterByClient :: Vector numClients (Arbiter.Arbiter_IFC (TAdd numServers 1))
responseArbiterByClient <- replicateM (mkArbiter False) responseArbiterByClient <- replicateM (mkArbiter False)
-- After we inspect the head/oldest request in the `clientRequestQueues` and perform an
-- arbiter request to the destination arbiter, we need to inspect for grant in another
-- rule as I don't believe grant and request can be called simultaneously.
-- The following vector allows us to move
dispatchByClient :: Vector numClients (Wire (DispatchFromClient inFlightTransactions numServers))
dispatchByClient <- replicateM mkWire
-- There are `numServer` servers, each of which needs its own arbiter as -- There are `numServer` servers, each of which needs its own arbiter as
-- there are up to `numClient` clients that may wish to submit a response -- there are up to `numClient` clients that may wish to submit a response
-- to a given server. -- to a given server.
@ -87,17 +75,13 @@ mkBus serverMap = do
selectedClientRequestQueue = (select clientRequestQueues clientIdx) selectedClientRequestQueue = (select clientRequestQueues clientIdx)
in in
rules rules
(sprintf "dispatch client request %d" clientIdx): when True ==> do (sprintf "client[%d] route request" clientIdx): when True ==> do
let let
clientRequest :: TaggedBusRequest inFlightTransactions clientRequest :: TaggedBusRequest inFlightTransactions
clientRequest = selectedClientRequestQueue.first clientRequest = selectedClientRequestQueue.first
targetAddr :: Addr = busRequestToAddr |> clientRequest.busRequest targetAddr :: Addr = busRequestToAddr |> clientRequest.busRequest
targetServerIdx :: (Maybe (MkServerIdx numServers)) = serverMap targetAddr targetServerIdx :: (Maybe (MkServerIdx numServers)) = serverMap targetAddr
dispatchByClientWire :: Wire (DispatchFromClient inFlightTransactions numServers)
dispatchByClientWire = (select dispatchByClient clientIdx)
case targetServerIdx of case targetServerIdx of
Just serverIdx -> do Just serverIdx -> do
let let
@ -106,7 +90,6 @@ mkBus serverMap = do
arbiterClientSlot :: Arbiter.ArbiterClient_IFC arbiterClientSlot :: Arbiter.ArbiterClient_IFC
arbiterClientSlot = (select targetServerArbiter.clients clientIdx) arbiterClientSlot = (select targetServerArbiter.clients clientIdx)
arbiterClientSlot.request arbiterClientSlot.request
dispatchByClientWire := DispatchRequest clientRequest serverIdx
Nothing -> do Nothing -> do
let let
targetClientResponseArbiter :: Arbiter.Arbiter_IFC (TAdd numServers 1) targetClientResponseArbiter :: Arbiter.Arbiter_IFC (TAdd numServers 1)
@ -119,6 +102,7 @@ mkBus serverMap = do
-- and should instead forward the `BusError UnMapped` response -- and should instead forward the `BusError UnMapped` response
-- back to the client. Vector.last selects arbiter `n` -- back to the client. Vector.last selects arbiter `n`
clientResponseArbiterSlot = Vector.last targetClientResponseArbiter.clients clientResponseArbiterSlot = Vector.last targetClientResponseArbiter.clients
let
responseUnMapped = case clientRequest.busRequest of responseUnMapped = case clientRequest.busRequest of
BusReadRequest _ -> BusReadResponse (Left UnMapped) BusReadRequest _ -> BusReadResponse (Left UnMapped)
BusWriteRequest _ -> BusWriteResponse (Left UnMapped) BusWriteRequest _ -> BusWriteResponse (Left UnMapped)
@ -127,9 +111,11 @@ mkBus serverMap = do
tag = clientRequest.tag; tag = clientRequest.tag;
busResponse = responseUnMapped busResponse = responseUnMapped
} }
clientResponseArbiterSlot.request clientResponseArbiterSlot.request
dispatchByClientWire := BypassResponse response
(sprintf "client[%d] arbit server response" clientIdx): when True ==> do
return |> action {}
addRules |> foldr (<+>) (rules {}) clientRules addRules |> foldr (<+>) (rules {}) clientRules