--File: DSimMOSAccessDefs.mesa
-- Last Updated: October 15, 1980 2:33 PM
--This version uses extended memory on a D* machine and INLINE calls
--*** Note *** this must be compiled with the /l switch
DIRECTORY
InlineDefs: FROM "InlineDefs" USING[LongCOPY],
SimMOSDefs: FROM "SimMOSDefs" USING[Node, NodeRecord, Transistor, TransistorRecord],
XFSPDefs: FROM "XFSPDefs" USING[XAllocateHeapNode];
SimMOSAccessDefs: DEFINITIONS
IMPORTS InlineDefs, XFSPDefs =
BEGIN OPEN InlineDefs, SimMOSDefs, XFSPDefs;
--Record component access procedures--
AllocateNode: PUBLIC PROCEDURE[name: STRING] RETURNS[node: Node] = INLINE
--Allocates space for a Node and its name
--This version puts chars adjacent to the Node record and following it,
-- and records the name length in node.nodeName
BEGIN
node ← XAllocateHeapNode[SIZE[NodeRecord] + (name.length+1)/2];
node.nodeName ← LOOPHOLE[name.length,STRING];
END;
AllocateTransistor: PUBLIC PROCEDURE RETURNS[trans: Transistor] = INLINE
BEGIN
trans ← XAllocateHeapNode[SIZE[TransistorRecord]];
END;
DestroyNodes: PUBLIC PROCEDURE[node: Node] RETURNS[Node] = INLINE
BEGIN --assumes nodeName STRING has been freed
--nothing for now
RETURN[NIL];
END;
DestroyTransistors: PUBLIC PROCEDURE[trans: Transistor] RETURNS[Transistor] = INLINE
BEGIN
--nothing for now
RETURN[NIL];
END;
--Node access procedures
SetNode: PUBLIC PROCEDURE[node: Node,
nodeFlags: WORD,-- flag word (fixnum)
nodeEquivClass: Node,-- ptr to next element of equivlence class
nodeName: STRING,-- pname of node
nodeNext: Node] = INLINE
BEGIN
node↑ ← [
nodeFlags: nodeFlags,
nodeEquivClass: nodeEquivClass,
nodeName: LOOPHOLE[nodeName.length,STRING],
nodeNext: nodeNext];
LongCOPY[BASE[nodeName.text], (nodeName.length+1)/2, node+SIZE[NodeRecord]];
END;
SetNodeFlags: PUBLIC PROCEDURE[node: Node, nodeFlags: WORD] = INLINE
BEGIN
node.nodeFlags ← nodeFlags;
END;
SetNodeEquivClass: PUBLIC PROCEDURE[node: Node, nodeEquivClass: Node] = INLINE
BEGIN
node.nodeEquivClass ← nodeEquivClass;
END;
SetNodeName: PUBLIC PROCEDURE[node: Node, nodeName: STRING] = INLINE
BEGIN
node.nodeName ← LOOPHOLE[nodeName.length,STRING];
LongCOPY[BASE[nodeName.text], (nodeName.length+1)/2, node+SIZE[NodeRecord]];
END;
SetNodeNext: PUBLIC PROCEDURE[node: Node, nodeNext: Node] = INLINE
BEGIN
node.nodeNext ← nodeNext;
END;
GetNodeFlags: PUBLIC PROCEDURE[node: Node] RETURNS[WORD] = INLINE
BEGIN
RETURN[node.nodeFlags];
END;
GetNodeEquivClass: PUBLIC PROCEDURE[node: Node] RETURNS[Node] = INLINE
BEGIN
RETURN[node.nodeEquivClass];
END;
GetNodeName: PUBLIC PROCEDURE[node: Node, name: STRING] RETURNS[STRING] = INLINE
--Returns name (input parameter) filled in with the name
--Generates StringDefs.StringBoundFault[s]RETURNS[ns] if name not long enough
BEGIN
name.length ← LOOPHOLE[node.nodeName,CARDINAL];
LongCOPY[node+SIZE[NodeRecord], (name.length+1)/2, BASE[name.text]];
RETURN[name];
END;
GetNodeNext: PUBLIC PROCEDURE[node: Node] RETURNS[Node] = INLINE
BEGIN
RETURN[node.nodeNext];
END;
--Transistor access procedures
SetTrans: PUBLIC PROCEDURE[trans: Transistor,
transGate: Node,-- gate node
transSource: Node,-- source node
transDrain: Node,-- drain node
transNext: Transistor] = INLINE
BEGIN
trans↑ ← [
transGate: transGate,
transSource: transSource,
transDrain: transDrain,
transNext: transNext];
END;
SetTransGate: PUBLIC PROCEDURE[trans: Transistor, transGate: Node] = INLINE
BEGIN
trans.transGate ← transGate;
END;
SetTransSource: PUBLIC PROCEDURE[trans: Transistor, transSource: Node] = INLINE
BEGIN
trans.transSource ← transSource;
END;
SetTransDrain: PUBLIC PROCEDURE[trans: Transistor, transDrain: Node] = INLINE
BEGIN
trans.transDrain ← transDrain;
END;
SetTransNext: PUBLIC PROCEDURE[trans: Transistor, transNext: Transistor] = INLINE
BEGIN
trans.transNext ← transNext;
END;
GetTransGate: PUBLIC PROCEDURE[trans: Transistor] RETURNS[Node] = INLINE
BEGIN
RETURN[trans.transGate];
END;
GetTransSource: PUBLIC PROCEDURE[trans: Transistor] RETURNS[Node] = INLINE
BEGIN
RETURN[trans.transSource];
END;
GetTransDrain: PUBLIC PROCEDURE[trans: Transistor] RETURNS[Node] = INLINE
BEGIN
RETURN[trans.transDrain];
END;
GetTransNext: PUBLIC PROCEDURE[trans: Transistor] RETURNS[Transistor] = INLINE
BEGIN
RETURN[trans.transNext];
END;
END.