SimpleTest.Rose
Last Edited by: Spreitzer, April 28, 1985 3:47:58 pm PDT
Imports
IO, NumTypes;
CELLTYPE "Inverter"
PORTS [in<
BOOL, out>
BOOL]
EvalSimple
out ←
NOT in
ENDCELLTYPE;
CELLTYPE "Driver"
PORTS [in<Int[16], out>Int[16], str<Int[4]]
EvalSimple
drive[out] ←
VAL[str];
out ← in;
ENDCELLTYPE;
CELLTYPE "Incrementer"
PORTS [in<Int[16], out>Int[16]]
EvalSimple
out ← in + 1
ENDCELLTYPE;
Contest:
LAMBDA [contestants: |
NAT|]
RETURN
CELLTYPE AutoName
PortsProc
ports ←
NEW [PortsRep[contestants*2+1]];
FOR i:
NAT
IN [0 .. contestants)
DO
ports[2*i] ← [
simple: noField,
switch: noField,
name:
IO.PutFR["c[%g].in",
IO.int[i]],
type: NumTypes.NumType[16],
input:
TRUE];
ports[2*i+1] ← [
simple: noField,
switch: noField,
name:
IO.PutFR["c[%g].str",
IO.int[i]],
type: NumTypes.NumType[4],
input:
TRUE];
ENDLOOP;
ports[2*contestants] ← [
simple: noField,
switch: noField,
name: "incedOutcome",
type: NumTypes.NumType[16],
output:
TRUE];
Expand
CEDAR
[] ← to.class.NodeInstance[
erInstance: to.instance,
name: "outcome",
type: NumTypes.NumType[16]];
FOR i:
NAT
IN [0 .. contestants)
DO
[] ← to.class.CellInstance[
erInstance: to.instance,
instanceName:
IO.PutFR["d[%g]",
IO.int[i]],
typeName: "Driver",
interfaceNodes:
IO.PutFR["in: c[%g].in, out: outcome, str: c[%g].str",
IO.int[i],
IO.int[i]]
];
ENDLOOP;
[] ← to.class.CellInstance[
erInstance: to.instance,
instanceName: "inc",
typeName: "Incrementer",
interfaceNodes: "in: outcome, out: incedOutcome"
];
ENDCELLTYPE;
c3: Contest[3]