Counter:
PUBLIC
PROC [table: TableOfVariables] = {
numBits: INT = PW.Log2[MC.nLines];
Since the counter is a power of 2, we don't care where the counter starts on ResetxAB, so for the debug version we leave ResetxAB out of the picture.
The inputs to the counter are ArrayAdrsxBA and Incr; the outputs are ArrayAdrsxAB
FOR index:
INT
IN [0..numBits)
DO
me: Expression ← Find[table, MC.IndexedName["ArrayAdrsxBA", index]];
allUnderAreOnes: Expression ← true;
expr: Expression;
FOR under:
INT
IN (index .. numBits)
DO
allUnderAreOnes ← And[table,
allUnderAreOnes,
Find[table, MC.IndexedName["ArrayAdrsxBA", under]]];
ENDLOOP;
expr ← If[table,
Find[table, "Incr"],
If[table, allUnderAreOnes, Not[me], me],
me];
AddOutput[table,
NEW[OutputRec ← [
name: MC.IndexedName["ArrayAdrsxAB", index],
type: latch,
fedBackInput: FindInternal[table, MC.IndexedName["ArrayAdrsxBA", index]],
expr: expr]]];
ENDLOOP;
};