-- File: newtest.mesa - Created by SETAR 17-Jan-86 14:31:58
-- Frank Bowers January 20, 1986 11:23:30 am PST

DIRECTORY
Core,
CoreClasses,
CoreCompose,
CoreOps,
CoreProperties,
Rope,
SCTestCore;

newtest: CEDAR PROGRAM

IMPORTS CoreClasses, CoreCompose, CoreOps, CoreProperties
EXPORTS SCTestCore =

BEGIN

CellInstance: TYPE = CoreClasses.CellInstance;

CellType: TYPE = {c1IV00B, c1AN02A, c1NO02B, c1NO03B, c1NA03A, c1OR02A, c1NO04B};

ct: ARRAY CellType OF Core.CellType;

InitializeTypes: PROC [context: CoreCompose.Context] = {
  c1IV00BWires: CoreCompose.WireSequence ← CoreCompose.CreateWires[context, "I, X, Vdd, Gnd"];
  c1AN02AWires: CoreCompose.WireSequence ← CoreCompose.CreateWires[context, "IXA, IXB, X, Vdd, Gnd"];
  c1NO02BWires: CoreCompose.WireSequence ← CoreCompose.CreateWires[context, "IXA, IXB, X, Vdd, Gnd"];
  c1NO03BWires: CoreCompose.WireSequence ← CoreCompose.CreateWires[context, "IXA, IXB, X, IXC, Vdd, Gnd"];
  c1NA03AWires: CoreCompose.WireSequence ← CoreCompose.CreateWires[context, "IXA, IXB, IXC, X, Vdd, Gnd"];
  c1OR02AWires: CoreCompose.WireSequence ← CoreCompose.CreateWires[context, "IXA, IXB, X, Vdd, Gnd"];
  c1NO04BWires: CoreCompose.WireSequence ← CoreCompose.CreateWires[context, "IXA, IXB, IXC, IXD, X, Vdd, Gnd"];
  ct[c1IV00B] ← CreateRecordCell[context, "C1IV00B", c1IV00BWires, NIL, NIL];
  ct[c1AN02A] ← CreateRecordCell[context, "C1AN02A", c1AN02AWires, NIL, NIL];
  ct[c1NO02B] ← CreateRecordCell[context, "C1NO02B", c1NO02BWires, NIL, NIL];
  ct[c1NO03B] ← CreateRecordCell[context, "C1NO03B", c1NO03BWires, NIL, NIL];
  ct[c1NA03A] ← CreateRecordCell[context, "C1NA03A", c1NA03AWires, NIL, NIL];
  ct[c1OR02A] ← CreateRecordCell[context, "C1OR02A", c1OR02AWires, NIL, NIL];
  ct[c1NO04B] ← CreateRecordCell[context, "C1NO04B", c1NO04BWires, NIL, NIL];
};

CreateInstance: PROC [context: CoreCompose.Context, actual: Rope.ROPE, type: Core.CellType, name: Rope.ROPE] RETURNS [instance: CellInstance] = {
instance ← NEW[CoreClasses.CellInstanceRec ← [CoreCompose.CreateWires[context, actual], type, NIL]];
CoreProperties.PutCellInstanceProp[instance, CoreClasses.instanceNameProp, name]};

CreateRecordCell: PROC [context: CoreCompose.Context, name: Rope.ROPE, public: Core.WireSequence, onlyInternal: Core.WireSequence ← NIL, instances: CoreClasses.CellInstanceList ← NIL] RETURNS [cellType: Core.CellType] = {
internal: Core.WireSequence ← WireUnion[public, onlyInternal];
recCell: CoreClasses.RecordCellType ← NEW [CoreClasses.RecordCellTypeRec ← [internal: internal, instances: instances]];
cellType ← CoreOps.CreateCellType[
name: name,
class: CoreClasses.recordCellClass,
public: public,
data: recCell];
};

WireUnion: PROC [w1, w2: Core.WireSequence] RETURNS [union: Core.WireSequence] = {
IF w1=NIL THEN RETURN [w2];
IF w2=NIL THEN RETURN [w1];
union ← NEW [Core.WireSequenceRec[w1.size+w2.size]];
FOR i: INT IN [0..w1.size) DO union[i] ← w1[i] ENDLOOP;
FOR i: INT IN [0..w2.size) DO union[i+w1.size] ← w2[i] ENDLOOP;
};

CreateCore: PUBLIC PROC [] RETURNS [CoreCompose.Context, Core.CellType] = BEGIN
  context: CoreCompose.Context ← CoreCompose.CreateContext[];
instList: LIST OF CellInstance ← NIL;
  newtest: Core.CellType;
  pubWires: CoreCompose.WireSequence ← CoreCompose.CreateWires[context, "SD1Output, SF, Don, Act, SX, SD1, Start, Select, SelectOutput, StartOutput, EOP, FD, Contention, RENA, Vdd, Gnd"];
  privWires: CoreCompose.WireSequence ← CoreCompose.CreateWires[context, "w141, w140, w131, w127, w125, w108, w102, w98, w81, w78, w75, w72, w70, w69, w68, w67, w64, w63, w62, w56, w54, w51, w47, w46, w45, w44, w40, w37, w36, w18"];
