FSAExtrasImpl.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Barth, November 19, 1986 6:30:03 pm PST
DIRECTORY CDDirectory, Core, CoreCreate, CoreOps, FSAExtras, Rope, Sisyph;
FSAExtrasImpl:
CEDAR
PROGRAM
IMPORTS CDDirectory, 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:
ROPE ←
NIL]
RETURNS [ct: CellType] = {
fsaCell: CellType ← NIL;
fsaName: ROPE ← NIL;
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.