vram/MemArbiter: remove unnecessary wires and fields

While iterating many redundant bits were added. This removes them again,
keeping just (I think) the minimum necessary for the arbitrators to work.
This commit is contained in:
David Anderson 2024-09-08 15:06:27 -07:00
parent 519eddc552
commit e5aabcbf4a
1 changed files with 9 additions and 14 deletions

View File

@ -25,6 +25,7 @@ function Bool mem_ops_conflict(Maybe#(MemArbiterOp#(addr)) a, Maybe#(MemArbiterO
endfunction endfunction
// A MemArbiterServer receives requests and emits grants. // A MemArbiterServer receives requests and emits grants.
(* always_ready *)
interface MemArbiterServer#(type addr); interface MemArbiterServer#(type addr);
method Action request(MemArbiterOp#(addr) req); method Action request(MemArbiterOp#(addr) req);
method Bool grant(); method Bool grant();
@ -71,6 +72,7 @@ interface MemArbiter#(numeric type num_clients, type addr);
// MemArbiter intances are Connectable: mkConnection(a, b) gives // MemArbiter intances are Connectable: mkConnection(a, b) gives
// conflict priority to a. That is, b only grants requests that // conflict priority to a. That is, b only grants requests that
// don't conflict with a's grant. // don't conflict with a's grant.
(* always_ready *)
method Action conflict(MemArbiterOp#(addr) conflict); method Action conflict(MemArbiterOp#(addr) conflict);
method MemArbiterOp#(addr) granted_op(); method MemArbiterOp#(addr) granted_op();
endinterface endinterface
@ -130,13 +132,13 @@ module mkPriorityMemArbiter(MemArbiter#(num_clients, addr))
endmodule endmodule
typedef struct { typedef struct {
Bool granted;
Vector#(n, Bool) grant_vec; Vector#(n, Bool) grant_vec;
UInt#(TLog#(n)) selected;
Maybe#(MemArbiterOp#(addr)) granted_op; Maybe#(MemArbiterOp#(addr)) granted_op;
} GrantResult#(numeric type n, type addr) deriving (Bits, Eq, FShow); } GrantResult#(numeric type n, type addr) deriving (Bits, Eq, FShow);
// select_grant computes which one entry of requests should be granted. // select_grant computes which one entry of requests should be
// granted. Priority order is descending starting from
// requests[hipri].
function GrantResult#(n, addr) select_grant(Vector#(n, Maybe#(MemArbiterOp#(addr))) requests, function GrantResult#(n, addr) select_grant(Vector#(n, Maybe#(MemArbiterOp#(addr))) requests,
UInt#(TLog#(n)) hipri, UInt#(TLog#(n)) hipri,
Maybe#(MemArbiterOp#(addr)) conflict) Maybe#(MemArbiterOp#(addr)) conflict)
@ -152,11 +154,9 @@ function GrantResult#(n, addr) select_grant(Vector#(n, Maybe#(MemArbiterOp#(addr
Tuple2#(UInt#(TLog#(n)), Tuple2#(UInt#(TLog#(n)),
Maybe#(MemArbiterOp#(addr))) next); Maybe#(MemArbiterOp#(addr))) next);
match {.idx, .mreq} = next; match {.idx, .mreq} = next;
if (mreq matches tagged Valid .req &&& !acc.granted &&& !mem_ops_conflict(conflict, mreq)) if (mreq matches tagged Valid .req &&& acc.granted_op matches tagged Invalid &&& !mem_ops_conflict(conflict, mreq))
return GrantResult{ return GrantResult{
granted: True,
grant_vec: onehot(idx), grant_vec: onehot(idx),
selected: idx,
granted_op: tagged Valid req granted_op: tagged Valid req
}; };
else else
@ -167,9 +167,7 @@ function GrantResult#(n, addr) select_grant(Vector#(n, Maybe#(MemArbiterOp#(addr
let in = zip(map(fromInteger, genVector()), requests); let in = zip(map(fromInteger, genVector()), requests);
let rot = rotateBy(in, fromInteger(valueOf(n)-1)-hipri+1); let rot = rotateBy(in, fromInteger(valueOf(n)-1)-hipri+1);
let seed = GrantResult{ let seed = GrantResult{
granted: False,
grant_vec: replicate(False), grant_vec: replicate(False),
selected: 0,
granted_op: tagged Invalid granted_op: tagged Invalid
}; };
return foldl(do_fold, seed, rot); return foldl(do_fold, seed, rot);
@ -201,13 +199,10 @@ module mkRoundRobinMemArbiter(MemArbiter#(num_clients, addr))
let res = select_grant(in, high_prio, conflict_in.wget()); let res = select_grant(in, high_prio, conflict_in.wget());
grants <= res.grant_vec; grants <= res.grant_vec;
if (res.granted) if (res.granted_op matches tagged Valid .op) begin
if (res.selected == fromInteger(valueOf(num_clients)-1))
high_prio <= 0;
else
high_prio <= res.selected+1;
if (res.granted_op matches tagged Valid .op)
granted_op_out.wset(op); granted_op_out.wset(op);
high_prio <= validValue(findElem(True, rotateR(res.grant_vec)));
end
endrule endrule
Vector#(num_clients, MemArbiterServer#(addr)) _ifcs = newVector(); Vector#(num_clients, MemArbiterServer#(addr)) _ifcs = newVector();