InitializeTypes[context];
  instList ← CONS[CreateInstance[context, "RENA, w131, Vdd, Gnd", ct[c1IV00B], "c1IV00BInst128"], instList];
  instList ← CONS[CreateInstance[context, "Contention, w127, Vdd, Gnd", ct[c1IV00B], "c1IV00BInst126"], instList];
  instList ← CONS[CreateInstance[context, "FD, w125, Vdd, Gnd", ct[c1IV00B], "c1IV00BInst113"], instList];
  instList ← CONS[CreateInstance[context, "EOP, w108, Vdd, Gnd", ct[c1IV00B], "c1IV00BInst109"], instList];
  instList ← CONS[CreateInstance[context, "SD1, w102, Vdd, Gnd", ct[c1IV00B], "c1IV00BInst100"], instList];
  instList ← CONS[CreateInstance[context, "Select, w98, Vdd, Gnd", ct[c1IV00B], "c1IV00BInst96"], instList];
  instList ← CONS[CreateInstance[context, "Start, w81, Vdd, Gnd", ct[c1IV00B], "c1IV00BInst94"], instList];
  instList ← CONS[CreateInstance[context, "Act, w78, Vdd, Gnd", ct[c1IV00B], "c1IV00BInst90"], instList];
  instList ← CONS[CreateInstance[context, "Don, w75, Vdd, Gnd", ct[c1IV00B], "c1IV00BInst85"], instList];
  instList ← CONS[CreateInstance[context, "SF, w72, Vdd, Gnd", ct[c1IV00B], "c1IV00BInst83"], instList];
  instList ← CONS[CreateInstance[context, "w67, w68, w69, Vdd, Gnd", ct[c1AN02A], "c1AN02AInst66"], instList];
  instList ← CONS[CreateInstance[context, "SX, w127, w68, Vdd, Gnd", ct[c1NO02B], "c1NO02BInst65"], instList];
  instList ← CONS[CreateInstance[context, "Vdd, w64, w70, w69, Vdd, Gnd", ct[c1NO03B], "c1NO03BInst60"], instList];
  instList ← CONS[CreateInstance[context, "w62, w63, w64, Vdd, Gnd", ct[c1AN02A], "c1AN02AInst59"], instList];
  instList ← CONS[CreateInstance[context, "Gnd, w140, Vdd, Gnd", ct[c1IV00B], "c1IV00BInst53"], instList];
  instList ← CONS[CreateInstance[context, "w78, w127, w131, w51, Vdd, Gnd", ct[c1NA03A], "c1NA03AInst50"], instList];
  instList ← CONS[CreateInstance[context, "Gnd, w54, w56, Vdd, Gnd", ct[c1OR02A], "c1OR02AInst43"], instList];
  instList ← CONS[CreateInstance[context, "w45, w44, w47, Vdd, Gnd", ct[c1OR02A], "c1OR02AInst42"], instList];
  instList ← CONS[CreateInstance[context, "Gnd, w51, w54, Vdd, Gnd", ct[c1NO02B], "c1NO02BInst39"], instList];
  instList ← CONS[CreateInstance[context, "Vdd, w40, w46, Vdd, Gnd", ct[c1NO02B], "c1NO02BInst38"], instList];
  instList ← CONS[CreateInstance[context, "w36, w37, w40, Vdd, Gnd", ct[c1AN02A], "c1AN02AInst35"], instList];
  instList ← CONS[CreateInstance[context, "w56, w70, StartOutput, Vdd, Gnd", ct[c1AN02A], "c1AN02AInst16"], instList];
  instList ← CONS[CreateInstance[context, "w47, w46, SelectOutput, Vdd, Gnd", ct[c1AN02A], "c1AN02AInst15"], instList];
  instList ← CONS[CreateInstance[context, "Vdd, w18, SD1Output, Vdd, Gnd", ct[c1AN02A], "c1AN02AInst14"], instList];
  instList ← CONS[CreateInstance[context, "SD1, w98, w81, w108, w36, Vdd, Gnd", ct[c1NO04B], "c1NO04BInst13"], instList];
  instList ← CONS[CreateInstance[context, "w81, SD1, w67, w98, Vdd, Gnd", ct[c1NO03B], "c1NO03BInst12"], instList];
  instList ← CONS[CreateInstance[context, "w125, Act, w63, Contention, Vdd, Gnd", ct[c1NO03B], "c1NO03BInst11"], instList];
  instList ← CONS[CreateInstance[context, "w125, Act, w37, Contention, Vdd, Gnd", ct[c1NO03B], "c1NO03BInst10"], instList];
  instList ← CONS[CreateInstance[context, "Select, w81, w45, w102, Vdd, Gnd", ct[c1NO03B], "c1NO03BInst9"], instList];
  instList ← CONS[CreateInstance[context, "w98, w81, w44, SD1, Vdd, Gnd", ct[c1NO03B], "c1NO03BInst8"], instList];
  instList ← CONS[CreateInstance[context, "SD1, w81, w18, Select, Vdd, Gnd", ct[c1NO03B], "c1NO03BInst7"], instList];
  instList ← CONS[CreateInstance[context, "w81, SD1, Select, RENA, w62, Vdd, Gnd", ct[c1NO04B], "c1NO04BInst6"], instList];
  instList ← CONS[CreateInstance[context, "w81, SD1, Select, SX, , Vdd, Gnd", ct[c1NO04B], "c1NO04BInst5"], instList];
  instList ← CONS[CreateInstance[context, "Start, SD1, Select, SX, , Vdd, Gnd", ct[c1NO04B], "c1NO04BInst4"], instList];
  instList ← CONS[CreateInstance[context, "Gnd, Select, w81, SX, w141, Vdd, Gnd", ct[c1NO04B], "c1NO04BInst3"], instList];
  instList ← CONS[CreateInstance[context, "w72, w75, w78, SX, , Vdd, Gnd", ct[c1NO04B], "c1NO04BInst2"], instList];
  newtest ← CreateRecordCell[context, "newtest", pubWires, privWires, instList];
  RETURN[context, newtest];
  END;

END.