RequestArbiterFSM:
CEDAR
PROGRAM
IMPORTS Boole, CoreCreate, CoreOps, FiniteStateAutomata =
BEGIN OPEN Boole, CoreCreate, FiniteStateAutomata;
Create:
PROC
RETURNS [ct: CellType] = {
fsa: StateMachine;
AReq: Wire ← CoreOps.CreateWire[name: "AReq"];
BReq: Wire ← CoreOps.CreateWire[name: "BReq"];
PopReq: Wire ← CoreOps.CreateWire[name: "PopReq"];
PriorityA: Wire ← CoreOps.CreateWire[name: "PriorityA"];
PriorityB: Wire ← CoreOps.CreateWire[name: "PriorityB"];
public: Wire ← WireList[
LIST["Vdd", "Gnd", "Clock", "Reset",
AReq, BReq, PopReq, PriorityA, PriorityB]];
states: LIST OF ATOM ← LIST[$Idle];
states ← StateSeq[states, "PA", 2];
states ← StateSeq[states, "PB", 2];
fsa ← NewMachine[states];
Mealy[fsa, $Idle,
NIL,
LIST [
[$Idle, And[Not[AReq], Not[BReq]]],
[$PA0, AReq],
[$PB0, BReq]
]];
Mealy[fsa, $PA0,
LIST[PriorityA],
LIST[
[$Idle, And[PopReq, Not[BReq]]],
[$PA0, And[Not[PopReq], Not[BReq]]],
[$PA1, And[Not[PopReq], BReq]],
[$PB0, And[PopReq, BReq]]
]];
Mealy[fsa, $PA1,
LIST[PriorityA],
LIST[
[$PA1, Not[PopReq]],
[$PB0, PopReq]
]];
Mealy[fsa, $PB0,
LIST[PriorityB],
LIST[
[$Idle, And[PopReq, Not[AReq]]],
[$PA0, And[PopReq, AReq]],
[$PB0, And[Not[PopReq], Not[AReq]]],
[$PB1, And[Not[PopReq], AReq]]
]];
Mealy[fsa, $PB1,
LIST[PriorityB],
LIST[
[$PA0, PopReq],
[$PB1, Not[PopReq]]
]];