/* Core.h
	*/
	
# ifndef Core
# define Core

#include "CoreBasics.h"

/* Miscellaneous */
	
	extern String Index();
		/* new, String name, Nat index */
		
/* Wire */
	
	typedef struct WireRec {
		Properties properties;
		Nat size;
		struct WireRec *elements[1];
		} WireRec;
		
	typedef WireRec *Wire;
	typedef WireRec *WireSeq;
		
	extern Ref GetWireProp();
		/* ref, Wire wire, Atom prop */
		
	extern void PutWireProp();
		/* Wire wire, Atom prop, Ref value */
		
	extern String GetShortWireName();
		/* name, Wire wire */
		
	extern void SetShortWireName();
		/* Wire wire, String name */
		
	extern Nat WireBits();
		/* count, Wire wire */
		
	extern ListOfString GetFullWireNames();
		/* names, WireSeq root, Wire wire */
		
	extern String GetFullWireName();
		/* name, WireSeq root, Wire wire */
		
	extern Wire CreateWire();
		/* wire, List wires, String name, Properties properties=nil */
		
	extern Wire CreateWires();
		/* wire, Nat size, String name, Properties properties=nil */
		
	extern Wire CopyWire();
		/* new, Wire wire */
		
	extern Wire FindWire();
		/* wire, WireSeq root, String name */
		
	extern void PrintWire();
		/* Wire wire, Nat indent=0, Nat level=2 */
		
	typedef void (*EachWireProc)();
		/* Wire wire, Ref context */
		
	extern void VisitRootAtomics();
		/* WireSeq root, EachWireProc each, Ref context */
		
	typedef Bool (*EachWirePairProc)();
		/* quit=false, Wire actualWire, Wire publicWire, Ref context, Bool *subWires=true */
		
	extern Bool VisitBinding();
		/* quit, Wire actual, Wire public, EachWirePairProc each, Ref context */
		
	extern Bool VisitBindingSeq();
		/* quit, WireSeq actual, WireSeq public, EachWirePairProc each, Ref context */
		
/* Cell Class */
	
	typedef struct CellClassRec {
		String name;
		Ref (* recast)();  /* really RecastProc */
		Properties properties;
		Bool layersProps;
		} CellClassRec;
		
	typedef CellClassRec *CellClass;
		
	extern Ref GetCellClassProp();
		/* ref, CellClass cellClass, Atom prop */
		
	extern void PutCellClassProp();
		/* CellClass cellClass, Atom prop, Ref value */
		
	extern CellClass CreateCellClass();
		/* cellClass, String name, RecastProc recast, Properties properties=nil, Bool layersProps=true */
		
	extern CellClass SetClassPrintProc();
		/* same, CellClass cellClass, PrintClassProc proc */
		typedef void (* PrintClassProc)();
			/* Ref data, Nat indent=0, Nat level=2 */
			
/* Cell Type */
	
	typedef struct CellTypeRec {
		CellClass class;
		WireSeq public;
		Ref data;
		Properties properties;
		} CellTypeRec;
		
	typedef CellTypeRec *CellType;
		
	typedef CellType (* RecastProc)();
		/* CellType me */
		
	extern Ref GetCellTypeProp();
		/* ref, CellType cellType, Atom prop */
		
	extern void PutCellTypeProp();
		/* CellType cellType, Atom prop, Ref value */
		
	extern String GetCellTypeName();
		/* name, CellType cellType */
		
	extern CellType SetCellTypeName();
		/* same, CellType cellType, String name */
		
	extern CellType CreateCellType();
		/* cellType, CellClass class, WireSeq public, Ref data, String name, Properties properties */
		
	extern void PrintCellType();
		/* CellType cellType, Nat indent=0, Nat level=2 */
		
/* Record Cell Class
	*/
	
	extern CellClass recordCellClass;
		
	typedef struct CellInstanceRec {
		WireSeq actual;
		CellType type;
		Properties properties;
		} CellInstanceRec;
		
	typedef CellInstanceRec *CellInstance;
		
	typedef struct RecordCellTypeRec {
		WireSeq internal;
		Nat size;
		CellInstance cellInstances[1];
		} RecordCellTypeRec;
		
	typedef RecordCellTypeRec *RecordCellType;
		
	extern Ref GetCellInstanceProp();
		/* ref, CellInstance cellInstance, Atom prop */
		
	extern void PutCellInstanceProp();
		/* CellInstance cellInstance, Atom prop, Ref value */
		
	extern String GetCellInstanceName();
		/* name, CellInstance cellInstance */
		
	extern CellInstance SetCellInstanceName();
		/* same, CellInstance cellInstance, String name */
		
	extern CellInstance CreateCellInstance();
		/* cellInstance, WireSeq actual, CellType type, String name=nil, Properties properties=nil */
		
	extern CellType CreateRecordCell();
		/* cellType, WireSeq public, WireSeq internal, List cellInstances, String name=nil, Properties properties=nil, Bool giveNames=false */
		
/* Transistor Cell Class */
	
	extern CellClass transistorCellClass;
		
	typedef enum TransistorType {nE, pE, nD} TransistorType;
		
	extern String transistorTypeNames[3];
		
	typedef enum TransistorPort {gate, ch1, ch2, Vdd} TransistorPort;
		
	extern String transistorPortNames[4];
		
	typedef struct TransistorRec {
		TransistorType type;
		} TransistorRec;
		
	typedef TransistorRec *Transistor;
		
	extern CellType CreateTransistor();
		/* cellType, TransistorType type, int length=-1, int width=-1, String name=nil, Properties properties=nil */
		
/* Initialization */
	
	extern void CoreInitialize();
		/*  */
		
# endif