first attempt at server rule, also implemented consumeRequest of the server part of the Bus interface
This commit is contained in:
parent
a58c836981
commit
c28425f10c
51
bs/Bus.bs
51
bs/Bus.bs
|
@ -63,7 +63,12 @@ mkBus serverMap = do
|
|||
|
||||
-- The following two vectors of FIFOs make it easier to push/pull data to/from internal
|
||||
-- server methods:
|
||||
consumeRequestQueues :: Vector numServers (FIFOF (TaggedBusResponse inFlightTransactions))
|
||||
consumeRequestQueues :: Vector numServers (
|
||||
FIFOF (
|
||||
MkClientTagType numClients,
|
||||
TaggedBusRequest inFlightTransactions
|
||||
)
|
||||
)
|
||||
consumeRequestQueues <- replicateM mkBypassFIFOF
|
||||
|
||||
submitResponseQueues :: Vector numServers (FIFOF (TaggedBusResponse inFlightTransactions))
|
||||
|
@ -160,6 +165,33 @@ mkBus serverMap = do
|
|||
selectedClientResponseQueue.enq response
|
||||
selectedSubmitResponseQueue.deq
|
||||
|
||||
let serverRules :: Vector numServers (Rules)
|
||||
serverRules = genWith $ \serverIdx ->
|
||||
let
|
||||
selectedServerArbiter :: Arbiter.Arbiter_IFC numClients
|
||||
selectedServerArbiter = (select requestArbiterByServer serverIdx)
|
||||
|
||||
selectedConsumeRequestQueue :: FIFOF (
|
||||
MkClientTagType numClients,
|
||||
TaggedBusRequest inFlightTransactions
|
||||
)
|
||||
selectedConsumeRequestQueue = (select consumeRequestQueues serverIdx)
|
||||
in
|
||||
rules
|
||||
(sprintf "server[%d] handle request" serverIdx): when True ==> do
|
||||
let
|
||||
grantedClientIdx :: MkClientTagType numClients
|
||||
grantedClientIdx = unpack selectedServerArbiter.grant_id
|
||||
|
||||
selectedClientRequestQueue :: FIFOF (TaggedBusRequest inFlightTransactions)
|
||||
selectedClientRequestQueue = (select clientRequestQueues grantedClientIdx)
|
||||
|
||||
clientRequest :: TaggedBusRequest inFlightTransactions
|
||||
clientRequest = selectedClientRequestQueue.first
|
||||
|
||||
selectedConsumeRequestQueue.enq (grantedClientIdx, clientRequest)
|
||||
selectedClientRequestQueue.deq
|
||||
|
||||
addRules |> foldr (<+>) (rules {}) clientRules
|
||||
|
||||
-- Client interface vector
|
||||
|
@ -196,12 +228,21 @@ mkBus serverMap = do
|
|||
-- Server interface vector
|
||||
let servers :: Vector numServers (BusServer inFlightTransactions numClients)
|
||||
servers = genWith $ \serverIdx ->
|
||||
let
|
||||
selectedConsumeRequestQueue :: FIFOF (
|
||||
MkClientTagType numClients,
|
||||
TaggedBusRequest inFlightTransactions
|
||||
)
|
||||
selectedConsumeRequestQueue = (select consumeRequestQueues serverIdx)
|
||||
in
|
||||
interface BusServer
|
||||
consumeRequest :: ActionValue (TaggedBusRequest inFlightTransactions)
|
||||
consumeRequest :: ActionValue (
|
||||
MkClientTagType numClients,
|
||||
TaggedBusRequest inFlightTransactions
|
||||
)
|
||||
consumeRequest = do
|
||||
dummyVar := (not dummyVar)
|
||||
let dummyBusRequest = BusReadRequest (ReadRequest 0 SizeByte)
|
||||
return (TaggedBusRequest {tag = 0; busRequest = dummyBusRequest})
|
||||
selectedConsumeRequestQueue.deq
|
||||
return selectedConsumeRequestQueue.first
|
||||
|
||||
submitResponse :: ( MkClientTagType numClients,
|
||||
TaggedBusResponse inFlightTransactions
|
||||
|
|
|
@ -102,7 +102,10 @@ interface (BusClient :: # -> *) inFlightTransactions =
|
|||
-- received from `consumeRequest`, ensuring the response is correctly
|
||||
-- associated with the original request.
|
||||
interface (BusServer :: # -> # -> *) inFlightTransactions numClients =
|
||||
consumeRequest :: ActionValue (TaggedBusRequest inFlightTransactions)
|
||||
consumeRequest :: ActionValue (
|
||||
MkClientTagType numClients,
|
||||
TaggedBusRequest inFlightTransactions
|
||||
)
|
||||
submitResponse :: ( MkClientTagType numClients,
|
||||
TaggedBusResponse inFlightTransactions
|
||||
) -> Action
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<mxfile host="Electron" agent="Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/26.0.16 Chrome/132.0.6834.196 Electron/34.2.0 Safari/537.36" version="26.0.16">
|
||||
<diagram name="simplified" id="y4uZzcGV7WDpy27g0Dv6">
|
||||
<mxGraphModel dx="675" dy="346" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
|
||||
<mxGraphModel dx="673" dy="413" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
|
||||
<root>
|
||||
<mxCell id="0" />
|
||||
<mxCell id="1" parent="0" />
|
||||
|
@ -91,7 +91,7 @@
|
|||
<mxCell id="DDLsznhKMAXYVWb-8vYK-280" value="server1<div>router</div>" style="rounded=1;whiteSpace=wrap;html=1;labelBackgroundColor=default;fontSize=11;" parent="1" vertex="1">
|
||||
<mxGeometry x="200" y="340" width="80" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="DDLsznhKMAXYVWb-8vYK-281" value="request /<div>grant</div>" style="endArrow=classic;html=1;rounded=0;labelBackgroundColor=#F8CECC;fontSize=10;" parent="1" edge="1">
|
||||
<mxCell id="DDLsznhKMAXYVWb-8vYK-281" value="request /<div>grant</div>" style="endArrow=classic;html=1;rounded=0;labelBackgroundColor=#F8CECC;fontSize=10;startArrow=classic;startFill=1;" parent="1" edge="1">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="214.89" y="340" as="sourcePoint" />
|
||||
<mxPoint x="214.89" y="300" as="targetPoint" />
|
||||
|
@ -117,7 +117,7 @@
|
|||
<mxCell id="DDLsznhKMAXYVWb-8vYK-285" value="server1<div>arbiter</div>" style="rounded=1;whiteSpace=wrap;html=1;labelBackgroundColor=default;fontSize=11;" parent="1" vertex="1">
|
||||
<mxGeometry x="80" y="550" width="80" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="DDLsznhKMAXYVWb-8vYK-286" value="request /<div>grant</div>" style="endArrow=classic;html=1;rounded=0;labelBackgroundColor=#DAE8FC;fontSize=10;" parent="1" edge="1">
|
||||
<mxCell id="DDLsznhKMAXYVWb-8vYK-286" value="request /<div>grant</div>" style="endArrow=classic;html=1;rounded=0;labelBackgroundColor=#DAE8FC;fontSize=10;startArrow=classic;startFill=1;" parent="1" edge="1">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="94.88999999999999" y="510" as="sourcePoint" />
|
||||
<mxPoint x="94.88999999999999" y="550" as="targetPoint" />
|
||||
|
@ -223,7 +223,7 @@
|
|||
<mxCell id="DDLsznhKMAXYVWb-8vYK-306" value="server2<div>router</div>" style="rounded=1;whiteSpace=wrap;html=1;labelBackgroundColor=default;fontSize=11;" parent="1" vertex="1">
|
||||
<mxGeometry x="440" y="340" width="80" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="DDLsznhKMAXYVWb-8vYK-307" value="request /<div>grant</div>" style="endArrow=classic;html=1;rounded=0;labelBackgroundColor=#F8CECC;fontSize=10;" parent="1" edge="1">
|
||||
<mxCell id="DDLsznhKMAXYVWb-8vYK-307" value="request /<div>grant</div>" style="endArrow=classic;html=1;rounded=0;labelBackgroundColor=#F8CECC;fontSize=10;startArrow=classic;startFill=1;" parent="1" edge="1">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="454.8899999999999" y="340" as="sourcePoint" />
|
||||
<mxPoint x="454.8899999999999" y="300" as="targetPoint" />
|
||||
|
@ -248,7 +248,7 @@
|
|||
<mxCell id="DDLsznhKMAXYVWb-8vYK-311" value="server2<div>arbiter</div>" style="rounded=1;whiteSpace=wrap;html=1;labelBackgroundColor=default;fontSize=11;" parent="1" vertex="1">
|
||||
<mxGeometry x="320" y="550" width="80" height="30" as="geometry" />
|
||||
</mxCell>
|
||||
<mxCell id="DDLsznhKMAXYVWb-8vYK-312" value="request /<div>grant</div>" style="endArrow=classic;html=1;rounded=0;labelBackgroundColor=#DAE8FC;fontSize=10;" parent="1" edge="1">
|
||||
<mxCell id="DDLsznhKMAXYVWb-8vYK-312" value="request /<div>grant</div>" style="endArrow=classic;html=1;rounded=0;labelBackgroundColor=#DAE8FC;fontSize=10;startArrow=classic;startFill=1;" parent="1" edge="1">
|
||||
<mxGeometry width="50" height="50" relative="1" as="geometry">
|
||||
<mxPoint x="334.8899999999999" y="510" as="sourcePoint" />
|
||||
<mxPoint x="334.8899999999999" y="550" as="targetPoint" />
|
||||
|
|
Loading…
Reference in a new issue