FSAExtrasImpl.mesa
Copyright Ó 1986, 1987 by Xerox Corporation. All rights reserved.
Barth, April 1, 1987 11:13:32 am PST
Bertrand Serlet April 2, 1987 9:39:46 pm PST
DIRECTORY Core, CoreCreate, CoreOps, FSAExtras, Rope, Sisyph;
FSAExtrasImpl: CEDAR PROGRAM
IMPORTS CoreCreate, CoreOps, Rope, Sisyph
EXPORTS FSAExtras
= BEGIN OPEN FSAExtras;
fsaExtension: ROPE ← ".fsa";
machineClass: Core.CellClass ← NEW [Core.CellClassRec ← [name: "MealyMachine", recast: RecastMealyMachine, layersProps: FALSE]];
stateClass: Core.CellClass ← NEW [Core.CellClassRec ← [name: "MealyState", layersProps: FALSE]];
transitionClass: Core.CellClass ← NEW [Core.CellClassRec ← [name: "MealyTransition", layersProps: FALSE]];
transitionCellType: Core.CellType ← CoreOps.CreateCellType [
class: transitionClass,
public: CoreCreate.Wires["Target", "Expression", "Source"]];
MealyMachine: PUBLIC PROC [cx: Sisyph.Context, s: ROPENIL] RETURNS [ct: CellType] = {
fsaCell: CellType ← NIL;
fsaName: ROPENIL;
IF s=NIL THEN {
objectName: ROPE ← CDDirectory.Name[Sisyph.GetCDObj[cx]];
index: INT ← Rope.Find[s1: objectName, s2: ".icon"];
length: INT ← Rope.Length[objectName];
IF index<0 OR index#length-5 THEN
ERROR; -- .icon not in string or not at end of string
s ← Rope.Substr[objectName, 0, length-5];
};
fsaCell ← Sisyph.ExtractSchematicByName[Rope.Cat[s, fsaExtension], cx];
fsaName ← CoreOps.GetCellTypeName[fsaCell];
fsaName ← Rope.Substr[fsaName, 0, Rope.Index[fsaName, 0, fsaExtension]];
[] ← CoreOps.SetCellTypeName[fsaCell, fsaName];
ct ← CoreOps.CreateCellType [
class: machineClass,
public: CoreCreate.Union[CoreOps.CopyWire[fsaCell.public], CoreCreate.Wires["Vdd", "Gnd", "Clock", "Reset"]],
data: fsaCell,
name: fsaName];
};
MealyState: PUBLIC PROC [o: NAT] RETURNS [ct: CellType] = {
ct ← CoreOps.CreateCellType [
class: stateClass,
public: CoreCreate.Wires["Target", "Source", CoreCreate.Seq["Output", o]]];
};
MealyTransition: PUBLIC PROC RETURNS [ct: CellType] = {
ct ← transitionCellType;
};
RecastMealyMachine: Core.RecastProc = {
ERROR;
};
END.