MyCellModule.mesa
Copyright © 1987 by Xerox Corporation. All rights reserved.
Monier, January 5, 1987 8:15:51 pm PST
Gasbarro, January 23, 1987 2:17:39 pm PST
Barth, March 12, 1987 11:53:03 am PST
DIRECTORY CDCommandOps, CDProperties, CDSequencer, Core, CoreCreate, CoreFlat, Ports, Rope, Rosemary, RosemaryUser, Sisyph;
MyCellModule: CEDAR PROGRAM
IMPORTS CDCommandOps, CDProperties, CDSequencer, CoreCreate, CoreFlat, Ports, Rosemary, RosemaryUser, Sisyph
= BEGIN
This file contains templates for attaching behavior and tests to cell types generated by program or by extraction. The behavioral template should not be used when the cell type is used more than once in a design and the cell type is saved in a cache using CoreIO.
Binding
MyCellPhA, MyCellPhB, Vdd, Gnd: NATLAST[NAT];
MyCellInitPortIndicies: PROC [p: Core.Wire] ~ {
[up to 12 signals] ← Ports.PortIndexes[p, up to 12 quoted signals];
[Vdd, Gnd] ← Ports.PortIndexes[p, "Vdd", "Gnd"];
};
Structure
MyCell: PUBLIC PROC [arguments] RETURNS [cellType: CoreCreate.CellType] = {
public: Core.Wire ← CoreCreate.Wires[
"simpleWire",
CoreCreate.Seq["bus", bitsInBus],
"Vdd", "Gnd"];
cellType ← CoreClasses.CreateUnspecified[name: "MyCell", public: public];
MyCellInitPortIndicies[public];
Ports.IPList[public, LIST[MyCellPhA, MyCellPhB], b];
};
Test
InitializeTest: PROC ~ {
CDSequencer.ImplementCommand[key: $MyCellExtractAndSimulate, proc: MyCellExtractAndSimulate, queue: doQueue];
CDCommandOps.RegisterWithMenu[menu: $ProgramMenu, entry: "Simulate MyCell", key: $MyCellExtractAndSimulate];
RosemaryUser.RegisterTestProc["MyCellTest", MyCellTest]; 
};
MyCellExtractAndSimulate: PROC [comm: CDSequencer.Command] ~ {
cellType: Core.CellType ← Sisyph.ExtractSchematicByName["MyCell.sch", Sisyph.Create[comm.design]];
public: Core.Wire ← cellType.public;
MyCellInitPortIndicies[public];
Ports.IPList[public, LIST[MyCellPhA, MyCellPhB], b];
CDProperties.PutDesignProp[comm.design, $DAUserRoseDisplay, MyCellSimulate[cellType].display];
};
MyCellCreateAndSimulate: PROC ~ {
cellType: Core.CellType ← MyCell[arguments];
MyCellSimulate[cellType];
};
MyCellSimulate: PROC [cellType: Core.CellType] RETURNS [tester: RosemaryUser.Tester] ~ {
public: Core.Wire ← cellType.public;
Ports.ITDList[public, LIST[inputs], force];
Ports.ITDList[public, LIST[outputs], expect];
Ports.ITDList[public, LIST[inputs/outputs], none];
[] ← Rosemary.SetFixedWire[cellType.public[Vdd], H];
[] ← Rosemary.SetFixedWire[cellType.public[Gnd], L];
tester ← RosemaryUser.TestProcedureViewer[
cellType: cellType,
testButtons: LIST["MyCellTest"],
name: "MyCell Test",
displayWires: RosemaryUser.DisplayPortLeafWires[cellType],
cutSet: CoreFlat.CreateCutSet[labels: LIST["Logic", "LogicMacro", "FSA"]]];
};
MyCellTest: RosemaryUser.TestProc ~ { -- PROC [cellType: Core.CellType, p: Ports.Port, Eval: PROC]
MyCellInitPortIndicies[cellType.public];
p[MyCellPhA].b ← TRUE;
p[MyCellPhB].b ← FALSE;
Eval[];
};
Behavior
MyCellName: Rope.ROPE = Rosemary.Register[roseClassName: "MyCell", init: MyCellInit, evalSimple: MyCellSimple];
MyCellState: TYPE = REF MyCellStateRec;
MyCellStateRec: TYPE = RECORD [
any state: any type];
MyCellInit: Rosemary.InitProc = {
state: MyCellState ← IF oldStateAny#NIL THEN NARROW[oldStateAny] ELSE NEW[MyCellStateRec];
MyCellInitPortIndicies[cellType.public];
stateAny ← state;
};
MyCellSimple: Rosemary.EvalProc = {
state: MyCellState ← NARROW[stateAny];
body of the proc
};
Start Code
InitializeTest[];
END.