The Utilities Header Files
Define all Basic Data Types
Boolean Data Type
ce_Bool
Definition for Boolean true and false.
typedef enum {
ce_False = 0,
ce_True = 1
} ce_Bool;
Signed Integer Data Types
ce_Int8
8 Bit signed integer.
typedef signed char ce_Int8;
#define CE_INT8_MIN SCHAR_MIN
#define CE_INT8_MAX SCHAR_MAX
ce_Int16
16 Bit signed integer.
typedef signed short ce_Int16;
#define CE_INT16_MIN SHRT_MIN
#define CE_INT16_MAX SHRT_MAX
ce_Int32
32 Bit signed integer.
typedef signed int ce_Int32;
#define CE_INT32_MIN INT_MIN
#define CE_INT32_MAX INT_MAX
ce_Int64
64 Bit signed integer.
#if defined(WINDOWS)
typedef signed __int64 ce_Int64;
#define CE_INT64_MIN _I64_MIN
#define CE_INT64_MAX _I64_MAX
#else
typedef signed long long ce_Int64;
#define CE_INT64_MIN (-CE_INT64_MAX-1LL)
#define CE_INT64_MAX (9223372036854775807LL)
#endif
Unsigned Integer Data Types
ce_UInt8
8 Bit unsigned integer.
typedef unsigned char ce_UInt8;
#define CE_UINT8_MAX UCHAR_MAX
ce_UInt16
16 Bit unsigned integer.
typedef unsigned short ce_UInt16;
#define CE_UINT16_MAX USHRT_MAX
ce_UInt32
32 Bit unsigned integer.
typedef unsigned int ce_UInt32;
#define CE_UINT32_MAX UINT_MAX
ce_UInt64
64 Bit unsigned integer.
#if defined(WINDOWS)
typedef unsigned __int64 ce_UInt64;
#define CE_UINT64_MAX _UI64_MAX
#else
typedef unsigned long long ce_UInt64;
#define CE_UINT64_MAX (18446744073709551615ULL)
#endif
Integer Type for Pointer Precision
ce_IntPtr
Signed integer in the size of a pointer; use when casting a pointer to a long to perform pointer arithmetic.
#if defined(WINDOWS)
typedef signed __int64 ce_IntPtr;
#else
typedef signed long ce_IntPtr;
#endif
ce_UIntPtr
Unsigned integer in the size of a pointer; use when casting a pointer to a long to perform pointer arithmetic.
#if defined(WINDOWS)
typedef unsigned __int64 ce_UIntPtr;
#else
typedef unsigned long ce_UIntPtr;
#endif
Integer Type for File Size, Position and Offset
ce_Filepos
File position.
typedef ce_Int64 ce_Filepos;
#define CE_FILEPOS_MAX CE_INT64_MAX
Integer Type for Platform Independent Long Precision
ce_Long
Signed integer in the size of a pointer.
#if defined(WINDOWS)
typedef signed __int64 ce_Long;
#define CE_LONG_MAX _I64_MAX
#else
typedef signed long ce_Long;
#define CE_LONG_MAX LONG_MAX
#endif
ce_ULong
Unsigned integer in the size of a pointer.
#if defined(WINDOWS)
typedef unsigned __int64 ce_ULong;
#define CE_ULONG_MAX _UI64_MAX
#else
typedef unsigned long ce_ULong;
#define CE_ULONG_MAX ULONG_MAX
#endif
Integer Type for Time
ce_Time
Unsigned 64 bit integer to store time information.
typedef ce_UInt64 ce_Time;
ce_Date
Signed integer to store date information.
Define Custom Assertions
Error Message Handling
File System Functions
Collection of functions to interact with the file system.
File Functions
Many ce_File* functions get an "filename" argument that refers to a file or to a directory. If not stated different below, it can be either an absolute path or a relative path (relative to the current working directory). The "dirname" argument refers to a directory (can be either an absolute path or a relative path).
ce_Filesize
Returns the size of a file (in # of bytes).
ce_Filepos ce_Filesize(const char* filename);
ce_FileModificationTime
Returns the modification time stamp of a file or directory.
ce_Date ce_FileModificationTime(const char* filename);
ce_FileExist
Return true if given file or directory exists and false if it does not exist.
ce_Bool ce_FileExist(const char* filename);
ce_FileIsDirectory
Returns true if filename refers to a directory or false if not.
ce_Bool ce_FileIsDirectory(const char* filename);
ce_FileIsSymbolicLink
Returns true if filename refers to a symbolic link or false if not.
ce_Bool ce_FileIsSymbolicLink(const char* filename);
ce_FileReadSymbolicLink
Returns the target of a symbolic link.
int ce_FileReadSymbolicLink(
const char* filename,
char* buf,
unsigned maxlen
);
ce_FilePathToExe
Return the absolute path to the running executable.
int ce_FilePathToExe(
const char* filename,
char* buf,
unsigned maxlen
);
ce_FileIsWritable
Return true if given dir/file is writable.
ce_Bool ce_FileIsWritable(const char* filename);
ce_FileIsReadable
Return true if given dir/file is readable.
ce_Bool ce_FileIsReadable(const char* filename);
ce_FileIsExecutable
Return true if the given file is executable.
ce_Bool ce_FileIsExecutable(const char* filename);
ce_FileRename
Renames a file. Returns 0 on success or 1 on error. This function is limited to file names without any directory path prefix (neither relative nor absolute).
int ce_FileRename(
const char* oldName,
const char* newName
);
ce_FileDelete
Delete a file. Returns 0 on success or 1 on error. This function is limited to file names without any directory path prefix (neither relative nor absolute).
int ce_FileDelete(const char* filename);
ce_FileCaseName
Converts the given filename (by changing upper/lower case of the file name characters) to fit an existing filename (in the file system). If no existing file name can be found, then 0 is returned and filename is not modified. On success, 1 is returned.
int ce_FileCaseName(char* filename);
ce_FileHasTTY
Return true if there is a TTY
ce_Bool ce_FileHasTTY(void);
ce_FileOpenDir
Open a directory - like UNIX opendir(). Opening "/.." maps to "/" on some UNIX systems.
void* ce_FileOpenDir(const char* dirname);
ce_FileReadDir
Read the next entry of the directory - like UNIX readdir().
const char* ce_FileReadDir(void* dir);
ce_FileCloseDir
Close the directory - like UNIX closedir(). Returning 0 on success or -1 on failure (the global errno is set to indicate the error).
int ce_FileCloseDir(void* dir);
ce_FileCopy
Copy infile to outfile.
int ce_FileCopy(
const char* infile,
const char* outfile
);
ce_FileTempDirectory
Return a good temp dir.
const char* ce_FileTempDirectory(void);
ce_FileTempFilename
Return unique filename in temp dir.
const char* ce_FileTempFilename(
const char* prefix,
const char* tempDir,
char* buf,
int maxlen
);
ce_FileDirname
Find directory of given filename.
int ce_FileDirname(
const char* filename,
char* result,
unsigned maxlen
);
ce_FileTail
Return all of the characters in the last filesystem component of the given filename. If the filename contains no separators, then the filename is returned.
int ce_FileTail(
const char* filename,
char* result,
unsigned maxlen
);
ce_FileNameType
Return the type of the file: 0: absolute 1: relative -1: empty file name 2: volumerelative (on Windows only) 3: novolumeabsolute (on Windows only)
int ce_FileNameType(const char* filename);
ce_FileNativeName
Convert / to \\ on Windows.
void ce_FileNativeName(char* filename);
ce_FileUniqueName
Makes the given filename unique. The returned string must be freed after usage.
char* ce_FileUniqueName(const char* filename);
ce_FileMkdir
Create given directory. If successful returns true. If failed or the if the directory already exists return false.
ce_Bool ce_FileMkdir(
const char* directory,
ce_Bool recursive
);
ce_FileConvertName
Converts a given filename depending on mode. The given filename is converted to absolute or relative (more on Windows) depending on the "mode" argument. The conversion is relative to the given directory "dir" (dir must be absolute) or if dir == NULL, then relative to the current working directory. The converted path is copied into result buffer with maxlen space. Returns the mode of given filename or -1 for error. The following modes are defined: 0 : absolute Unix: /dir/file Win32: c:\dir\file.txt, \\host\service\file.txt 1 : relative Unix: ./file, file.txt Win32: .\file, file.txt dir\file.txt 2 : volumerelative Win32: c:.\file, c:file.txt c:dir\file.txt 3 : novolumeabsolute Win32: /dir/file 4 : relative(1) or absolute(0) - whatever is shorter
int ce_FileConvertName(
const char* filename,
int mode,
const char* dir,
char* result,
unsigned maxlen
);
ce_FileConvertName2
Converts a given "filename" into relative-to-todir. Converted path is copied into "result" buffer with maxlen space. Returns the mode of given "filename" or -1 for error. The given "filename" may be relative to "fromdir". If the given "fromdir" and "todir" are not absolute paths, then they are first converted to absolute by the current working directory. If the given "filename" cannot converted into relative-to-todir, then the absolute path is returned. On Windows, the details are: filename result 0:absolute 0:absolute 1:relative 1:relative-to-todir or 0:absolute 2:volumerelative 1:relative-to-todir or 0:absolute 3:novolumeabsolute 3:novolumeabsolute or 0:absolute
The ambiguous case 2:volumerelative will call getdcwd() to get Window’s drive-specific directory if the drive character in the given filename does not match to the drive character in todir. Examples:
filename fromdir todir result bla C:\path C:\path\to ..\bla bla C:\path\to C:\path to\bla bla C:\path F:\path\to C:\path\bla bla C:\path\to F:\path C:\path\to\bla F:\path\bla ??????? ??????? F:\path\bla F:bla F:\path\to C:\path F:\path\to\bla F:bla F:\path\to F:\path\any ..\to\bla \ok\bla F:\path\to C:\path F:\ok\bla \ok\bla F:\path\to F:\path\any \ok\bla
More examples for the cases if fromdir or todir are not absolute:
filename fromdir todir result bla C:/path C:/path bla bla C:/path/ok C:/path ok\bla bla . . bla bla .. . ..\bla bla . ok/ok ..\..\bla
If todir==NULL, then "." (the current working directory) is assumed, and in addition, the returned filename is absolute if that is shorter than the relative version.
int ce_FileConvertName2(
const char* filename,
const char* fromdir,
const char* todir,
char* result,
unsigned maxlen
);
ce_FileHomeDir
Get home dir of given user, use NULL for current user. Returns true if ok, false on Error (error message is in dest).
int ce_FileHomeDir(
const char* user,
char* dest,
unsigned maxLen
);
ce_FileConfigDir
Get the configuration directory for current user. Returns -1 on Error (error message is in dest).
int ce_FileConfigDir(
ce_Bool legacy,
char* dest,
unsigned maxLen
);
ce_FilePathCompare
Compare the two given paths. On Windows '\\' and '/' are equal, also ignore case.
int ce_FilePathCompare(
const char* path1,
const char* path2
);
ce_FileGetCwd
Get the current working directory.
char* ce_FileGetCwd(
char* result,
unsigned maxLen
);
ce_SanitizeFilename
Return a sanitized version of the given file name, e.g. a new string without any special characters, following the OS rules for file naming. The returned must be freed by the caller.
char* ce_FileSanitizeName(const char* filename);
Operating System Calls
Reimplementation of the most important clib functions. == Operating System Calls to Allocate Memory
Allocate and Free Memory
Define a Read/Write Interface
Hash Table Template
The Progress Bar Header File
Manage Progress Bar and Interrupt
The zdb Header Files
The zdb Database Core Functions and Objects
Version of the Binfile Format
Incompatible changes are only permitted for major releases.
#define BINFILE_VERSION_MAJOR 16 /* Increment this for in-compatible changes */
#define BINFILE_VERSION_MINOR 1 /* Increment this for compatible changes */
Database Hash Table Definition
Hash Table Key Types
typedef enum HashKeyType {
HASHKEY_STRING,
HASHKEY_ICASE,
HASHKEY_PTR,
HASHKEY_LENGTH
} HashKeyType;
Hash Table Struct Definition
typedef struct HashTable {
struct HashTableEntry** bucketList;
struct HashTableMemory* memoryBuffer;
struct HashTableEntry* freeList;
int nBuckets;
int count;
int valueSize;
HashKeyType ktype;
} HashTable;
Hash Table Iterator Struct Definition
typedef struct HashIter {
struct HashTable* table;
struct HashTableEntry* cur;
int slot;
} HashIter;
Hierarchy Separator
Default Hierarchy Separators
The visible hierarchy separator can be any character. The internal hierarchy separator needs to be a character that is not used as an object name in the entire database. The default value is the non-printable character GS (group separator).
#define VISIBLE_HIERARCHY_SEPARATOR '.'
#define INTERNAL_HIERARCHY_SEPARATOR 0x1D
Database Object Flags
Port Flags
typedef unsigned short PortFlags;
#define PortFUnknown 0x0000 /* Port direction: Unknown */
#define PortFOut 0x0001 /* Port direction: Output */
#define PortFIn 0x0002 /* Port direction: Input */
#define PortFInOut 0x0003 /* Port direction: Bidir */
#define PortFTarget 0x0004 /* General purpose flag, use for Cone Extract */
#define PortFVisit 0x0008 /* Visit flag for processing */
#define PortFRed 0x0010 /* General purpose flag */
#define PortFGreen 0x0020 /* General purpose flag */
#define PortFBlue 0x0040 /* General purpose flag */
#define PortFYellow 0x0080 /* General purpose flag */
#define PortFNeg 0x0100 /* Primitive pin function: port is inverted */
#define PortFClk 0x0200 /* Primitive pin function: port is clocked */
#define PortFMultiGate 0x0400 /* Port is a multi gate */
#define PortFHide 0x0800 /* Primitive/module port is hidden in zdi.c */
#define PortFTop 0x1000 /* Display port at top */
#define PortFBot 0x2000 /* Display port at bottom */
#define PortFLeft 0x4000 /* Force port to left side */
#define PortFRight 0x8000 /* Force port to right side */
#define PortFTBLR (PortFTop|PortFBot|PortFLeft|PortFRight)
#define PortFAll 0xffff /* all bits set as error flags */
typedef unsigned short PortFlagsInternal;
/* Port has different power */
#define PortFInternalMixed 0x0001
/* Port has guessed power */
#define PortFInternalGuessed 0x0002
/* Port has IO set from -node */
#define PortFInternalIOSet 0x0004
/* Port has weak (e.g. diode) */
#define PortFInternalWeak 0x0008
/* Port has Power */
#define PortFInternalPower 0x0010
/* Port has Ground */
#define PortFInternalGround 0x0020
/* Port has NegPower */
#define PortFInternalNegPower 0x0040
/* Port is ignored in cone search */
#define PortFInternalConeIgn 0x0080
/* Port direction is define in a library */
#define PortFInternalFixedDirection 0x0100
#define PortFInternalPG (PortFInternalPower \
|PortFInternalGround \
|PortFInternalNegPower)
Cell Flags
typedef unsigned short CellFlags;
#define CellFModule 0x0001 /* This is a Module */
#define CellFTarget 0x0002 /* general purpose flag, use for Cone Extract */
#define CellFZombie 0x0004 /* This object is to be deleted */
#define CellFVisit 0x0008 /* Visit flag for processing */
#define CellFVisit2 0x0010 /* Visit flag for processing */
#define CellFVisit3 0x0020 /* Visit flag for processing */
#define CellFUndefined 0x0040 /* Is a blackbox instantiation */
#define CellFWeakFlow 0x0080 /* Set for Weakflow devices */
#define CellFFeedthru 0x0100 /* Nlview VdiInstFFeedthru */
#define CellFLibCell 0x0200 /* Cell is a Library Cell */
#define CellFClk 0x0400 /* Cell has a Clock-Port */
#define CellFModuleMem 0x0800 /* Remember original CellFModule flag */
#define CellFRed 0x1000 /* general purpose flag */
#define CellFGreen 0x2000 /* general purpose flag */
#define CellFBlue 0x4000 /* general purpose flag */
#define CellFYellow 0x8000 /* general purpose flag */
typedef unsigned short CellFlagsInternal;
/* `celldefine */
#define CellFInternalCelldefine 0x0001
/*The Cell is preloaded */
#define CellFInternalPreloaded 0x0002
/* Visit flag for processing */
#define CellFInternalVisit 0x0004
/* UserdefinedArcs are checked */
#define CellFInternalUserDefArcsChecked 0x0008
/* Auto generated cell */
#define CellFInternalAutoGen 0x0010
/* Generated in Lpe */
#define CellFInternalLpeParasitic 0x0020
/* Generated by spice */
#define CellFInternalCreatedBySpice 0x0040
/* Generated by symlib */
#define CellFInternalCreatedBySymlib 0x0080
/* Generated by zverilog */
#define CellFInternalCreatedByZverilog 0x0100
/* If cell is undefined and has generic port names */
#define CellFInternalUndefinedWithNamedPorts 0x0200
/* If cell is ignored in zwrite */
#define CellFInternalIgnoreInWrite 0x0400
/* Generated by Liberty */
#define CellFInternalCreatedByLiberty 0x0800
/* Exclude cell from cone extraction */
#define CellFInternalConeExtractExclude 0x8000
Module Flags
typedef unsigned short ModuleFlags;
#define ModuleFTop 0x0001 /* Top Module (topList) */
#define ModuleFParasitic 0x0002 /* Parasitic Module (parasiticTable)*/
#define ModuleFParasiticTop 0x0004 /* Parasitic Top Module. */
#define ModuleFQuick 0x0008 /* Quick Parser Mode. */
#define ModuleFAutoGen 0x0010 /* Auto-generated module */
#define ModuleFOperpp 0x0020 /* Created by operpp */
#define ModuleFOperGate 0x0040 /* Created by recognize gates */
#define ModuleFLeafCell 0x0080 /* Treated module as a primitive */
#define ModuleFParasiticHier 0x0100 /* Para-Module for hierarchical net */
#define ModuleFParasiticParent 0x0200 /* Para-Module for parent hier net */
#define ModuleFParasiticNeedRename 0x0400 /* Parasitic Module need rename */
#define ModuleFParasiticProcess 0x0800 /* Parasitic Module need processing */
#define ModuleFParasiticComplete 0x1000 /* Para Module is filled/processed */
#define ModuleFGroupPorts 0x2000 /* @group attribute set at ports */
#define ModuleFInvisible 0x4000 /* Hide the module in the Tcl API */
#define ModuleFPreplace 0x8000 /* Module instances have @X/@y */
typedef unsigned short ModuleFlagsInternal;
#define ModuleFInternalTopCandidate 0x0001 /* Top Candidate */
#define ModuleFInternalGuessedTop 0x0002 /* Guessed Top Module */
#define ModuleFInternalIgnoreContentInWrite 0x0004 /* Ignore Content in zWrite*/
#define ModuleFInternalContentNotPopulated 0x0008 /* Contents is not populated*/
#define ModuleFInternalFlatNotPopulated 0x0010 /* Contents is not populated*/
Instance Flags
typedef unsigned short InstFlags;
#define InstFAutoGen 0x0001 /* Is an auto generated instance */
#define InstFTarget 0x0002 /* Cone Extraction target */
#define InstFZombie 0x0004 /* This object is to be deleted */
#define InstFVisit 0x0008 /* Visit flag for processing */
#define InstFCouplLocal 0x0010 /* Coupling local */
#define InstFCouplExtern 0x0020 /* Coupling external */
#define InstFTreeGroup 0x0040 /* Flag to group instances in tree */
#define InstFWeakFlow 0x0080 /* Set for Weakflow devices */
#define InstFRed 0x1000 /* general purpose flag */
#define InstFGreen 0x2000 /* general purpose flag */
#define InstFBlue 0x4000 /* general purpose flag */
#define InstFYellow 0x8000 /* general purpose flag */
typedef unsigned short InstFlagsInternal;
/* Set if attributes were modified */
#define InstFInternalAttrMod 0x01
/* Internal general purpose flag */
#define InstFInternalVisit 0x02
/* Ignore instance in zdi (ictrl). */
#define InstFInternalIgnore 0x04
/* Set the unfold flag is zdi. */
#define InstFInternalUnfold 0x08
/* Internal general purpose flag */
#define InstFInternalVisit2 0x10
/* Internal pfilter shorten flag */
#define InstFInternalPFilterShorten 0x20
/* Internal pfilter remove flag */
#define InstFInternalPFilterRemove 0x40
Net Flags
typedef unsigned short NetFlags;
#define NetFMember 0x0001 /* This net is a subnet member of a NetBus */
#define NetFGlobal 0x0002 /* Global Net, connectivity by name */
#define NetFZombie 0x0004 /* This object is to be deleted */
#define NetFVisit 0x0008 /* Visit flag for processing */
#define NetFPower 0x0010 /* Power Net */
#define NetFGround 0x0020 /* Ground Net */
#define NetFNegPower 0x0040 /* Negative Power Net */
#define NetFPG (NetFPower \
|NetFGround \
|NetFNegPower) /* Net is either power, ground or negpower */
#define NetFVisit2 0x0080 /* Visit flag for processing */
#define NetFVisit3 0x0100 /* Visit flag for processing */
#define NetFAutoGen 0x0200 /* Is an auto generated net */
#define NetFHide 0x0400 /* Hide net */
#define NetFTarget 0x0800 /* Cone Extraction target */
#define NetFRed 0x1000 /* general purpose flag */
#define NetFGreen 0x2000 /* general purpose flag */
#define NetFBlue 0x4000 /* general purpose flag */
#define NetFYellow 0x8000 /* general purpose flag */
typedef unsigned short NetFlagsInternal;
/* Net is a potential power. */
#define NetFInternalPotentialPower 0x0001
/* Net is a potential ground. */
#define NetFInternalPotentialGround 0x0002
/* Ignore net in zdi (ictrl). */
#define NetFInternalIgnore 0x0004
/* Mark OOM nets. */
#define NetFInternalOOMNet 0x0008
/* Don't route in schematic. */
#define NetFInternalConnectByName 0x0010
/* Defined as wire in Verilog. */
#define NetFInternalWire 0x0020
/* All bus members are one-to-one connected. */
#define NetFInternalNetBusWideConnection 0x0040
Constant Net Values
enum zNetValue {
NetVUndef = 0,
NetV0 = 1,
NetVGround = 1,
NetV1 = 2,
NetVPower = 2,
NetVZ = 3,
NetVX = 4,
NetVNeg = 5,
NetBusVSet = 6
};
Primitive Level Flags
typedef unsigned short PrimitiveLevel;
#define PrimitiveLevelDefault 0x01 /* Only Primitive types are prim */
#define PrimitiveLevelOperator 0x02 /* Cells with a known function are prim */
#define PrimitiveLevelLibCell 0x04 /* Cells flagged as library cells are prim*/
#define PrimitiveLevelSymbol 0x08 /* Cells with @symbol attr are primitive */
#define PrimitiveLevelFlagged 0x10 /* Modules with flag leafcell are prim */
#define PrimitiveLevelCelldefine 0x20 /* Modules inside `celldefine are prim */
Instance Orientation
enum zOrientation {
OrientFR0,
OrientFR90,
OrientFR180,
OrientFR270,
OrientFMY,
OrientFMYR90,
OrientFMX,
OrientFMXR90
};
Database Flags
typedef unsigned short DBFlags;
#define DBFPreplace 0x0001 /* Preplace info exists */
#define DBFTopUnused 0x0002 /* DB has unused top modules */
#define DBFTopGuessed 0x0004 /* DB has guessed top modules */
zFlagObjType
enum zFlagObjType {
FlagObjCell = 0,
FlagObjMod = 1,
FlagObjInst = 2,
FlagObjNet = 3,
FlagObjPort = 4,
FlagObjPin = 5,
FlagObjDB = 6,
FlagObjVirtual = 7
};
Highlight Colors
Highlight Color Info Struct
typedef struct HiCol {
unsigned char norm; /* Normal highlight color. */
unsigned char perm; /* Permanent highlight color. */
} HiCol;
Object Definition Structures
Definition of a Single Bit Interface Port
typedef struct Port {
char* name; /* Port name */
struct Net* net; /* Inside net or NULL (Module Ports only)*/
char** attrList; /* Dynamic list of name=value attributes */
int* arcList; /* List of arcs for cone extraction */
struct Spos* spos; /* Pointer to first Spos or NULL */
int busMember; /* Member of PortBus or -1 */
PortFlags flags; /* Port direction and other flags */
HiCol hicol; /* Highlight Color */
PortFlagsInternal internalFlags; /* Internal Port Flags */
char unused[6];
} Port;
Definition of an Interface PortBus
A PortBus is a group of Ports.
typedef struct PortBus {
char* name; /* PortBus name */
char** attrList; /* Dynamic list of name=value attributes */
struct Spos* spos; /* pointer to first Spos or NULL */
int rangestart; /* range index at Cell.portList[first] */
int first; /* First Member: Cell.portList[first] (LSB) */
int width; /* Bus width: members [first...first+width) */
PortFlags flags; /* Port direction and other flags */
HiCol hicol; /* Highlight Color */
signed char rangedir; /* range direction: 0=off 1=ascent -1=descent */
char unused[7];
} PortBus;
Definition of a Cell Object
typedef struct Cell {
char* name; /* Cell name */
Port* portList; /* List of single bit Ports - ordered */
PortBus* portBusList; /* List of PortBus - ordered, or NULL */
char** attrList; /* Dynamic list of name=value attributes */
struct Spos* spos; /* pointer to first Spos or NULL */
HashTable portTable; /* String HashTable for Ports */
int refCount; /* Number of referencing instances */
PrimitiveFunc func; /* Cell function */
CellFlags flags; /* Cell Flags */
CellFlagsInternal internalFlags; /* Internal use only (no Tcl API) */
HiCol hicol; /* Highlight Color */
char unused[2];
} Cell;
Definition of a Primitive
typedef struct Primitive {
Cell c; /* Is a Cell */
} Primitive;
Definition of a Module
typedef struct Module {
Cell c; /* Is a Cell */
struct Inst** instList; /* Dynamic list of Instances */
struct Net** netList; /* Dynamic list of Nets */
struct NetBus** netBusList; /* Dynamic list of Buses */
struct FTopNode* topNode; /* ptr to top flat node */
HashTable instTable; /* String HashTable for Instances */
HashTable netTable; /* String HashTable for Nets */
HashTable nbusTable; /* String HashTable for Buses */
char* schematicCache; /* Store schematic layout information */
ModuleFlags mflags; /* Flags in addition to c.flags */
ModuleFlagsInternal internalFlags; /* Internal module Flags */
char unused[4];
} Module;
Pin Flags
typedef unsigned short PinFlags;
#define PinFTarget 0x0004 /* General purpose flag, use for Cone Extract */
#define PinFVisit 0x0008 /* Visit flag for processing */
#define PinFRed 0x0010 /* General purpose flag */
#define PinFGreen 0x0020 /* General purpose flag */
#define PinFBlue 0x0040 /* General purpose flag */
#define PinFYellow 0x0080 /* General purpose flag */
#define PinFHide 0x0800 /* Primitive/module pin is hidden in zdi.c */
typedef unsigned char PinFlagsInternal;
#define PinFInternalOOMR 0x01 /* Pin has OOMR connected in some hierarchy */
#define PinFInternalAutoGen 0x02 /* Pin is auto generated (not in netlist) */
Definition of Instance Pins
The instance pins refer to the Cell pins in the same order.
typedef struct Pin { /* Single Bit Pin */
struct Net* net; /* connected Net - may be NULL if unconnected */
struct Spos* spos; /* pointer to first Spos or NULL */
char** attrList; /* Dynamic list of name=value attributes */
HiCol hicol; /* Highlight Color */
PinFlags flags; /* Pin flags */
PinFlags internalFlags; /* Internal Pin flags */
char unused[2];
} Pin;
Definition of an Instance Object
typedef struct Inst {
char* name; /* Instance name */
Cell* cellRef; /* Instance cell interface */
char** attrList; /* Dynamic list of name=value attributes */
struct Spos* spos; /* pointer to first Spos or NULL */
HiCol hicol; /* Highlight Color */
InstFlags flags; /* Instance Flags */
InstFlagsInternal internalFlags; /* Internal Instance flags */
unsigned short orient:3; /* enum zOrientation for VdiInstOrientMask */
unsigned short unused:13;
Pin pin[1]; /* ordered list of Pins */
} Inst;
Definition of Net Connectivity
The Net’s pinRefList refers to instance pins or to this module’s Ports (if PinRef.inst == NULL).
typedef struct PinRef { /* Reference to an inst Pin */
Inst* inst; /* Pointer to the instance or NULL */
int pinNo; /* inst->pin[pinNo] or Cell.portList[pinNo] */
char unused[4];
} PinRef;
Definition of a Net Object
typedef struct Net {
char* name; /* Net name */
PinRef* pinRefList; /* Dynamic list defines Connectivity */
char** attrList; /* Dynamic list of name=value attributes */
struct Spos* spos; /* pointer to first Spos or NULL */
zInt32 busMember; /* Member of NetBus or -1 */
HiCol hicol; /* Highlight Color */
NetFlagsInternal internalFlags; /* Internally used net flags. */
NetFlags flags; /* Net type and other flags */
char value; /* Value of the net */
char unused[5];
} Net;
Definition of a NetBus Object
typedef struct NetBus {
char* name; /* NetBus name */
Net** subnetList; /* SubNets (LSB first) may contain NULL nets */
char** attrList; /* Dynamic list of name=value attributes */
struct Spos* spos; /* pointer to first Spos or NULL */
int rangestart; /* range index at subnetList[0] */
NetFlags flags; /* Net type and other flags */
NetFlagsInternal internalFlags; /* Internally used netBus flags. */
signed char rangedir; /* range direction: 0=off 1=ascent -1=descent */
char value; /* Value of the netBus */
HiCol hicol; /* Highlight Color */
char unused[4];
} NetBus;
Definition of a VirtualObject
typedef unsigned short VirtualFlags;
#define VirtualFZombie 0x0004 /* This object is to be deleted */
typedef enum zVirtualObjectType {
VIRTUALOBJECT_NONE = 0,
VIRTUALOBJECT_MACRO = 1,
VIRTUALOBJECT_PARAMETER = 2,
VIRTUALOBJECT_MACRO_DEF = 3,
VIRTUALOBJECT_MACRO_REF = 4,
VIRTUALOBJECT_TASK = 5,
VIRTUALOBJECT_FUNCTION = 6,
VIRTUALOBJECT_WDB_VAR_ID = 7,
VIRTUALOBJECT_INVALID = 8
} zVirtualObjectType;
zVirtualObjectType zVirtualObject_str2type(const char* str, zBool icase);
const char* zVirtualObject_type2str(zVirtualObjectType type);
typedef struct VirtualObject {
char* name; /* VirtualObject name */
char** attrList; /* Dynamic list of name=value attributes */
struct Spos* spos; /* pointer to first Spos or NULL */
zVirtualObjectType type; /* Type */
VirtualFlags flags;
HiCol hicol; /* Highlight Color */
} VirtualObject;
Forward Definition of OIDs
OIDs do not resist in DB memory.
struct OID;
struct OIDMemBlock;
struct OIDMemory {
struct OIDMemBlock* blk;
struct OID* free;
int blkCount;
int freeCount;
};
Definition of the Database Hooks
typedef struct Hooks {
struct FlatCache* flatCache; /* for flat node cache */
struct TNode* tree;
struct OIDMemory oid;
struct Efile** efileList;
char* sposBase; /* zSposNewFile noconvert=zTrue */
char* binfileName; /* Name of the binfile. */
struct PopulateInfo* populateInfo;
struct ParasiticInfo* parasiticInfo;
zBool debugMem;
zBool debugMemSize;
zBool debugMemFreeList;
zBool useTree;
zBool legacyBinfile;
} Hooks;
Definition of the Database Root
typedef struct DB {
struct Strmem* strmem;
Cell** cellList; /* Dynamic list of Cells */
Module** topList; /* Dynamic list of Top modules or NULL */
Module** savedTopList; /* Dynamic list of Top modules or NULL */
HashTable cellTable; /* String HashTable for Cell namespace */
HashTable parasiticTable; /* Str HashTable for parasitic Modules */
HashTable virtualObjectTable; /* Hash table of virtual objects */
struct Sfile** sfileList; /* Dynamic list of Sfiles or NULL */
char** attrList; /* List of name=value attributes */
struct Symlib* symlibs; /* list of symlibs */
HashTable symdefTable; /* Str HashTable for port/pgnet symdef */
int parserBits; /* each used parser sets bits */
DBFlags flags; /* DB Flags */
char hiersep; /* usable hierarchy separator character*/
char internalHierSep;
Hooks hooks; /* DB hooks must be at the end of DB */
} DB;
Database Hash Table Implementation
Each HashTable struct must get initialized by zTableInit() before it can be used. A hash table stores key-value pairs. Currently, STRING and PTR are supported as hash-keys but anything can be added in future. The valueSize argument defines the number of bytes of the hash-value.
For STRING hash-key: the key "const char*" points to a zero-terminated string; that must be non-volatile memory if given to zTableInsert(). For PTR hash-key: the key "const char*" is used as "void*" and is not de-referenced (just the pointer value is used).
The zTableIgnoreCase() has only effect on STRING and ICASE Tables; those Tables are switched from STRING to ICASE and back. This only affects the behavior of zTableFind()
not the behavior of zTableInsert() and zTableRemoveObj().
zTableRemoveObj() removes the entry with identical key and identical value.
zTableInit
void zTableInit(
DB*,
HashTable*,
int valueSize,
HashKeyType
);
zTableAlloc
void zTableAlloc(
DB*,
HashTable*,
int nBuckets
);
zTableFree
void zTableFree(
DB*,
HashTable*
);
zTableInsert
void zTableInsert(
DB*,
HashTable*,
const char* key,
const void* valuePtr
);
zTableFind
zBool zTableFind(
DB*,
HashTable*,
const char* key,
void* valuePtr_return
);
zTableRemoveObj
zBool zTableRemoveObj(
DB*,
HashTable*,
const char* key,
const void* valuePtr
);
zTableIgnoreCase
void zTableIgnoreCase(
DB*,
HashTable*,
zBool icase
);
Database Hash Table Iterator
zIterInit
void zIterInit(
HashIter*,
HashTable*
);
zIterMore
zBool zIterMore(
HashIter*
);
zIterNext
zBool zIterNext(
HashIter*
);
zIterKey
void zIterKey(
HashIter*,
const char** keyPtr_return
);
zIterValue
void zIterValue(
HashIter*,
void* valPtr_return
);
Database Service and Access Function
zUniqueName
Append _%d at the end of the given name and repeats incrementing until this name is unique in the given hash table.
const char* zUniqueName(
DB*,
HashTable*,
const char* name,
char* buf,
int maxlen,
zBool icase
);
zUniqueNameAlloc
If 'name' is unique in the hash table, NULL is returned, otherwise a new unique string is returned, which must be 'zFree’d by the caller.
char* zUniqueNameAlloc(
DB*,
HashTable*,
const char* name,
zBool icase
);
zIdenticalInterface
Test if the interface of two given Cells is identical. If icase is zTrue, then the port names are compared using zStrcasecmp.
zBool zIdenticalInterface(
Cell* oldCell,
Cell* newCell,
zBool icase
);
zSimilarInterface
Test if the interface of two given Cells is identical. If icase is zTrue, then the port names are compared using zStrcasecmp. Ports at oldCell will match portBusses on newCell.
zBool zSimilarInterface(
DB* db,
Cell* oldCell,
Cell* newCell,
zBool icase
);
zModifyFlags
Modify the given flag at all database objects, mode can be: 0 set 1 clear flagsToModify are in the same order as enum zFlagObjType.
typedef enum zModifyFlags_Mode {
ZMODIFYFLAGS_MODE_SET=0,
ZMODIFYFLAGS_MODE_CLEAR=1
} zModifyFlags_Mode;
zBool zModifyFlags(
DB* db,
unsigned flagsToModify[8],
int mode,
zBool procModule,
zBool procPrimitive,
zBool procInst,
zBool procNet,
zBool procNetBus,
zBool procPort,
zBool procPortBus,
zBool procPin,
zBool procVirtual
);
zStr2Flag
Get flag bit for given string.
zBool zStr2Flag(
enum zFlagObjType type,
const char* name,
unsigned short* flagsPtr,
unsigned short* iflagsPtr,
unsigned short* mflagsPtr,
unsigned short* miflagsPtr
);
zFlag2Str
Get string list from bits.
int zFlag2Str(
enum zFlagObjType type,
unsigned short flags,
unsigned short iflag,
unsigned short mflags,
unsigned short miflags,
const char** strs,
unsigned maxStrs
);
zFlag2Dump
Get string list from bits for dump.
int zFlag2Dump(
enum zFlagObjType type,
unsigned short flags,
unsigned short iflag,
unsigned short mflags,
unsigned short miflags,
const char** strs,
unsigned maxStrs
);
zGetVersion
Return zdb version string.
void zGetVersion(
char[512],
const char* what
);
zGetMemoryUsage
Return memory usage in given buf (human readable).
void zGetMemoryUsage(
DB* db,
char sep,
char buf[800]
);
zIsEmpty
Check if a cell refers to an empty module.
zBool zIsEmpty(
Cell* cell,
zBool checkDanglingNets,
zBool checkZombie
);
zCellIsModule
Check if a given cell is a module.
#define zCellIsModule(cell) \
((cell)->flags & CellFModule)
zCellIsModuleMem
Check if a given cell originally is a module.
#define zCellIsModuleMem(cell) \
((cell)->flags & CellFModuleMem)
zCellIsPrimitive
Check if a given cell is a primitive.
#define zCellIsPrimitive(cell) \
(!((cell)->flags & CellFModule))
zCellIsPrimitiveMem
Check if a given cell originally is a primitive.
#define zCellIsPrimitiveMem(cell) \
(!((cell)->flags & CellFModuleMem))
zCellIsParasitic
Check if a given cell is a parasitic module.
#define zCellIsParasitic(cell) \
(zCellIsModule(cell) && (((Module*)(cell))->mflags & ModuleFParasitic))
zModuleIsTop
Check if a given module is a top module.
#define zModuleIsTop(mod) \
((mod)->mflags & ModuleFTop)
PINCOUNT
Get the number of instance pins.
#define PINCOUNT(inst) \
LISTLEN((inst)->cellRef->portList)
Create and Access Database Objects
Many functions below accept a const char* (const char*) for the object name that can point to volatile memory (like stack memory). The zNew functions internally allocate private memory and copy the name.
Those functions that return a pointer to a DB object may return NULL to indicate an error. In that case, the error message is stored in zLastErrorMsg (see zerror.h).
The functions zNewPort and zSearchPort return the index into the cell’s portList, or -1 to indicate an error (message in zLastErrorMsg). The Function zNewPortBus return the index into the cell’s portBusList, or -1 to indicate an error (message in zLastErrorMsg).
The zBool-returning functions return zTrue in case of success or zFalse in case of an error (message in zLastErrorMsg).
zNewModule
Module* zNewModule(
DB*,
const char* name
);
zTopModule
zBool zTopModule(
DB*,
Module* mod
);
zUnsetTopModule
zBool zUnsetTopModule(
DB*,
Module* mod
);
zIsTmpTop
Check if tmp top is used.
zBool zIsTmpTop(
DB*
);
zUnusedTopCandidates
zBool zUnusedTopCandidates(
DB*
);
zGuessedTopModules
zBool zGuessedTopModules(
DB*
);
zNewPrimitive
Primitive* zNewPrimitive(
DB*,
const char* name,
PrimitiveFunc func
);
zSetPrimitives
void zSetPrimitives(
DB*,
PrimitiveLevel level
);
zSearchCell
Cell* zSearchCell(
DB*,
const char* name,
zBool icase,
zBool errMsg
);
zSearchTopModule
Module* zSearchTopModule(
DB*,
const char* name,
zBool icase,
zBool errMsg
);
zRenameCell
void zRenameCell(
DB*,
Cell*,
const char* name
);
zDeleteCell
void zDeleteCell(
DB*,
Cell*
);
zNewParasitic
Module* zNewParasitic(
DB*,
const char* name
);
zSearchParasitic
Module* zSearchParasitic(
DB*,
const char* name,
zBool icase,
zBool errMsg
);
zRenameParasitic
void zRenameParasitic(
DB*,
Module* para,
const char* name
);
zDeleteParasitic
void zDeleteParasitic(
DB*,
Module*
);
zIsParasiticModInst
zBool zIsParasiticModInst(
Inst*
);
zIsCouplingParasiticPort
zBool zIsCouplingParasiticPort(
Module* parasitic,
int portNo
);
zIsCouplingParasiticInst
zBool zIsCouplingParasiticInst(
Inst* inst,
zBool local
);
zNewInst
Inst* zNewInst(
DB*,
Module*,
const char* name,
Cell* cellRef
);
zNewInstByIndex
Inst* zNewInstByIndex(
DB*,
Module*,
const char* name,
unsigned index,
Cell* cellRef
);
zSearchInst
Inst* zSearchInst(
DB*,
Module*,
const char* name,
zBool icase,
zBool errMsg
);
zRenameInst
void zRenameInst(
DB*,
Module*,
Inst*,
const char* name
);
zDeleteLastInst
zBool zDeleteLastInst(
DB*,
Module*,
Inst*
);
zInstSetXY
void zInstSetXY(
DB*,
Module*,
Inst*,
const char* x,
const char* y
);
zNewNet
Net* zNewNet(
DB*,
Module*,
const char* name
);
zNewNetBus
NetBus* zNewNetBus(
DB*,
Module*,
const char* name,
int width
);
zSearchNet
Net* zSearchNet(
DB*,
Module*,
const char* name,
zBool icase,
zBool errMsg
);
zSearchNetBus
NetBus* zSearchNetBus(
DB*,
Module*,
const char* name,
zBool icase,
zBool errMsg
);
zRenameNet
void zRenameNet(
DB*,
Module*,
Net*,
const char* name
);
zRenameNetBus
void zRenameNetBus(
DB*,
Module*,
NetBus*,
const char* name
);
zNewPort
int zNewPort(
DB*,
Cell*,
const char* name,
PortFlags dir
);
zNewPortBus
int zNewPortBus(
DB*,
Cell*,
const char* name,
PortFlags dir
);
zSearchPort
int zSearchPort(
DB*,
Cell*,
const char* name,
zBool icase,
zBool errMsg
);
zSearchPortEscapedName
int zSearchPortEscapedName(
DB*,
Cell*,
const char* name,
zBool icase,
zBool errMsg
);
zSearchPortBus
int zSearchPortBus(
DB*,
Cell*,
const char* name,
zBool icase,
zBool errMsg
);
zSearchPortBusEscapedName
int zSearchPortBusEscapedName(
DB*,
Cell*,
const char* name,
zBool icase,
zBool errMsg
);
zRenamePort
void zRenamePort(
DB*,
Cell*,
Port*,
const char* name
);
zRenamePortBus
void zRenamePortBus(
DB*,
Cell*,
PortBus*,
const char* name
);
zNewAttribute
char* zNewAttribute(
DB*,
char*** attrListPtr,
const char* nameValue
);
zNewAttributeChk
char* zNewAttributeChk(
DB* db,
char*** attrListPtr,
const char* nameValue
);
zNewAttributeNv
char* zNewAttributeNv(
DB*,
char*** attrListPtr,
const char* name,
const char* val
);
zSetAttribute
char* zSetAttribute(
DB*,
char*** attrListPtr,
const char* nameValue,
zBool ic
);
zSetAttributeNv
char* zSetAttributeNv(
DB* db,
char*** attrListPtr,
const char* name,
const char* value,
zBool icase
);
zDeleteAttribute
void zDeleteAttribute(
DB*,
char** attrList,
const char* name,
zBool ic
);
zSearchAttributeValue
char* zSearchAttributeValue(
DB*,
char** attrList,
const char* name,
zBool ic
);
zSearchAttributeValues
const char** zSearchAttributeValues(
DB*,
char** attrList,
const char* name,
zBool ic
);
zSetAttributeList
void zSetAttributeList(
DB*,
char*** destListPtr,
char** srcList
);
zSetSchematicCache
void zSetSchematicCache(Module* module, const char* schematicLayout);
zGetSchematicCache
const char* zGetSchematicCache(Module* module);
zClearSchematicCache
void zClearSchematicCache(DB* db, Module* module);
zDeleteHilight
void zDeleteHilight(
DB*,
int col,
int permanent
);
zNewPinRef
zBool zNewPinRef(
DB*,
Net*,
Inst*,
int pinNo
);
zNewPortRef
zBool zNewPortRef(
DB*,
Net*,
Cell*,
int portNo
);
zNewNetBusMember
zBool zNewNetBusMember(
DB*,
Module*,
NetBus*,
Net* subnet
);
zNewNetBusMemberByIndex
zBool zNewNetBusMemberByIndex(
DB*,
Module*,
int busIndex,
Net* subnet
);
zValidateNetBus
zBool zValidateNetBus(
DB*,
Module*,
NetBus*,
int width
);
zNewPortBusMember
zBool zNewPortBusMember(
DB*,
Cell*,
int portBusNo,
int portNo
);
zValidatePortBus
zBool zValidatePortBus(
DB*,
Cell*,
int portBusNo,
int width
);
zNewVirtualObject
VirtualObject* zNewVirtualObject(
DB* db,
const char* name,
zVirtualObjectType type
);
zDeleteVirtualObject
void zDeleteVirtualObject(
DB* db,
VirtualObject* obj
);
zSearchVirtualObject
VirtualObject* zSearchVirtualObject(
DB* db,
const char* name,
zBool icase,
zBool errMsg
);
zDefineNetBusRange
Define a bus range like [31:0].
void zDefineNetBusRange(
NetBus*,
int from,
int to
);
zDefinePortBusRange
Define a bus range like [31:0].
void zDefinePortBusRange(
PortBus*,
int from,
int to
);
zUndefineNetBusRange
Remove bus range.
void zUndefineNetBusRange(
NetBus*
);
zUndefinePortBusRange
Remove bus range.
void zUndefinePortBusRange(
PortBus*
);
zHasNetBusRange
Return zTrue if a range is defined.
zBool zHasNetBusRange(
NetBus*,
int* from,
int* to
);
zHasPortBusRange
Return zTrue if a range is defined.
zBool zHasPortBusRange(
PortBus*,
int* from,
int* to
);
zGetSubnetByRangeIdx
Get a member by range index.
zBool zGetSubnetByRangeIdx(
NetBus*,
int idx,
Net** net
);
zGetSubportByRangeIdx
Get a member by range index.
zBool zGetSubportByRangeIdx(
Cell* cell,
int portBus,
int rangeIdx,
Port** port
);
zValidateNetBusRange
Validate the bus range information.
zBool zValidateNetBusRange(
Cell*,
NetBus*
);
zValidatePortBusRange
Validate the bus range information. Checks the bus range info if defined: The member names must comply with the Verilog/VHDL member naming rules. Example: bus name: DATA bus range from: 31 (MSB) bus range to: 8 (LSB) member names: DATA[31], DATA[30], …, DATA[0]
zBool zValidatePortBusRange(
Cell* cell,
int portBusNo
);
zBusOfNet
NetBus* zBusOfNet(
Module*,
Net*
);
zOneToOneBusConnection
zBool zOneToOneBusConnection(
NetBus* netBus,
Module* mod,
Inst* inst,
int busNo,
zBool checkSequence
);
zCheckRangeName
zBool zCheckRangeName(
Cell*,
const char*,
const char*,
int
);
Symbol Definitions
The functions below manage the symdefTable needed for graphical port and pg symbols. And symioList used for the mapping information.
zSetSymdef
Add/overwrite a symdef entry
void zSetSymdef(
DB* db,
const char* name,
const char* def
);
zGetSymdef
Return symdef entry or NULL
char* zGetSymdef(
DB* db,
const char* name
);
zDeleteSymdef
Remove symdef entry
void zDeleteSymdef(
DB* db,
const char* name
);
Delete Contents of Database
zDeleteContentsOfDataBase
Delete all objects (called from zCloseDataBase).
void zDeleteContentsOfDataBase(
DB* db
);
zDeleteContentsOfModule
Delete all inst/net/netBundle in a Module.
void zDeleteContentsOfModule(
DB* db,
Module* module
);
zDeleteContentsOfModulePreserveHierInsts
Like zDeleteContentsOfModule but preserves hierarchical instances.
void zDeleteContentsOfModulePreserveHierInsts(
DB* db,
Module* module
);
zDeleteZombies
Delete those objects with the Zombie flag.
void zDeleteZombies(
DB* db
);
zDeleteAllButFlat
Delete all expect top module and it’s flat info.
void zDeleteAllButFlat(
DB* db
);
zDeleteZombiesInModule
Delete those inst/net/netBundle with Zombie flag.
void zDeleteZombiesInModule(
DB* db,
Module* module
);
zDeleteZombieModules
Delete those modules with the Zombie flag.
void zDeleteZombieModules(
DB* db
);
zInvalidateAll
Is initially NULL but can be set to a callback functions to get called back before database objects go away.
extern void (*zInvalidateAll)(
DB* db
);
zInvalidateZombies
Is initially NULL but can be set to a callback functions to get called back before database objects go away.
extern void (*zInvalidateZombies)(
DB* db
);
zCellPointerIsEqual
Compare two cells pointer.
zBool zCellPointerIsEqual(
Cell* cell1,
Cell* cell2
);
zModulePointerIsEqual
Compare two module pointer.
zBool zModulePointerIsEqual(
Module* module1,
Module* module2
);
zNetPointerIsEqual
Compare two net pointer.
zBool zNetPointerIsEqual(
Net* net1,
Net* net2
);
zInstPointerIsEqual
Compare two inst pointer.
zBool zInstPointerIsEqual(
Inst* inst1,
Inst* inst2
);
zOppositeDir
return the opposite port/pin direction
PortFlags zOppositeDir(
PortFlags dir
);
zDir2Str
return string for given direction flags.
const char* zDir2Str(
PortFlags dir
);
zGetOriginalName
Get the original name of the given cell. Return NULL if the original name is not known.
char* zGetOriginalName(
DB* db,
Cell* cell
);
zIdenticalInterfaceIgnoreMemberBrackets
Test if the interface of two given Cells is identical. If icase is zTrue, then the port names are compared using zStrcasecmp. Differences in '<','[' and '>', ']' are ignored.
zBool zIdenticalInterfaceIgnoreMemberBrackets(
Cell* oldCell,
Cell* newCell,
zBool icase
);
zSearchPortEscapedNameIgnoreMemberBrackets
int zSearchPortEscapedNameIgnoreMemberBrackets(
DB*,
Cell*,
const char* name,
zBool icase,
zBool errMsg
);
zSearchPortBusEscapedNameIgnoreMemberBrackets
int zSearchPortBusEscapedNameIgnoreMemberBrackets(
DB*,
Cell*,
const char* name,
zBool icase,
zBool errMsg
);
The Database Memory Manager
Create and Open a Database
zNewDataBase
Create a new database.
#define zNewDataBase() \
zNewDataBase_(BINFILE_VERSION_MAJOR, BINFILE_VERSION_MINOR)
zNewDataBase_
Do not use directly, use zNewDataBase instead.
DB* zNewDataBase_(
int major,
int minor
);
zOpenDataBase
open an existing database - binfile : name of the existing db file
#define zOpenDataBase(binfile) \
zOpenDataBase_(binfile, zFalse, BINFILE_VERSION_MAJOR, \
BINFILE_VERSION_MINOR)
zOpenDataBase_
Do not use directly, use a zOpenDataBase* function instead.
DB* zOpenDataBase_(
const char* binfile,
zBool quick,
int major,
int minor
);
zCheckDataBase
Check the binfile for correct structure. Return zFalse (and set zLastErrorMsg) on error.
zBool zCheckDataBase(
const char* binfile
);
zFileInfoDataBase
Print file header infos from given binfile into buffer.
zBool zFileInfoDataBase(
const char* binfile,
char* buffer,
int sizeofbuffer
);
zParserBitsDataBase
Return parser bits from Binfile header.
int zParserBitsDataBase(
const char* binfile
);
zCloseDataBase
Close database and free all memory. Return zFalse (and set zLastErrorMsg) on errors.
zBool zCloseDataBase(
DB* db
);
zSaveDataBase
Write database to binfile. Return zFalse (and set zLastErrorMsg) on error.
zBool zSaveDataBase(
DB* db,
const char* binfile
);
zSaveDataBaseCompact
Write database to compact binfile.
#define zSaveDataBaseCompact(db, binfile) zSaveDataBase(db, binfile)
Memory Allocation
zAllocDB
Allocate cleared memory.
void* zAllocDB(
DB* db,
zULong size
);
zMallocDB
Allocate memory.
void* zMallocDB(
DB* db,
zULong size
);
zFreeDB
Return memory chunk to free-list.
void zFreeDB(
DB* db,
void* chunk
);
zReallocDB
Reallocate larger memory chunk
void* zReallocDB(
DB* db,
void* chunk,
zULong size
);
zReallocDynamicDB
Reallocate memory chunk with best size.
void* zReallocDynamicDB(
DB* db,
zULong* sizePtr,
zULong incr_size,
void* chunk
);
zStrAllocDB
Allocate string memory.
char* zStrAllocDB(
DB* db,
const char* name
);
zStrFreeDB
Not implemented.
#define zStrFreeDB(DB, STR) UNUSED(db) /* noop */
zStrFreeAllDB
Free all string memory.
void zStrFreeAllDB(
DB* db
);
zStrmemAllocLenDB
Allocate string memory with the given length.
char* zStrmemAllocLenDB(
DB* db,
struct Strmem** strmemPtr,
unsigned len
);
zStrmemFreeAllDB
Free all string memory.
void zStrmemFreeAllDB(
DB*,
struct Strmem**
);
zStrmemMemoryUsage
Return used string memory.
zULong zStrmemMemoryUsage(
struct Strmem*,
unsigned* cnt
);
The Database Primitive Function Definition
Access Primitive Functions
Port Functions
Enumeration iof named port functions.
typedef enum PortFunc {
PortFuncBAD, /* Used to identify errors. */
PortFuncSELECT, /* Select port (MUX, SELECTOR) */
PortFuncSET, /* Set port (DFF, LATCH) */
PortFuncRESET, /* Reset port (DFF, LATCH) */
PortFuncCLOCK, /* Clock port (DFF) */
PortFuncENABLE, /* Enable port (LATCH) */
PortFuncDRAIN, /* Drain port (PMOS,NMOS) */
PortFuncGATE, /* Gate port (PMOS,NMOS) */
PortFuncSOURCE, /* Source port (PMOS,NMOS) */
PortFuncBULK, /* Bulk port (PMOS,NMOS,NPN,PNP,DIODE,ZDIODE, */
/* RES,CAP) */
PortFuncCOLLECTOR, /* Collector port (NPN,PNP) */
PortFuncBASE, /* Base port (NPN,PNP) */
PortFuncEMITTER, /* Emitter port (NPN,PNP) */
PortFuncANODE, /* Anode port (DIODE,ZDIODE) */
PortFuncCATHODE, /* Cathode port (DIODE,ZDIODE) */
PortFuncPLUS, /* Plus port (CAP) */
PortFuncMINUS, /* Minus port (CAP) */
PortFuncONE, /* First port (RES) */
PortFuncTWO, /* Second port (RES) */
} PortFunc;
CheckPortFunc
check or fix port direction flags. In full mode (mode=0), this procedure performs a full check of the cell interface (all ports and portBuses) concerning the port order, the direction flags, the PortFNeg flag and the bus widths.
In building-mode (mode=1 or 2), this function is assumed to be called after each Port (mode=1) or PortBus (mode=2) is completely added to the cell interface. If the last port/portBus has PortFUnknown direction, then the direction is FIXED (no error). However, if a direction is set, then it is checked and an error may be returned. In building-mode only some checks are performed.
The cell’s PrimitiveFunc defines the function of the ports/portBuses by the port order. The docs at doc/api/tprim.html define details.
It returns zTrue in case of success or zFalse in case of an error (message in zLastErrorMsg).
zBool zCheckPortFunc(
Cell* cell,
int mode
);
GetOrderNo
Return the order number of the given port function at the given cell. Supported port functions are defined by the PortFunc enumeration above.
int zGetOrderNo(
Cell* cell,
PortFunc portFunc
);
GetFuncPortOrderNo
Return the order number of the given port function at the given primitive function. Supported port functions are defined by the PortFunc enumeration above.
int zGetFuncPortOrderNo(
PrimitiveFunc func,
PortFunc portFunc
);
Str2PortFunc
Return the PortFunc enum value for a given name.
PortFunc zStr2PortFunc(
const char* name
);
GetFuncPort
Return the number of the port in the cell’s portList for a given port order number.
int zGetFuncPort(
Cell* cell,
int orderNo,
zBool* isBus
);
LookupPrimitiveFunc
name -→ PrimitiveFunc (or PrimFLAST on error).
PrimitiveFunc zLookupPrimitiveFunc(
const char* function
);
PrintPrimitiveFunc
PrimitiveFunc -→ name.
const char* zPrintPrimitiveFunc(
PrimitiveFunc func,
CellFlags flags
);
Access Primitive Types
IsTransistorDevice
Return true if cell is a transistor device.
zBool zIsTransistorDevice(
Cell* cell
);
IsTransistor
Return true if cell is a transistor.
zBool zIsTransistor(
Cell* cell
);
IsDeviceFunction
Return true if the given func is a device func.
zBool zIsDeviceFunction(
PrimitiveFunc func
);
IsOperator
Return true if the given cell is an operator.
zBool zIsOperator(
Cell* cell
);
CheckPortIsHidable
Returns zTrue if the given port is ok for the PortFHide flag.
zBool zCheckPortIsHidable(
Cell* cell,
int portNo
);
OppositePort
Returns portno of opposite port, or -1 if not possible.
int zOppositePort(
Cell* cell,
int portNo
);
PolarDevice
Return true if the given cell is a polar device.
zBool zPolarDevice(
Cell* cell
);
zSetDisplayAttribute
Set the meta attribute format string how to display attributes at the given cell. If metaAttribute is NULL, then the internal default format string is used.
void zSetDisplayAttribute(
DB* db,
Cell* cell,
const char* metaAttribute
);
typedef struct {
const char* name;
PortFlags dir;
} PrimDescrPort;
typedef struct {
const char* prefix;
const char* type;
PrimDescrPort* ports;
enum PrimitiveFunc func;
int minPortCnt;
int maxPortCnt;
} PrimDescr;
zPrimPrefix2Func
Find function for given prefix (like MN, D).
enum PrimitiveFunc zPrimPrefix2Func(const char* prefix);
zPrimType2Decr
Find description for spice types (like NMOS, DIODE, NPN).
PrimDescr* zPrimType2Descr(const char* type);
zPrimFunc2Decr
Find description for functions (like PrimFNMOS etc.).
PrimDescr* zPrimFunc2Descr(enum PrimitiveFunc func);
zPrimModelName2Func
Guess model names (like nmos, nch) to primitive function. if portCnt is not -1 it is checked against the minimum needed count.
enum PrimitiveFunc zPrimModelName2Func(const char* modelName, int portCnt);
The Database Validator
Validate Flags
Available Flags
Flags to control validate options.
/* namespace */
#define VALIDATE_NAMESPACE (1U<<0)
#define VALIDATE_NAMESPACE_S "namespace"
/* namespace and ignore case */
#define VALIDATE_ICASENAMESPACE (1U<<1)
#define VALIDATE_ICASENAMESPACE_S "icasenamespace"
/* spos */
#define VALIDATE_SPOS (1U<<2)
#define VALIDATE_SPOS_S "spos"
/* primFunction in mode9 */
#define VALIDATE_MODE9 (1U<<3)
#define VALIDATE_MODE9_S "mode9"
/* flat database */
#define VALIDATE_FLAT (1U<<4)
#define VALIDATE_FLAT_S "flat"
/* spos lineinfo */
#define VALIDATE_LINEPOS (1U<<5)
#define VALIDATE_LINEPOS_S "linepos"
/* cycle in hierarchy */
#define VALIDATE_TORDER (1U<<6)
#define VALIDATE_TORDER_S "torder"
/* if visit flags are cleared */
#define VALIDATE_VISIT (1U<<7)
#define VALIDATE_VISIT_S "visit"
/* if all flags are cleared */
#define VALIDATE_FLAGS (1U<<8)
#define VALIDATE_FLAGS_S "flags"
/* net/bus values */
#define VALIDATE_VALUE (1U<<9)
#define VALIDATE_VALUE_S "value"
/* that DB hiersep is unused */
#define VALIDATE_HIERSEP (1U<<10)
#define VALIDATE_HIERSEP_S "hiersep"
/* flat database incl. name matches */
#define VALIDATE_FLATPEDANTIC (1U<<11)
#define VALIDATE_FLATPEDANTIC_S "flatpedantic"
/* flat values at signals */
#define VALIDATE_FLATVALUE (1U<<12)
#define VALIDATE_FLATVALUE_S "flatvalue"
/* attribute format 'name=value' */
#define VALIDATE_ATTRIBUTES (1U<<13)
#define VALIDATE_ATTRIBUTES_S "attributes"
/* integrity of parasitic data */
#define VALIDATE_PARASITIC (1U<<14)
#define VALIDATE_PARASITIC_S "parasitic"
/* power/ground flags of nets */
#define VALIDATE_PG (1U<<15)
#define VALIDATE_PG_S "pg"
/* value nets only one pin. */
#define VALIDATE_SINGLEVALCONN (1U<<16)
#define VALIDATE_SINGLEVALCONN_S "singlevalconn"
/* for unused visible hiersep. */
#define VALIDATE_VISIBLEHIERSEP (1U<<17)
#define VALIDATE_VISIBLEHIERSEP_S "visiblehiersep"
/* for valid clock flags at cell. */
#define VALIDATE_CLOCK (1U<<18)
#define VALIDATE_CLOCK_S "clock"
/* for valid clock flags at cell/port*/
#define VALIDATE_CLOCKSTRICT (1U<<19)
#define VALIDATE_CLOCKSTRICT_S "clockstrict"
/* flags of bus members. */
#define VALIDATE_BUSMEMBERDIR (1U<<20)
#define VALIDATE_BUSMEMBERDIR_S "busmemberdir"
/* skill export namespace. */
#define VALIDATE_SKILLEXPORTNAMESPACE (1U<<21)
#define VALIDATE_SKILLEXPORTNAMESPACE_S "skillexportnamespace"
/* keep going. */
#define VALIDATE_KEEPGOING (1U<<22)
#define VALIDATE_KEEPGOING_S "keepgoing"
/* attrList NULL pointer */
#define VALIDATE_ATTRLISTNULL (1U<<23)
#define VALIDATE_ATTRLISTNULL_S "atrrlistnull"
/* net bus wide connection */
#define VALIDATE_NETBUSWIDECONNECTION (1U<<24)
#define VALIDATE_NETBUSWIDECONNECTION_S "netbuswideconnection"
/* defaults. */
#define VALIDATE_DEFAULTS ( VALIDATE_NAMESPACE \
| VALIDATE_SPOS \
| VALIDATE_FLAT \
| VALIDATE_TORDER \
| VALIDATE_VALUE \
| VALIDATE_HIERSEP \
| VALIDATE_ATTRIBUTES \
| VALIDATE_PARASITIC \
| VALIDATE_PG \
| VALIDATE_CLOCK \
| VALIDATE_BUSMEMBERDIR \
| VALIDATE_ATTRLISTNULL \
| VALIDATE_NETBUSWIDECONNECTION \
| VALIDATE_KEEPGOING \
)
#define VALIDATE_DEFAULTS_S "defaults"
Default Flags for Validation
Built-in defaults:
zValidateDB
Validate the given ZDB database.
zBool zValidateDB(
DB* db,
int flags
);
The Source Position API
Type Definitions for Spos
Spos Type
Definition of the type which the Spos belongs to. The order of the enumeration is used as a priority during pick operation: Higher numbers get prio over lower numbers.
enum SposType {
SposInvalid,
SposNext,
SposInst,
SposCell,
SposNet,
SposPin,
SposPort,
SposNetBus,
SposPortBus,
SposNull,
SposVirtual
};
SposTypeFlags
Definition of the type flags use in bit flags.
typedef zUInt8 SposTypeFlags;
#define SposTypeUndefine 0x00
#define SposTypeFFile 0x01
#define SposTypeFLine 0x02
#define SposTypeFPrimitive 0x04
#define SposTypeFModule 0x08
#define SposTypeFPort 0x10
#define SposTypeFInst 0x20
#define SposTypeFPin 0x40
#define SposTypeFNet 0x80
Definition of a Spos
Each struct stores the index of the file in which this Spos lies in. The type indicates the type of DB object this spos belongs to. The special type SposNext is used to indicate, that there are more Spos in the list. Only the last entry points the DB object. Only begPos and length are stored, the endPos can be calculated as (begPos+length). Spos entries of type SposNext have an additional pointer to the last entry, for faster access to the corresponding DB object. Invalid Spos entries, which exist after a call to zSposInvalidate are marked as type SposInvalid.
#define SFILES_BITS 24
#define SPOS_MAX_SFILES (1L << SFILES_BITS)
typedef struct Spos {
unsigned sfileIdx:SFILES_BITS; /* index in db.sfiles (max: 1<<24) */
unsigned BF_ENUM_type_:5; /* SposType */
unsigned BF_ENUM_nt_:3; /* nulltype if type==SposNull */
unsigned length; /* length of source file pos */
zFPos begPos; /* begin of source file position */
union { /* union ptr to next Spos or */
struct { struct Spos* next; struct Spos* last; } x; /* ptr to next */
/* and last spos */
/* of same obj */
struct { struct Spos* next; } invalid; /* nxt invalid/unused in bucket*/
struct {Cell* cell; } c; /* SposCell */
struct {Cell* cell; int portNo; } p; /* SposPort */
struct {Cell* cell; int portBusNo; } pb; /* SposPortBus */
struct {Module* mod; Inst* inst; int pinNo;} pi; /* SposPin */
struct {Module* mod; Inst* inst; } i; /* SposInst */
struct {Module* mod; Net* net; } n; /* SposNet */
struct {Module* mod; NetBus* netBus; } nb; /* SposNetBus */
struct {VirtualObject* obj; } v; /* SposVirtual */
} u;
} Spos;
zSposGetType
Get the type of a spos.
#define zSposGetType(spos) \
((enum SposType)(spos)->BF_ENUM_type_)
zSposGetLastType
Get the type of the last spos entry.
#define zSposGetLastType(spos) \
zSposGetType(zSposLAST(spos))
zSposGetBegPos
Get the beginning of spos.
#define zSposGetBegPos(spos) \
((spos)->begPos)
zSposGetLength
Get the length of spos.
#define zSposGetLength(spos) \
((spos)->length)
zSposGetEndPos
Get end of spos.
#define zSposGetEndPos(spos) \
((spos)->begPos + (spos)->length)
zSposGetSfile
Get the sfile pointer.
#define zSposGetSfile(db, spos) \
((db)->sfileList[(spos)->sfileIdx])
zSposSetType
Set the type of a spos.
#define zSposSetType(spos, sposTypeValue) \
(spos)->BF_ENUM_type_ = (unsigned)(sposTypeValue)
zSposGetNullType
Get the OidNullType of a spos for a null Oid.
#define zSposGetNullType(spos) \
((enum OidNullType)(spos)->BF_ENUM_nt_)
zSposSetNullType
Set the OidNullType of a spos for a null Oid.
#define zSposSetNullType(spos, nullTypeValue) \
(spos)->BF_ENUM_nt_ = (unsigned)(nullTypeValue)
Spos File Types
Define different Spos file types.
typedef enum {
SposFileTUndef,
SposFileTSpice2,
SposFileTSpice3,
SposFileTPSpice,
SposFileTHSpice,
SposFileTCalibre,
SposFileTCdl,
SposFileTSpectre,
SposFileTSpectreLpe,
SposFileTSpectrePex,
SposFileTDspf,
SposFileTEldo,
SposFileTVerilog,
SposFileTVhdl,
SposFileTglVerilog,
SposFileTEdif,
SposFileTDef,
SposFileTLef,
SposFileTSpef,
SposFileTLiberty,
SposFileTLTSpice,
SposFileTEND
} SposFileType;
SposBucketRoot
Each bucket Root has a free list of invalid/unused spos entries. and a linked list of Spos buckets containing a fixed number of spos entries.
typedef struct SposBucketRoot {
struct SposBucket* firstBucket; /*ptr to first bucket */
struct Spos* firstInvalidSpos; /*ptr to first invalid/unused spos */
} SposBucketRoot;
Definition of the Sfile Structure
Each source file manages: - filepositions for the lines in SlineTabs - a list of buckets with Sposs which belong to a specific filepos range of fixed size - Spos which are too long and so belong to more than one range are kept in the largeBucket. The bucket ranges overlap, so small Spos, which lie at the border from one bucket range to the other, do not necessarily go into the largeBucket list.
typedef struct Sfile {
struct SposBucketRoot* bucketRootList; /* list of bucketRoots */
struct SposBucketRoot largeBucketRoot; /* one bucketRoot for large sposs */
struct SlineTab* slineTabFirst; /* linked list of SlineTabs */
struct SlineTab* slineTabLast; /* linked list of SlineTabs */
char* fname; /* absolute fname */
char* shortFname; /* short fname */
struct Spos* spos; /* start of spos without an object */
zFPos fileSize; /* size of file */
zDate modDate; /* modification date of file */
zULong refCnt; /* no of Spos which ref sfile */
unsigned slineLastOffset; /* lineno offset of last Tab */
unsigned maxLineno; /* max lineno */
unsigned maxColumn; /* max line length */
int ftype; /* fname type from zConvertFileName */
/* or -1 if noconvert */
zBool slineHasGaps; /* needs fill because of "gaps" */
zBool notPopulated; /* lineinfo not yet populated */
SposFileType type; /* type of source file */
unsigned idx:SFILES_BITS; /* uniq index of file */
} Sfile;
SlineTab
Filepositions of lines are managed in chunks for better memory usage/performance missing entries are preset to -1 the file position of each \n is entered in pos[].
typedef struct SlineTab {
struct SlineTab *next; /* linked list of other SlineTab */
unsigned posCnt; /* maximum number of file positions */
zFPos pos[1]; /* variable size */
} SlineTab;
zSposNewFile
Allocate a new Sfile, insert it into db→sfiles, and return it. In case of an error (e.g. too many SPOS files) NULL is returned and an error message is stored in the global error buffer. The given fname can be relative or absolute. Normally all fnames are stored absolute in the DB. Use noconvert=zTrue to store them as is.
Sfile* zSposNewFile(
DB* db,
const char* fname,
zBool noconvert,
SposFileType type
);
zSposSearchFile
Search for file, return NULL if not found.
Sfile* zSposSearchFile(
DB* db,
const char* fname,
zBool noconvert,
zBool setLastErrMsg
);
zSposMakeFile
Use zSposSearchFile to check whether file already exists. If not, create it with zSposNewFile.
Sfile* zSposMakeFile(
DB* db,
const char* fname,
zBool noconvert,
SposFileType type
);
zSposGetFile
Get file by index, return NULL if invalid.
Sfile* zSposGetFile(
DB* db,
int idx,
zBool setLastErrMsg
);
zSposSetBase
Set base name for zSposGetFilename() if noconvert=zTrue.
void zSposSetBase(
DB* db,
const char* base
);
zSposGetFilename
Return Sfile.fname rel to current working dir in given buffer. Normally the buffer should be PATH_MAX long.
zBool zSposGetFilename(
DB* db,
const Sfile*,
char* buf,
unsigned maxlen
);
zSposSetFilename
Set new filename.
zBool zSposSetFilename(
DB* db,
Sfile* sfile,
const char* fname
);
zSposGetShortFilename
Return Sfile.shortfname rel.
const char* zSposGetShortFilename(
DB* db,
const Sfile*
);
zSposSetShortFilename
Set short filename. Used only for display.
void zSposSetShortFilename(
DB* db,
Sfile* sfile,
const char* fname
);
zSposXXXInsert
Insert new Spos into sfile, and link it with DB obj. Return zTrue if OK, else a warning message is in zLastErrorMsg.
zBool zSposCellInsert(
DB* db,
Cell* cell,
Sfile* sfile,
zFPos begPos,
unsigned length
);
zBool zSposPortInsert(
DB* db,
Cell* cell,
int port,
Sfile* sfile,
zFPos begPos,
unsigned length
);
zBool zSposPortBusInsert(
DB* db,
Cell* cell,
int portBusNo,
Sfile* sfile,
zFPos begPos,
unsigned length,
zBool members
);
zBool zSposInstInsert(
DB* db,
Module* module,
Inst* inst,
Sfile* sfile,
zFPos begPos,
unsigned length
);
zBool zSposPinInsert(
DB* db,
Module* module,
Inst* inst,
int pinNo,
Sfile* sfile,
zFPos begPos,
unsigned length
);
zBool zSposNetInsert(
DB* db,
Module* module,
Net* net,
Sfile* sfile,
zFPos begPos,
unsigned length
);
zBool zSposNetBusInsert(
DB* db,
Module* module,
NetBus* netBus,
Sfile* sfile,
zFPos begPos,
unsigned length,
zBool members
);
zBool zSposNullInsert(
DB* db,
enum OidNullType nt,
Sfile* sfile,
zFPos begPos,
unsigned length
);
zBool zSposVirtualInsert(
DB* db,
VirtualObject* obj,
Sfile* sfile,
zFPos begPos,
unsigned length
);
zSposNEXT
Get next spos or NULL if there are no more.
#define zSposNEXT(spos) \
((zSposGetType(spos) == SposNext) ? (spos)->u.x.next : NULL)
zSposLAST
Get last spos. Because these are implemented as macros they should not be used with arguments which have side effects.
#define zSposLAST(spos) \
((zSposGetType(spos) == SposNext) ? (spos)->u.x.last : (spos))
zSposXXXDelete
Delete all spos from given object. If there are no more spos for a file, the file is delete too. Module or Primitive delete all contained objects (ports, inst etc.) Return zTrue if OK, else a warning message is in zLastErrorMsg.
zBool zSposCellDelete(
DB* db,
Cell* cell
);
zBool zSposPortDelete(
DB* db,
Port* port
);
zBool zSposPortBusDelete(
DB* db,
PortBus* portBus
);
zBool zSposInstDelete(
DB* db,
Inst* inst
);
zBool zSposPinDelete(
DB* db,
Inst* inst,
int pinNo
);
zBool zSposNetDelete(
DB* db,
Net* net
);
zBool zSposNetBusDelete(
DB* db,
NetBus* netBus
);
zBool zSposNullDelete(
DB* db,
enum OidNullType nt,
Sfile* sfile
);
zBool zSposVirtualDelete(
DB* db,
VirtualObject* obj
);
zSposXXXClone
Clone all Spos entries of an object. Clone list of spos entries - create a 1:1 copy, except if limit is set to non-zero, then only create up to limit spos entries.
zBool zSposCellClone(
DB*,
int*,
Spos*,
Cell*,
int limit
);
zBool zSposPortClone(
DB*,
int*,
Spos*,
Cell*,
int,
int limit
);
zBool zSposPortBusClone(
DB*,
int*,
Spos*,
Cell*,
int,
int limit
);
zBool zSposInstClone(
DB*,
int*,
Spos*,
Module*,
Inst*,
int limit
);
zBool zSposPinClone(
DB* db,
int* sfileIdxMap,
Spos* src,
Module* dmod,
Inst* dest,
int pinNo,
int limit
);
zBool zSposNetClone(
DB*,
int*,
Spos*,
Module*,
Net*,
int limit
);
zBool zSposNetBusClone(
DB*,
int*,
Spos*,
Module*,
NetBus*,
int limit
);
zSposUpdateCell
Update cell pointer, if needed
void zSposUpdateCell(
Spos*,
Cell*
);
zSposUpdatePinNo
Update pinNo pointer, if needed.
void zSposUpdatePinNo(
Spos*,
int
);
zSposPick
Returns the Spos of the object with the smallest filepos range with filePos in it. In case of nothing found, return NULL
Spos* zSposPick(
DB* db,
Sfile* sfile,
zFPos filePos
);
zSposPickAcceptCB
Returns the Spos of the object with the smallest filepos range with filePos in it. In case of nothing found, return NULL For each possible result a callback is consulted. if it returns zFalse the result is ignored.
typedef enum {SposAcceptFalse, SposAcceptTrue, SposAcceptErr} SposAcceptRes;
typedef SposAcceptRes (*SposAcceptCB)(void* ctx, const char* cellName);
Spos* zSposPickWithAcceptCB(
DB* db,
Sfile* sfile,
zFPos filePos,
void* acceptCtx,
SposAcceptCB acceptCB,
zBool* okPtr
);
zSposPickList
Returns a list Spos* of the objects. In case of nothing found, return NULL
Spos** zSposPickList(
DB* db,
Sfile* sfile,
zFPos filePos
);
zSposForeachRange
Find Spos in a given file/range and call callback foreach. Abort if callback return -1 (error) or 1 (break) if lastPos == -1 the last position of the file is used. continue loop if callback return 0 (ok). Return true if no error occurred. If uniq > 0, multiple oids with same type, beg/end are suppressed.
zBool zSposForeachRange(
DB* db,
Sfile* sfile,
unsigned uniqCnt,
zBool sort,
zFPos firstPos,
zFPos lastPos,
unsigned colBeg,
unsigned colEnd,
zFPos* linePos,
int (*cb)(Spos*,void*),
void* info
);
zSposForeachRangeWithAcceptCB
Find Spos in a given file/range and call callback foreach. Abort if callback return -1 (error) or 1 (break) if lastPos == -1 the last position of the file is used. continue loop if callback return 0 (ok). Return true if no error occurred. If uniq > 0, multiple oids with same type, beg/end are suppressed. For each possible result a callback is consulted. if it returns zFalse the result is ignored.
zBool zSposForeachRangeWithAcceptCB(
DB* db,
Sfile* sfile,
unsigned uniqCnt,
zBool sort,
zFPos firstPos,
zFPos lastPos,
unsigned colBeg,
unsigned colEnd,
zFPos* linePos,
int (*cb)(Spos*,void*),
void* info,
SposAcceptCB acceptCB,
void* acceptCtx
);
zSposInsertLine
Insert the file position for the lineno.
In case of an error, return NULL and store the error message in zLastErrorMsg. lineno : beginning at 1, should be up-counting. filepos : must be the position of the newline (\n) character.
If lineno is 0 the whole file will be scanned and all filepos will be determined. If the given lineno is not up-counting (is not exactly one above the previous zSposInsertLine call’s lineno), then the missing linenos are computed on demand (in zSposSearchLine). Duplicate calls with identical (lineno, filepos) are ignored, but a duplicate lineno with a different filepos results in an error.
In case of an error, return NULL and store the error message in zLastErrorMsg.
zBool zSposInsertLine(
DB* db,
Sfile* sfile,
unsigned lineno,
zFPos filepos
);
zSposInsertEOF
Define the file-size.
filesize : the file size (file position after the last char)
In case of an error, return NULL and store the error message in zLastErrorMsg.
Corner Cases: (1) "billy" -→ zSposInsertEOF (5) (2) "" -→ zSposInsertEOF (0) (3) "\n" -→ zSposInsertLine(1,0) zSposInsertEOF (1) (4) "billy\n" -→ zSposInsertLine(1,5) zSposInsertEOF (6) (5) "billy\nb" -→ zSposInsertLine(1,5) zSposInsertEOF (7) (6) "billy\nb\n" -→ zSposInsertLine(1,5) zSposInsertLine(2,7) zSposInsertEOF (8)
zBool zSposInsertEOF(
DB* db,
Sfile* sfile,
zFPos filesize
);
zSposSearchLine
Search for lineno, begPos and endPos at a given filepos.
If zSposInsertLine() or zSposInsertEOF() calls were missing, then the file is opened and scanned to get the missing information. If that file-open fails, then return zFalse and store the error message in zLastErrorMsg.
If filepos is -1 the last line is searched.
If filepos is out of range (<0 || >= filesize) then, return zFalse and store the error message in zLastErrorMsg.
filepos : the file position between start-of-line and the newline char (included). lineno : return: the line number begPos : return: the position of start-of-line (first char in line). endPos : return: the position directly after the newline (\n) char (or the file size)
Corner Cases: (1) zSposSearchLine(0) -→ 1,0,5 zSposSearchLine(4) -→ 1,0,5 zSposSearchLine(5) -→ error (2) zSposSearchLine(0) -→ error (3) zSposSearchLine(0) -→ 1,0,1 (4) zSposSearchLine(0) -→ 1,0,6 zSposSearchLine(5) -→ 1,0,6 zSposSearchLine(6) -→ error (5) zSposSearchLine(0) -→ 1,0,6 zSposSearchLine(6) -→ 2,6,7 (6) zSposSearchLine(6) -→ 2,6,8 zSposSearchLine(7) -→ 2,6,8 zSposSearchLine(8) -→ error
zBool zSposSearchLine(
DB* db,
Sfile* sfile,
zFPos filepos,
unsigned* lineno,
zFPos* begPos,
zFPos* endPos
);
zSposGetFilepos
Search for begPos and endPos for a given lineno
If zSposInsertLine() or zSposInsertEOF() calls were missing, then the file is opened and scanned to get the missing information. If that file-open fails, then return zFalse and store the error message in zLastErrorMsg.
if lineno == 0 then return the last line. if lineno is out of range (too big), then return zFalse and store the error message in zLastErrorMsg.
lineno : the line number, starting at 1 (or 0). begPos : return: the position of start-of-line (first char in line). endPos : return: the position directly after the newline (\n) char (or the file size)
Corner Cases: (1) file: "billy" zSposGetFilepos(0) -→ 0,5 - last line zSposGetFilepos(1) -→ 0,5 - line#1 zSposGetFilepos(2) -→ error (2) file: "" zSposGetFilepos(0) -→ error (3) file: "\n" zSposGetFilepos(0) -→ 0,1 - last line zSposGetFilepos(1) -→ 0,1 - line#1 zSposGetFilepos(2) -→ error (4) file: "billy\n" zSposGetFilepos(0) -→ 0,6 - last line zSposGetFilepos(1) -→ 0,6 - line#1 zSposGetFilepos(2) -→ error (5) file: "billy\nb" zSposGetFilepos(0) -→ 6,7 - last line zSposGetFilepos(1) -→ 0,6 - line#1 zSposGetFilepos(2) -→ 6,7 - line#2 (6) file: "billy\nb\n" zSposGetFilepos(0) -→ 6,8 - last line zSposGetFilepos(1) -→ 0,6 - line#1 zSposGetFilepos(2) -→ 6,8 - line#2 zSposGetFilepos(3) -→ error
zBool zSposGetFilepos(
DB* db,
Sfile* sfile,
unsigned lineno,
zFPos* begPos,
zFPos* endPos
);
zSposDeleteAll
Delete all Spos data, free database memory.
void zSposDeleteAll(
DB* db
);
zSposInvalidate
Flag Spos data of one object as SposInvalid.
void zSposInvalidate(
DB* db,
Spos*
);
zSposGetOID
Get oid from given spos. Returns zFalse and set zLastErrorMsg if spos is SposInvalid.
zBool zSposGetOID(
Spos* spos,
struct OID* oid
);
zSposValidate
Return false on error and report to zLastErrorMsg
zBool zSposValidate(
DB* db,
zBool linePos
);
zSposMemoryUsage
Return total memory usage.
zULong zSposMemoryUsage(
struct Sfile*,
unsigned* cnt
);
zSposUsage
Return number of pos and line entries.
void zSposUsage(
struct Sfile*,
zULong* sposCnt,
zULong* lineCnt
);
zSposFileType2Str
Return file type as a string.
const char* zSposFileType2Str(
SposFileType type
);
zSposStr2FileType
Return file type as enum
SposFileType zSposStr2FileType(
const char* str
);
zSposSfileIsEqual
Compare two sfile pointer.
zBool zSposSfileIsEqual(
Sfile* sfile1,
Sfile* sfile2
);
Object Identification (OID)
The Database Net/Pin/Inst/etc Identification Items
Type Definitions for OIDs
Path
Definition of the Path part of an OID These Paths are only created by malloc and are automatically freed (by zOID_unref) if refCount goes to 0.
typedef struct Path { /* Object Identification */
int refCount; /* How many OIDs are pointing to me */
int pathLength; /* Length of path */
Module* module; /* The root module */
Inst* path[1]; /* The instance path */
} Path;
OID Type
Definition of the Object Identification type.
enum oidtypeE {
OidBAD = 0,
OidModule = 1,
OidPrimitive = 2,
OidPort = 3,
OidPortBus = 4,
OidInst = 5,
OidPin = 6,
OidPinBus = 7,
OidNet = 8,
OidNetBus = 9,
OidSignal = 10,
OidNetSeg = 11,
OidNull = 12,
OidVirtual = 13,
OidLAST = 14
};
typedef enum oidtypeE OidType;
OID Null Types
Definition of the OidNull object types.
typedef enum OidNullType {
OidNullTNONE = 0,
OidNullTWhite = 1,
OidNullTGrey = 2,
OidNullTBlack = 3,
OidNullTComment = 4,
OidNullTUndefined = 5,
OidNullTColor = 6,
OidNullTERROR = 7
} OidNullType;
OID Flags
Definition of OID flags
typedef unsigned char OidFlags;
#define OidFNone 0x00 /* No OID flag is set */
#define OidFPath 0x01 /* p.path is valid instead of p.module */
#define OidFVisit 0x20 /* general purpose flag */
#define OidFFreeList 0x40 /* toid.c: This OID is in memory freelist */
#define OidFMemToFree 0x80 /* toid.c: This OID is marked to get freed */
OID Structure
Definition of the OID structure.
typedef struct OID { /* Object Identification */
OidType type;
OidFlags flags;
union {
Module* module;
Primitive* primitive;
Path* path; /* if flags & OidFPath */
struct OID* next; /* if flags & OidFFreeList */
} p; /* defines the parent */
union {
int portNo; /* also portBusNo */
Inst* inst;
PinRef pin; /* also pinBus */
Net* net; /* also signal */
NetBus* netBus;
struct {
Net* net;
unsigned short pin0;
unsigned short pin1;
} netseg;
OidNullType nullType; /* for OidNull */
VirtualObject* virtualObject;
} o; /* defines the object inside the parent */
} OID;
Access Functions to OIDs
zOID_getType
Get the type of 'oid'.
#define zOID_getType(oid) \
(oid)->type
zOID_setType
Set the type of 'oid' to 'newType'.
#define zOID_setType(oid,newType) \
(oid)->type = (newType)
zOID_EndOfPath
Get Cell at end of Path, that is the module or primitive referenced by the path’s last instance.
Cell* zOID_EndOfPath(
const OID* oid
);
zOID_samePath
return zTrue if both oids have same path.
zBool zOID_samePath(
const OID* a,
const OID* b
);
zOID_samePathMinus
return zTrue if both oids have same path, but ignore last element of a
zBool zOID_samePathMinus(
const OID* a,
const OID* b
);
zOID_ref
Increase the ref count of the path.
void zOID_ref(
const OID*
);
zOID_unref
Decrease the ref count of the path and eventually free Path.
void zOID_unref(
const OID*
);
Public Service Functions for Hash Tables with an OID Key
zOID_hash
unsigned zOID_hash(
OID
);
zOID_cmp
int zOID_cmp(
OID a,
OID b
);
zOID_dictCmp
int zOID_dictCmp(
OID a,
OID b
);
zOID_IsEqual
zBool zOID_IsEqual(
OID a,
OID b
);
zOID_equal
int zOID_equal(
OID a,
OID b
);
zOID_cmpVP
int zOID_cmpVP(
const void* objA,
const void* objB
);
zOID_cmpP
int zOID_cmpP(
const OID* a,
const OID* b
);
zOID_dictCmpVP
int zOID_dictCmpVP(
const void* objA,
const void* objB
);
zOID_dictCmpP
int zOID_dictCmpP(
const OID* a,
const OID* b
);
zOID_equalP
int zOID_equalP(
const OID* a,
const OID* b
);
zOID_create
zBool zOID_create(
DB* db,
int argc,
char* argv[],
OID* result,
zBool icase
);
zOID_isBusMember
zBool zOID_isBusMember(
const OID* oid,
int* bool_result
);
zOID_busOf
zBool zOID_busOf(
const OID* oid,
OID* result
);
zOID_widthOf
zBool zOID_widthOf(
const OID* oid,
int* result
);
zOID_hasRange
zBool zOID_hasRange(
const OID* oid,
int* bool_result
);
zOID_rangeLsb
zBool zOID_rangeLsb(
const OID* oid,
int* result
);
zOID_rangeMsb
zBool zOID_rangeMsb(
const OID* oid,
int* result
);
zOID_isModule
zBool zOID_isModule(
const OID* oid,
int* bool_result
);
zOID_isOperator
zBool zOID_isOperator(
const OID* oid,
int* bool_result
);
zOID_isTop
zBool zOID_isTop(
const OID* oid,
int* bool_result
);
zOID_isPgNet
zBool zOID_isPgNet(
const OID* oid,
int* bool_result
);
zOID_moduleOf
zBool zOID_moduleOf(
const OID* oid,
OID* result
);
zOID_primitiveOf
zBool zOID_primitiveOf(
const OID* oid,
OID* result
);
zOID_down
zBool zOID_down(
const OID* oid,
OID* result
);
zOID_up
zBool zOID_up(
const OID* oid,
OID* result
);
zOID_refCount
zBool zOID_refCount(
const OID* oid,
int* result
);
zOID_concat
zBool zOID_concat(
const OID* inst,
const OID* pin,
OID* result
);
zOID_changePin
Change pin no of a given pin/portOid.
zBool zOID_changePin(
OID* oid,
int pinNo
);
zOID_convertPin
Change pin/port of a pin/portOid. The resulting OID is stored where "result" points to. The result oid’s refCount is NOT incremented - like for all OID-returning functions in this file, it is up to the caller to perform zOID_ref(result) and zOID_unref(result).
zBool zOID_convertPin(
const OID* oid,
int pinNo,
OID* result
);
zOID_convertToPin
Convert to pin oid. The resulting OID is stored where "result" points to. The result oid’s refCount is NOT incremented - like for all OID-returning functions in this file, it is up to the caller to perform zOID_ref(result) and zOID_unref(result).
zBool zOID_convertToPin(
const OID* oid,
Inst* inst,
int pinNo,
OID* result
);
zOID_convertToNet
Convert to net oid. The resulting OID is stored where "result" points to. The result oid’s refCount is NOT incremented - like for all OID-returning functions in this file, it is up to the caller to perform zOID_ref(result) and zOID_unref(result).
zBool zOID_convertToNet(
const OID* oid,
Net* net,
OID* result
);
zOID_convertToPort
Convert to port oid. The resulting OID is stored where "result" points to. The result oid’s refCount is NOT incremented - like for all OID-returning functions in this file, it is up to the caller to perform zOID_ref(result) and zOID_unref(result).
zBool zOID_convertToPort(
const OID* oid,
int portNo,
OID* result
);
zOID_convertTo
Convert an OID. if pname == NULL pin -→ inst pinBus -→ inst signal -→ net netSeg -→ net port -→ module/primitive portBus -→ module/primitive
if pname is given pin ←- inst pinBus ←- inst port ←- module/primitive portBus ←- module/primitive
The resulting OID is stored where "result" points to. The OID’s root module and path information is copied from the given oid. The result oid’s refCount is NOT incremented - like for all OID-returning functions in this file, it is up to the caller to perform zOID_ref(result) and zOID_unref(result).
zBool zOID_convertTo(
DB* db,
const OID* oid,
const char* rtype,
const char* pname,
OID* result
);
zOID_convertable
Return what zOID_convertTo can do (with pname == NULL). The specialRes result is a 2nd possibility.
OidType zOID_convertable(
const OID* oid,
OidType* specialRes
);
zOID_convertFromParasitic
Converts a parasitic OID to a normal OID.
zBool zOID_convertFromParasitic(
DB*,
const OID* oid,
OID*
);
zOID_convertToParasitic
Converts a normal OID to a parasitic OID.
zBool zOID_convertToParasitic(
DB*,
const OID* oid,
const OID*,
OID*
);
zOID_hasParentInst
Checks if the inst/net oid has a path - that’s equivalent to checking if the oid is tree-based (that means there is a parent one step up the design hierarchy).
zBool zOID_hasParentInst(
const OID* oid,
int* bool_result
);
zOID_parentInst
Returns the parent inst (that means, the path is one entry shorter). Replace OID.o.inst by the previously last in path.
zBool zOID_parentInst(
const OID* oid,
OID* result
);
zOID_hasParentMod
Checks if the oid has a containing module - this is almost always zTrue, except for non tree-based primitive or module OIDs.
zBool zOID_hasParentMod(
const OID* oid,
int* bool_result
);
zOID_parentModule
Returns the parent module (that means, the type is set to OidModule). If however, the oid already is a module, then the path is cut by one entry.
zBool zOID_parentModule(
const OID* oid,
OID* result
);
zOID_isConnected
Checks if the given pin or port OID connects to a net or not (unconnected).
zBool zOID_isConnected(
const OID* oid,
int* bool_result
);
zOID_connectedNet2
Set netP to the connected net of the given pin or port OID.
zBool zOID_connectedNet2(
const OID* oid,
Net** netP
);
zOID_connectedNet
Returns the OID for the net connected by the given pin or port OID.
zBool zOID_connectedNet(
const OID* oid,
OID* result
);
zOID_createPath
If plen > 0 then allocate a Path and store a pointer to it in the given OID and fill the Path with the given "root" and "path" and set the OidFPath flag.
If plen == 0, then clear the OidFPath flag and store the given "root" into the given OID.
If path == NULL, then also allocate the Path, but leave it’s array of Inst* uninitialized.
void zOID_createPath(
OID*,
Module* root,
Inst** path,
int plen
);
zOID_createReversePath
Like zOID_createPath()
but the given path is in reverse order.
void zOID_createReversePath(
OID*,
Module* root,
Inst** path,
int plen
);
zOID_searchTreeBased
Searches a tree-OID that matches the given module-based OID - use hint as a starting point.
zBool zOID_searchTreeBased(
DB* db,
const OID* oid,
const OID* hint,
OID* result
);
zOID_createFromString
The given string 'str' is converted into 'oid'. The returned 'oid' will be of the given 'type'. The given 'hierSep' character is used to split 'str' in it’s hierarchical path of instance names rooted at given module 'top' and an object name. If 'delim' is not '\0' it is used, instead of 'hierSep' for separating the object name. If 'escape' is not '\0' 'hierSep' and 'delim' characters following 'escape' will be added to the corresponding name. If 'topInstName' is not 'NULL' the first part of 'str' is ignored if it matches 'topInstName'. If 'icase' is zTrue instance name and object searching is case insensitive. If 'guess' is zTrue instance names which are not found directly will be searched by prepending an 'X'. If 'guess' is zTrue try replacing first 'X' with the following second character. The oid’s refCount is NOT incremented - like for all OID-returning functions in this file, it is up to the caller to perform zOID_ref(oid) and zOID_unref(oid).
zBool zOID_createFromString(
DB* db,
OID* oid,
OidType type,
Module* top,
const char* str,
char hierSep,
char delim,
char escape,
const char* topInstName,
ce_Bool icase,
ce_Bool guess,
ce_Bool escapeVerilog,
ce_Bool autoPopulate
);
zOID_createFromStringList
zBool zOID_createFromStringList(
DB* db,
OidType type,
const char** pathList,
int pathListLength,
const char* oname,
ce_Bool icase,
ce_Bool guessPath,
ce_Bool guessName,
ce_Bool autoPopulate,
OID* oid
);
zOID_createNetSeg
Create net seg oid from two pin/ports. The res’s refCount is NOT incremented - like for all OID-returning functions in this file, it is up to the caller to perform zOID_ref(res) and zOID_unref(res).
zBool zOID_createNetSeg(
OID* res,
OID* oid1,
OID* oid2
);
Access OID Information
Public functions that return a string
In case of an error, return NULL and store the error message in zLastErrorMsg.
zOID_printDirection
String from PortFlags or NULL to indicate an error.
char* zOID_printDirection(
PortFlags dir
);
zOID_direction
set PortFlags of given dirP. return zFalse to indicate an error (zLastErrorMsg)
zBool zOID_direction(
const OID* oid,
PortFlags* dirP
);
zOID_directionOf
String from pin or port OID or NULL to indicate an error.
char* zOID_directionOf(
const OID* oid
);
zOID_type
Get type string from OidType.
char* zOID_type(
const OID* oid
);
zOID_oname
Get the object name.
char* zOID_oname(
const OID* oid
);
zOID_pname
Get the pin name.
char* zOID_pname(
const OID* oid
);
zOID_cname
Get the cell name.
char* zOID_cname(
const OID* oid
);
zOID_netsegpname
Get net segment pin name.
char* zOID_netsegpname(
const OID* oid,
int field /*0, 1, 2, 3*/
);
zOID_print
Print the given OID to a string.
char* zOID_print(
DB *db,
const OID* oid, /* The OID to print. */
zBool addType, /* Add the object type. */
zBool addWidth, /* Add the width of a bus object. */
zBool addRange, /* Add the range of a bus object. */
zBool typeTitle, /* Print the type as title. */
zBool addRoot, /* Add the root (toplevel) module. */
zBool addPath, /* Add the path to the object. */
zBool addName, /* Add the object type. */
zBool tclName, /* Add Tcl conform object names. */
zBool nameAttr, /* Use the @name attribute as the object name. */
zBool escapeVerilog, /* Escape identifiers for verilog.*/
char hiersep, /* Hierarchy separator to use. */
char delimiter, /* Pin delimiter character to use. */
char joinchar, /* Join all OID elements. */
DStr *result /* DStr to store the OID string */
/* (result needs to be initialized). */
);
zOID_stringRepresentation
Create a Tcl-compatible string representation of the OID.
char* zOID_stringRepresentation(
const OID* oid,
DStr* result
);
zOID_dump
dump oid as debug message. if msg is not NULL it is prepended as additional info.
void zOID_dump(
const char* msg,
const OID* oid
);
zOID_dumpList
dump oid list as debug message. if msg is not NULL it is prepended as additional info.
void zOID_dumpList(
const char* msg,
const OID* oidList
);
zOID_appendList
Append and ref an OID to an oidList.
void zOID_appendList(
OID** oidList,
OID* oid
);
zOID_resetList
Unref all oids in a list and set the list length to 0.
void zOID_resetList(
OID* oidList
);
zOID_freeList
unref all oids in a list and free array.
void zOID_freeList(
OID* oidList
);
zOID_str2type
Get OidType from type string.
OidType zOID_str2type(
const char* str,
zBool icase
);
OidType zOID_Str2Type(const char* str);
const char* zOID_Type2Str(OidType type);
void zOID_TypeUsageList(const char*** list);
zOID_nulltype2str
Get string from OidNullType.
const char* zOID_nulltype2str(
OidNullType t
);
zOID_str2nulltype
Get OidNullType from nulltype string.
OidNullType zOID_str2nulltype(
const char* str,
zBool errMsg
);
zOID_validate
Validate OID structure.
zBool zOID_validate(
const OID* oid
);
zOID_setSchematicCache
zBool zOID_setSchematicCache(OID* oid, const char* schematicLayout);
zOID_getSchematicCache
const char* zOID_getSchematicCache(OID* oid);
zOID_clearSchematicCache
zBool zOID_clearSchematicCache(DB* db, OID* oid);
zOID_highlightGet
Get highlight color of the given OID.
zBool zOID_highlightGet(
const OID* oid,
int* color,
int permanent
);
zOID_highlightSet
zBool zOID_highlightSet(
const OID* oid,
int color,
int permanent
);
zOID_highlightDelete
Delete highlight color of the given OID.
zBool zOID_highlightDelete(
const OID* oid,
int permanent
);
zOID_highlight2Get
get highlight in design, flat and parasitic.
zBool zOID_highlight2Get(
DB* db,
const OID* oid,
int* color,
int permanent
);
zOID_highlight2Set
set highlight in design, flat and parasitic.
zBool zOID_highlight2Set(
DB* db,
const OID* oid,
int color,
int permanent
);
zOID_highlight2Delete
delete highlight in design, flat and parasitic.
zBool zOID_highlight2Delete(
DB* db,
const OID* oid,
int permanent
);
zOID_insertModule
Similar to zOID_down, but insert the new Instance at the given level.
zBool zOID_insertModule(
const OID*,
int level,
Inst* newInst,
OID* res
);
zOID_removeModule
Counterpart to zOID_insertModule.
zBool zOID_removeModule(
const OID*,
int level,
OID* res
);
zOID_htraverseAll
Similar to searchTreeBased but find all paths from given top to given target. For each path found call the callback function func with the path stored in stack.
struct htraverseAll {
DB* db;
Cell* target;
Module* top;
Inst* stack[128];
zBool (*func)(struct htraverseAll*,int);
void* userData1;
void* userData2;
int userData3;
};
zBool zOID_htraverseAll(struct htraverseAll*, int stackTop);
zOID_isTopRoot
return true if OID is top based.
zBool zOID_isTopRoot(const OID* oid);
zOID_isParasitic
return true if OID is parasitic.
zBool zOID_isParasitic(const OID* oid);
zOID_rootModule
return root module of path (or NULL).
Module* zOID_rootModule(
const OID* oid
);
zOID_setNull
set oid to null.
void zOID_setNull(
OID* oid
);
zOID_setModulePort
set oid to module port.
void zOID_setModulePort(
OID* oid,
Module* mod,
int portNo
);
zOID_setModule
set oid to module.
void zOID_setModule(
OID* oid,
Module* mod,
Inst** path,
int plen
);
zOID_setNet
set oid to net.
void zOID_setNet(
OID* oid,
Module* mod,
Inst** path,
int plen,
Net* net
);
zOID_setNetFromNetBus
set oid to net.
void zOID_setNetFromNetBus(
OID* oid,
const OID* netBusOid,
Net* net
);
zOID_setInstPin
set oid to inst pin.
void zOID_setInstPin(
OID* oid,
Module* mod,
Inst** path,
int plen,
Inst* inst,
int pinNo
);
zOID_setInst
set oid to inst.
void zOID_setInst(
OID* oid,
Module* mod,
Inst** path,
int plen,
Inst* inst
);
zOID_setInstFromPin
set oid to inst from pin.
void zOID_setInstFromPin(
OID* oid,
const OID* pinOid
);
zOID_pinInstName
return name of inst.
const char* zOID_pinInstName(
const OID* oid
);
zOID_pinInstPath
get the inst path string.
const char* zOID_pinInstPath(
const OID* oid,
DStr* buf,
char delim
);
zOID_pinInst
return inst.
Inst* zOID_pinInst(
const OID* oid
);
zOID_pinInstRef
return referenced cell of inst.
Cell* zOID_pinInstRef(
const OID* oid
);
zOID_pinName
return name of pin.
const char* zOID_pinName(
const OID* oid
);
zOID_pinNo
return number of pin.
int zOID_pinNo(
const OID* oid
);
zOID_portName
return name of port.
const char* zOID_portName(
const OID* oid
);
zOID_portDir
return dir of port.
PortFlags zOID_portDir(
const OID* oid
);
zOID_setNetFromPin
set oid to net, get path from pinOid.
void zOID_setNetFromPin(
OID* oid,
const OID* pinOid,
Net* net
);
The ZDB Flat View Manager
Data Types for the Flat Tree
Supported Node Types
typedef unsigned char FNodeType;
Supported Flat Flags
typedef unsigned char FNodeFlags;
#define FNodeFNone 0x00
#define FNodeFOrange 0x01
#define FNodeFCyan 0x02
#define FNodeFBlack 0x04
#define FNodeFWhite 0x08
#define FNodeFMagenta 0x40
#define FNodeFTarget 0x80
#define FNodeFVisited 0x10
#define FNodeFAll 0xff
Flat Attribute Structure
typedef struct FAttr {
const char* name;
const char* value;
int nlen; /* length of name */
} FAttr;
zFlatFree
Delete complete Top Node incl. tree from module defined by the given OID. If OID == NULL then all flat views are deleted.
zBool zFlatFree(
DB* db,
const OID* oid
);
zFlatFreeByModule
Delete complete Top Node incl. tree from module.
void zFlatFreeByModule(
DB* db,
Module* mod
);
zFlatClearCache
Clear the flat tree cache.
void zFlatClearCache(
DB* db
);
zFlatCompress
Compress complete flat tree of module defined by given OID.
zBool zFlatCompress(
DB* db,
const OID* oid
);
zFlatValidate
Validate the flat tree.
zBool zFlatValidate(
DB* db,
const OID* oid,
zBool pedantic
);
zFlatWrite
Process nodes using zFlatWriteCB to write using OIDs. Starting from module defined by the given OID. If OID == NULL then all flat views are written out. For each hicol, flags, attr which is set in the tree a function from the given callbacks is called.
struct zWriteInfo;
struct zFlatWriteCB {
void (*writeHicol)(
struct zWriteInfo* writeInfo,
const char* oid,
HiCol* hicol
);
void (*writeFlags)(
struct zWriteInfo* writeInfo,
const char* oid,
FNodeFlags flags
);
void (*writeAttrs)(
struct zWriteInfo* writeInfo,
const char* oid,
FAttr* attrs,
int c
);
void (*writeOOMRs)(
struct zWriteInfo* writeInfo,
const char* pinOid,
const char* netOid
);
void (*writeId)(
struct zWriteInfo* writeInfo,
const char* oid,
zUInt64 id
);
};
zBool zFlatWrite(
DB* db,
const OID* oid,
struct zWriteInfo* writeInfo,
struct zFlatWriteCB* callbacks
);
zFlatPreprocessTree
write hier tree to ascii file. create fnode→uniqNo mapping in populateInfo create module→hierNodes list mapping in populateInfo.
void zFlatPreprocessTree(
DB* db,
struct zWriteInfo* writeInfo
);
zFlatWriteTree
write hier trees to ascii file.
void zFlatWriteTree(
DB* db,
struct zWriteInfo* writeInfo
);
zFlatWriteModuleChildNodes
Write flat data for given module into ascii file.
struct FNode;
void zFlatWriteModuleChildNodes(
DB* db,
struct zWriteInfo* writeInfo,
Module* mod
);
zFlatDump
Dump flat tree structures starting from module defined by the given OID into the given file pointer. If OID == NULL then all flat views are dumped.
zBool zFlatDump(
DB* db,
const OID* oid,
IOWriter* wrt
);
zFlatDumpFile
Dump flat tree structures starting from module defined by the given OID into the given file. If OID == NULL then all flat views are dumped.
zBool zFlatDumpFile(
DB* db,
const OID* oid,
const char* fname,
IOType type
);
zFlatDeleteZombies
Executes deleteZombie for each node in the flat tree.
zBool zFlatDeleteZombies(
DB* db,
Module* topMod
);
FlatForeachCallback
The FlatForeachCallback (callback functions) are called for each visited object (the given "ctx" is passed to the callback function). The FlatForeachCallback expect to return 0 for ok and continue, 1 for break, 2 for return and -1 on error.
typedef int FlatForeachCallback(
void* ctx,
const OID*
);
typedef int FlatForeachCallback2(
void* ctx,
const OID*,
HiCol*,
const char* attrVal
);
zFlatForeachSignal
Traverse the design hierarchy tree top down and call the given callback function for each signal.
int zFlatForeachSignal(
DB* db,
const OID* top,
zBool skipGlobal,
zBool skipConst,
zBool autoPopulate,
FlatForeachCallback* foreachCB,
void* foreachCtx
);
zFlatForeachNet
Call the given callback function for each net of a signal.
int zFlatForeachNet(
DB* db,
const OID* netOID,
zBool skipGlobal,
zBool skipConst,
zBool autoPopulate,
FlatForeachCallback* foreachCB,
void* foreachCtx
);
zFlatForeachPin
Call the given callback function for each pin or port connected to the given signal.
int zFlatForeachPin(
DB* db,
const OID* netOID,
zBool addHier,
zBool stopHier,
zBool skipConst,
zBool autoPopulate,
FlatForeachCallback* foreachCB,
void* foreachCtx
);
zFlatForeachNetSeg
Call the given callback function for each net segment between the two given pin/port OIDs.
int zFlatForeachNetSeg(
DB* db,
const OID* startOID,
const OID* endOID,
zBool skipConst,
zBool autoPopulate,
FlatForeachCallback* foreachCB,
void* foreachCtx
);
zFlatForeachObj
Call the given callback function for each node in the flat tree.
int zFlatForeachObj(
DB* db,
const OID* topOid,
FlatForeachCallback2* foreachCB,
void* foreachCtx,
FNodeFlags flagged,
const char* attrName,
zBool hilight,
zBool skipInvalid,
zBool autoPopulate
);
zFlatForeachInst
Traverse the hierarchy tree rooted at given module OID and call the given callback function for each instance of a cell with the given flag set. If flag == 0, then traverse all instances of all Cells. Return same as foreachCB: 0 (ok), 1 (break), 2 (return), -1 (error). or -2 (usage error, msg in zLastErrorMsg) If once == zTrue, then report only one inst of each referenced cell.
int zFlatForeachInst(
DB* db,
OID oid,
CellFlags flag,
zBool once,
zBool autoPopulate,
FlatForeachCallback* foreachCB,
void* foreachCtx
);
zFlatSignalOf
Get the signal of a given net.
zBool zFlatSignalOf(
DB* db,
const OID* net,
zBool skipGlobal,
zBool skipConst,
zBool autoPopulate,
OID* result
);
zFlatCountSignal
Count the number of signals.
zLong zFlatCountSignal(
DB* db,
const OID* top,
zBool autoPopulate
);
zFlatCountNet
Count the number of nets of a signal.
zLong zFlatCountNet(
DB* db,
const OID* netOID,
zBool autoPopulate
);
zFlatCountPin
Count the number of pins and ports connected to the given signal.
zLong zFlatCountPin(
DB* db,
const OID* netOID,
zBool addHier,
zBool stopHier,
zBool autoPopulate
);
zFlatCountNetSeg
Count the number of net segments between the two given pin/port OIDs.
zLong zFlatCountNetSeg(
DB* db,
const OID* startOID,
const OID* endOID,
zBool autoPopulate
);
zFlatAddAttrs
Add a new attribute to the given OID. If 'propagate' is true, all nets of signal are processed. For netbuses the first member is followed as long as there are 1-1 connection through the hierarchy.
zBool zFlatAddAttrs(
DB* db,
const OID* oid,
const FAttr attr[],
int len,
zBool propagate
);
zFlatSetAttrs
Same as zFlatAddAttr but attributes with the same name are overwritten.
zBool zFlatSetAttrs(
DB* db,
const OID* oid,
const FAttr attr[],
int len,
zBool propagate
);
zFlatGetAttrs
Get attributes into attr until a maximum of len elements.
int zFlatGetAttrs(
DB* db,
const OID* oid,
FAttr attr[],
int len
);
zFlatGetAttrsSorted
Get attributes into attr until a maximum of len elements. Sorted by name.
int zFlatGetAttrsSorted(
DB* db,
const OID* oid,
FAttr attr[],
int len
);
zFlatDelAttrs
Delete attribute at the given OID, if name is NULL delete all attribute of given OID.
zBool zFlatDelAttrs(
DB* db,
const OID* oid,
const char** names
);
zFlatDelAttrsAll
Recursively traverses the whole tree and delete attributes with given names.
zBool zFlatDelAttrsAll(
DB* db,
const OID*,
const char** name
);
zFlatSearchModuleAttrValue
Get flat module attribute value.
const char* zFlatSearchModuleAttrValue(
DB* db,
const char* attrName,
const char* topinfo,
const char* path,
zBool exact
);
zFlatSearchPrimitiveAttrValue
Get flat primitive attribute value.
const char* zFlatSearchPrimitiveAttrValue(
DB* db,
const char* attrName,
const char* topinfo,
const char* path,
zBool exact
);
zFlatSearchInstAttrValue
Get flat inst attribute value.
const char* zFlatSearchInstAttrValue(
DB* db,
Inst* inst,
const char* attrName,
const char* topinfo,
const char* path,
zBool exact
);
zFlatSearchPortAttrValue
Get flat port attribute value.
const char* zFlatSearchPortAttrValue(
DB* db,
Port* port,
const char* attrName,
const char* topinfo,
const char* path,
zBool exact
);
zFlatSearchPortBusAttrValue
Get flat portBus attribute value.
const char* zFlatSearchPortBusAttrValue(
DB* db,
PortBus* portBus,
const char* attrName,
const char* topinfo,
const char* path,
zBool exact
);
zFlatSearchPinAttrValue
Get flat pin attribute value.
const char* zFlatSearchPinAttrValue(
DB* db,
Inst* inst,
int pinNo,
const char* attrName,
const char* topinfo,
const char* path,
zBool exact
);
zFlatSearchPinBusAttrValue
Get flat pinBus attribute value.
const char* zFlatSearchPinBusAttrValue(
DB* db,
Inst* inst,
int pinBusNo,
const char* attrName,
const char* topinfo,
const char* path,
zBool exact
);
zFlatSearchSignalAttrValue
Get flat signal attribute value.
const char* zFlatSearchSignalAttrValue(
DB* db,
Net* signal,
const char* attrName,
const char* topinfo,
const char* path,
zBool exact
);
zFlatSearchNetAttrValue
Get flat net attribute value.
const char* zFlatSearchNetAttrValue(
DB* db,
Net* net,
const char* attrName,
const char* topinfo,
const char* path,
zBool exact
);
zFlatSearchNetBusAttrValue
Get flat netBus attribute value.
const char* zFlatSearchNetBusAttrValue(
DB* db,
NetBus* netBus,
const char* attrName,
const char* topinfo,
const char* path,
zBool exact
);
zFlatSearchInstHilight
Get flat inst hilight info.
zBool zFlatSearchInstHilight(
DB* db,
const char* topInfo,
const char* path,
Inst* inst,
int* color,
int* flags
);
zFlatSearchPortHilight
Get flat port hilight info.
zBool zFlatSearchPortHilight(
DB* db,
const char* topInfo,
const char* path,
Port* port,
int* color
);
zFlatSearchPortBusHilight
Get flat portBus hilight info.
zBool zFlatSearchPortBusHilight(
DB* db,
const char* topInfo,
const char* path,
PortBus* portBus,
int* color
);
zFlatSearchPinHilight
Get flat pin hilight info.
zBool zFlatSearchPinHilight(
DB* db,
const char* topInfo,
const char* path,
Inst* inst,
int pinNo,
int* color
);
zFlatSearchPinBusHilight
Get flat pinBus hilight info.
zBool zFlatSearchPinBusHilight(
DB* db,
const char* topInfo,
const char* path,
Inst* inst,
int pinBusNo,
int* color
);
SegmentHi
Struct to store flat segment hilight.
struct SegmentHi {
struct {
Inst* inst;
const char* pinName;
zBool isPort;
} con[2];
int color;
};
zFlatSearchNetHilight
Get flat net hilight info.
zBool zFlatSearchNetHilight(
DB* db,
Module* mod,
const char* topInfo,
const char* path,
Net* net,
int* color,
struct SegmentHi** segmentArray
);
zFlatSearchNetBusHilight
Get flat netBus hilight info.
zBool zFlatSearchNetBusHilight(
DB* db,
const char* topInfo,
const char* path,
NetBus* netBus,
int* color
);
zFlatNodeMakeInst
Make a flat node for an instance.
struct FNode* zFlatNodeMakeInst(
DB* db,
Module* root,
struct FNode* node,
Inst* inst
);
zFlatNodeMakeNet
Make a flat node for a net.
struct FNode* zFlatNodeMakeNet(
DB* db,
Module* root,
struct FNode* node,
Net* net
);
zFlatNodeMakeSignal
Make a flat node for a signal.
struct FNode* zFlatNodeMakeSignal(
DB* db,
Module* root,
struct FNode* node,
Net* net
);
zFlatNodeAddAttrs
Add attributes to a given node.
zBool zFlatNodeAddAttrs(
DB* db,
struct FTopNode* topNode,
struct FNode* node,
const FAttr attr[],
int len
);
zFlatNodeSetAttrs
Set attributes at a given node.
zBool zFlatNodeSetAttrs(
DB* db,
struct FTopNode* topNode,
struct FNode* node,
const FAttr attr[],
int len
);
zFlatNodeGetAttrs
Get attributes at a given node.
int zFlatNodeGetAttrs(
DB* db,
struct FTopNode* topNode,
struct FNode* node,
FAttr attr[],
int len
);
zFlatNodeDelAttrs
Delete attributes at a given node.
zBool zFlatNodeDelAttrs(
DB* db,
struct FTopNode* topNode,
struct FNode* node,
const char** names
);
zFlatGetAttrsMerged
Get merged flat and module based attributes at the given node.
int zFlatGetAttrsMerged(
DB* db,
const OID* oid,
FAttr attr[],
int len
);
zFlatGetAttrsMergedSorted
Get merged flat and module based attributes at the given node, sorted by name.
int zFlatGetAttrsMergedSorted(
DB* db,
const OID* oid,
FAttr attr[],
int len
);
zFlatNodeGetAttrValue
Get attribute value at a given node.
const char* zFlatNodeGetAttrValue(
DB* db,
Module* root,
struct FNode* node,
const char* name
);
zFlatGetAttrValue
Get flat attribute value of the given OID.
const char* zFlatGetAttrValue(
DB* db,
const OID* oid,
const char* name
);
zFlatGetAttrValueMerged
Get merged flat and module based attributes at the given OID.
const char* zFlatGetAttrValueMerged(
DB* db,
const OID* oid,
const char* name
);
zFlatStr2Flag
Convert a string into a flat flag.
FNodeFlags zFlatStr2Flag(
const char* str
);
zFlatFlag2Strs
Convert flags into strings. Return the number flags.
int zFlatFlag2Strs(
FNodeFlags flags,
const char* strs[10]
);
zFlatGetFlags
Return a bit vector of flags.
FNodeFlags zFlatGetFlags(
DB* db,
const OID* oid
);
zFlatGet5Flags
Like zFlatGetFlags above, but if called with a pin OID the search at inst+pin+pinBus+port+portBus and if called with oid=port then also search port+portBus.
FNodeFlags zFlatGet5Flags(
DB* db,
const OID* oid
);
#ifdef COMPARE_CONE
FNodeFlags zFlatGet5FlagsX(
DB* db,
const OID* oid,
zBool* fromPort
);
#endif
zFlatIsFlag
Set zTrue or zFalse depending on the flag state to the given 'isSet' zBool pointer and returns zTrue on success or zFalse on error (zLastErrorMsg is set).
zBool zFlatIsFlag(
DB* db,
const OID* oid,
FNodeFlags flag,
zBool* isSet
);
zFlatSetFlag
Store the old flag values through the "prevFlags" argument (if not NULL) and sets the given flags. Return zTrue on success or zFalse on error (zLastErrorMsg is set).
zBool zFlatSetFlag(
DB* db,
const OID* oid,
FNodeFlags flag,
FNodeFlags* prevFlags
);
zFlatClrFlag
Like zFlatSetFlag above but also clear the given flag.
zBool zFlatClrFlag(
DB* db,
const OID* oid,
FNodeFlags flag,
FNodeFlags* prevFlags
);
zFlatClrFlagAll
Like zFlatClrFlag but clear flags at all flat-tree nodes.
zBool zFlatClrFlagAll(
DB* db,
const OID* oid,
FNodeFlags flag
);
zFlatGetFlagOIDs
Return q list of all oids which have the given flag set.
zBool zFlatGetFlagOIDs(
DB* db,
const OID* top,
FNodeFlags flag,
OID** resultList
);
zFlatHilightSet
Hilight Function to set flat highlight information.
zBool zFlatHilightSet(
DB* db,
const OID* oid,
int color,
int permanent
);
zFlatHilightGet
Hilight Function to get flat highlight information.
zBool zFlatHilightGet(
DB* db,
const OID* oid,
int* color,
int permanent
);
zFlatHilightGetMerged
Hilight Function to get flat and module based highlight information.
zBool zFlatHilightGetMerged(
DB* db,
const OID* oid,
int* color,
int permanent
);
zFlatHilightGetSignalOrNet
Get hicolor of signal or first associated net which has a color.
zBool zFlatHilightGetSignalOrNet(
DB* db,
const OID* oid,
int* color,
int permanent
);
zFlatHilightDelAll
Hilight Function to delete flat highlight information.
zBool zFlatHilightDelAll(
DB* db,
const OID* top,
int color,
int permanent
);
OOMPinRef
Struct to store flat connectivity (OOMR: Out-Of-Module References).
struct OOMPinRef {
const char* hinstname;
int pinNo;
};
zFlatAddOOMR
Add an OOMR connection.
zBool zFlatAddOOMR(
DB* db,
const OID* pin,
const OID* net
);
zFlatDelOOMR
Del an OOMR connection.
zBool zFlatDelOOMR(
DB* db,
const OID* pin
);
zFlatGetOOMR
Get OOMR connections.
zBool zFlatGetOOMR(
DB* db,
const OID* oid,
OID** resultListPtr
);
FlatForeachOOMRCallback
The FlatForeachOOMRCallback (callback functions) are called for each oomr entry pair (the given "ctx" is passed to the callback function). The FlatForeachOOMRCallback expect to return 0 for ok and continue, 1 for break, 2 for return and -1 on error.
typedef int FlatForeachOOMRCallback(
void* ctx,
const OID* pinOid,
const OID* netOid
);
zFlatForeachOOMR
Iterate over all flat oomr entries.
int zFlatForeachOOMR(
DB* db,
const OID* topMod,
FlatForeachOOMRCallback* foreachCB,
void* foreachCtx
);
zFlatGetOOMPinList
From a given hierarchical net return: (a) top module (b) list of connected instance pins (as a list of OOMPinRef) path is separated by db→internalHierSep. Return false if the hierarchical net has non stored pin connections.
zBool zFlatGetOOMPinList(
DB* db,
const char* topinfo,
const char* path,
const Net* net,
Module** topPtr,
struct OOMPinRef** oomrListPtr,
zBool* allocated
);
zFlatGetOOMNet
From a given vdiHinst + pinNo return the hierarchical name to the connected net (db.hiersep separated string). Return NULL if the given pin is unconnected.
const char* zFlatGetOOMNet(
DB* db,
const char* topinfo,
const char* path,
const Inst* inst,
int pinNo
);
zFlatMoveInsts
Update Data Tree after zOperHierStart/zOperHierAdd
int zFlatMoveInsts(
DB* db,
Module* top,
const char* iname,
Module* from,
Module* to
);
zFlatUpdateAddHier
Update Data Tree after zOper*Hier has added/removed one level of Hierarchy.
zBool zFlatUpdateAddHier(
DB* db,
Module* parent,
InstFlags movedIFlag,
NetFlags movedNFlag,
NetFlags crossedNFlag,
Inst* newInst
);
zFlatUpdateRmHier
zBool zFlatUpdateRmHier(
DB* db,
Module* parent,
Inst* rmInst,
NetFlags movedNFlag,
NetFlags crossedNFlag,
const char* prefix
);
zFlatCreateHier
Update Data Tree after zOperCreateHier.
zBool zFlatCreateHier(
DB* db,
Module* topMod,
char hsep
);
zFlatUpdateSortPorts
Update Data Tree after zOperPortSorts.
zBool zFlatUpdateSortPorts(
DB* db,
Module* top,
CellFlags flags
);
zFlatUpdatePortNos
Update Data Tree after with shuffled port numbers.
zBool zFlatUpdatePortNos(
DB* db,
Module* top,
Cell* modifiedCell,
int* portNoMap
);
zFlatTreeMemoryUsage
Return total flat tree memory usage.
zULong zFlatTreeMemoryUsage(
struct FTopNode* top,
unsigned* cnt
);
zFlatTreeStrmemUsage
Return total string memory usage.
zULong zFlatTreeStrmemUsage(
struct FTopNode* top,
unsigned* cnt
);
zFlatMapAttr
Map instance attributes in tree.
struct Symlib;
struct Cell2SpiceMapping;
zBool zFlatMapAttr(
DB* db,
struct Cell2SpiceMapping* mapTable
);
zFlatAddAttrName
Add attribute name used for packAttrs format.
void zFlatAddAttrName(
DB* db,
struct FTopNode* top,
const char* name,
int nlen
);
zFlatNewTopNode
Create a top node starting at module root. Preallocate attrNameCnt attribute name entries.
struct FTopNode* zFlatNewTopNode(
DB* db,
Module* root,
int attrNameCnt
);
zFlatMakeTopNode
Create a new top node starting at module root, if it no already exists.
struct FTopNode* zFlatMakeTopNode(
DB* db,
Module* root,
int attrNameCnt
);
zFlatGetRootNode
Get root of flat data node from topNode. preallocate subListCnt sub node entries.
struct FNode* zFlatGetRootNode(
DB* db,
struct FTopNode* top,
int subListCnt
);
zFlatNewInstNode
Create a new flat inst node below the given parent node. preallocate subListCnt sub node entries. The given name should match to be hierarchical object. If it does not match it can not be accessed later and will be complained by validating with 'pedantic'.
struct FNode* zFlatNewInstNode(
DB* db,
struct FTopNode* top,
struct FNode* parent,
const char* name,
int subListCnt
);
zFlatMakeInstNode
Return exiting inst node or create a new flat inst node below the given parent node. The given name should match to be hierarchical object. If it does not match it can not be accessed later and will be complained by validating with 'pedantic'.
struct FNode* zFlatMakeInstNode(
DB* db,
struct FTopNode* top,
struct FNode* parent,
const char* name
);
zFlatMakeInstNodes
Create a new flat inst node path below the given parent node. All nodes on the given NULL terminated path array are created if the do not already exist. The given name should match to be hierarchical object. If it does not match it can not be accessed later and will be complained by validating with 'pedantic'.
struct FNode* zFlatMakeInstNodes(
DB* db,
struct FTopNode* top,
struct FNode* parent,
const char** path
);
zFlatNewNetNode
Create a new flat net node below the given parent node. The given name should match to the hierarchical object. If it does not match it can not be accessed later and will be complained by validating with 'pedantic'.
struct FNode* zFlatNewNetNode(
DB* db,
struct FTopNode* top,
struct FNode* parent,
const char* name
);
zFlatMakeNetNode
Search/create a flat net node below the given parent node. The given name should match to the hierarchical object. If it does not match it can not be accessed later and will be complained by validating with 'pedantic'.
struct FNode* zFlatMakeNetNode(
DB* db,
struct FTopNode* top,
struct FNode* parent,
const char* name
);
zFlatMakeNetBusNode
Search/create a flat netBus node below the given parent node. The given name should match to the hierarchical object. If it does not match it can not be accessed later and will be complained by validating with 'pedantic'.
struct FNode* zFlatMakeNetBusNode(
DB* db,
struct FTopNode* top,
struct FNode* parent,
const char* name
);
zFlatMakeSignalNode
Search/create a flat Signal node below the given parent node. The given name should match to the hierarchical object. If it does not match it can not be accessed later and will be complained by validating with 'pedantic'.
struct FNode* zFlatMakeSignalNode(
DB* db,
struct FTopNode* top,
struct FNode* parent,
const char* name
);
zFlatMakePinNode
Search/create a flat pin node below the given parent node. The given name should match to the hierarchical object. If it does not match it can not be accessed later and will be complained by validating with 'pedantic'.
struct FNode* zFlatMakePinNode(
DB* db,
struct FTopNode* top,
struct FNode* parent,
const char* name
);
zFlatMakePinBusNode
Search/create a flat pinBus node below the given parent node. The given name should match to the hierarchical object. If it does not match it can not be accessed later and will be complained by validating with 'pedantic'.
struct FNode* zFlatMakePinBusNode(
DB* db,
struct FTopNode* top,
struct FNode* parent,
const char* name
);
zFlatMakePortNode
Search/create a flat port node below the given parent node. The given name should match to the hierarchical object. If it does not match it can not be accessed later and will be complained by validating with 'pedantic'.
struct FNode* zFlatMakePortNode(
DB* db,
struct FTopNode* top,
struct FNode* parent,
const char* name
);
zFlatMakePortBusNode
Search/create a flat port bus node below the given parent node. The given name should match to the hierarchical object. If it does not match it can not be accessed later and will be complained by validating with 'pedantic'.
struct FNode* zFlatMakePortBusNode(
DB* db,
struct FTopNode* top,
struct FNode* parent,
const char* name
);
zFlatNewNetOOMRNode
Create a new flat NetOOMR node below the given parent node. The given name should match to the hierarchical object. If it does not match it can not be accessed later and will be complained by validating with 'pedantic'.
struct FNode* zFlatNewNetOOMRNode(
DB* db,
struct FTopNode* top,
struct FNode* parent,
const char* name
);
zFlatNewNetSegNode
Create a new flat NetSeg node below the given parent node. The given name should match to the hierarchical object. If it does not match it can not be accessed later and will be complained by validating with 'pedantic'.
struct FNode* zFlatNewNetSegNode(
DB* db,
struct FTopNode* top,
struct FNode* parent,
const char* name,
int pin0,
int pin1
);
zFlatMakeNetSegNode
Search/create a flat NetSeg node below the given parent node. The given name should match to the hierarchical object. If it does not match it can not be accessed later and will be complained by validating with 'pedantic'.
struct FNode* zFlatMakeNetSegNode(
DB* db,
struct FTopNode* top,
struct FNode* parent,
const char* name,
int pin0,
int pin1
);
zFlatNewPortNode
Create a new flat port node below the given parent node. The given name should match to the hierarchical object. If it does not match it can not be accessed later and will be complained by validating with 'pedantic'.
struct FNode* zFlatNewPortNode(
DB* db,
struct FTopNode* top,
struct FNode* parent,
const char* name
);
zFlatNewPortBusNode
Create a new flat portBus node below the given parent node. The given name should match to the hierarchical object. If it does not match it can not be accessed later and will be complained by validating with 'pedantic'.
struct FNode* zFlatNewPortBusNode(
DB* db,
struct FTopNode* top,
struct FNode* parent,
const char* name
);
zFlatNewPinNode
Create a new flat net node below the given parent node. The given name should match to the hierarchical object. If it does not match it can not be accessed later and will be complained by validating with 'pedantic'.
struct FNode* zFlatNewPinNode(
DB* db,
struct FTopNode* top,
struct FNode* parent,
const char* name
);
zFlatNewPinBusNode
Create a new flat net node below the given parent node. The given name should match to the hierarchical object. If it does not match it can not be accessed later and will be complained by validating with 'pedantic'.
struct FNode* zFlatNewPinBusNode(
DB* db,
struct FTopNode* top,
struct FNode* parent,
const char* name
);
zFlatNewNetIdNode
Create a new flat net id node below the given parent node. The given name should match to the hierarchical object. If it does not match it can not be accessed later and will be complained by validating with 'pedantic'.
struct FNode* zFlatNewNetIdNode(
DB* db,
struct FTopNode* top,
struct FNode* parent,
const char* name
);
zFlatNewNetBusIdNode
Create a new flat net bus id node below the given parent node. The given name should match to the hierarchical object. If it does not match it can not be accessed later and will be complained by validating with 'pedantic'.
struct FNode* zFlatNewNetBusIdNode(
DB* db,
struct FTopNode* top,
struct FNode* parent,
const char* name
);
zFlatNewSignalIdNode
Create a new flat signal id node below the given parent node. The given name should match to the hierarchical object. If it does not match it can not be accessed later and will be complained by validating with 'pedantic'.
struct FNode* zFlatNewSignalIdNode(
DB* db,
struct FTopNode* top,
struct FNode* parent,
const char* name
);
zFlatNewNamedNode
Create a new flat node below the given parent node. Internal use only. The given name should match to the hierarchical object. If it does not match it can not be accessed later and will be complained by validating with 'pedantic'.
struct FNode* zFlatNewNamedNode(
DB* db,
struct FTopNode* top,
struct FNode* parent,
FNodeType type,
const char* name,
int subListCnt
);
zFlatNewIndexedNode
Create new flat node below the given parent node. Internal use only. The given index should match the hierarchical object. If it does not match it can not be accessed later and will be complained by validating with 'pedantic'.
struct FNode* zFlatNewIndexedNode(
DB* db,
struct FNode* parent,
FNodeType type,
int index
);
zFlatNewPinOOMRNode
Create new flat node below the given parent node. Internal use only. The given index should match the hierarchical object. If it does not match it can not be accessed later and will be complained by validating with 'pedantic'.
struct FNode* zFlatNewPinOOMRNode(
DB* db,
struct FTopNode* top,
struct FNode* parent,
int index,
const char* hnetname
);
zFlatSetFlags
Set flag for the object represented by the flat node.
void zFlatSetFlags(
struct FNode* node,
FNodeFlags flags
);
zFlatSetHicol
Set normal and permanent highlight color for the object represented by the flat node.
void zFlatSetHicol(
struct FNode* node,
int norm,
int perm
);
zFlatSetPackedAttrs
Set attributes of given node in packedAttrs format. Internal use only.
void zFlatSetPackedAttrs(
DB* db,
struct FTopNode* top,
struct FNode* node,
const char* packedAttrs
);
zFlatSetPackedAttrsLen
Set attributes of given node in packedAttrs format. For speed, if len of packedAttrs is already known Internal use only.
void zFlatSetPackedAttrsLen(
DB* db,
struct FTopNode* top,
struct FNode* node,
const char* packedAttrs,
int len
);
zFlatNewPackedAttrNode
Add attributes of given node in packedAttrs format. Internal use only.
struct FNode* zFlatNewPackedAttrNode(
DB* db,
struct FTopNode* top,
struct FNode* parent,
const char* packedAttrs
);
zFlatNewPackedAttrNodeLen
Add attributes of given node in packedAttrs format. Internal use only.
struct FNode* zFlatNewPackedAttrNodeLen(
DB* db,
struct FTopNode* top,
struct FNode* parent,
const char* packedAttrs,
int len
);
zFlatSetNetSeg
Set net segment pin indices Internal use only.
void zFlatSetNetSeg(
struct FNode* node,
int pin0,
int pin1
);
zFlatSetPinOOMR
Set oomr info for given node. Internal use only.
void zFlatSetPinOOMR(
DB* db,
struct FTopNode* top,
struct FNode* node,
const char* hnetname
);
zFlatAddNetOOMR
Set oomr info for given node. Internal use only.
void zFlatAddNetOOMR(
DB* db,
struct FTopNode* top,
struct FNode* node,
const char* hinstname,
int pinNo
);
zFlatNodeSetId
Set id for given node. Internal use only.
void zFlatNodeSetId(
struct FNode* node,
zUInt64 id
);
zFlatClone
Clone flat info to another database 'dst'. If at least one of 'keepCell','keepInst','keepPos' is not 0 only flagged objects are cloned and invalid entries are ignored.
zBool zFlatClone(
DB* src,
DB* dst,
CellFlags keepCell,
InstFlags keepInst,
NetFlags keepNet,
PortFlags keepPort,
const char** prefixPath,
int prefixPathLen
);
zFlatMerge
Merge flat info to another database 'dst'.
zBool zFlatMerge(
DB* src,
DB* dst,
const char** prefixPath,
int prefixPathLen
);
zFlatSetId
Set a new id to the given OID.
zBool zFlatSetId(
DB* db,
const OID* oid,
zUInt64 id
);
zFlatGetId
Get a id to the given OID.
zBool zFlatGetId(
DB* db,
const OID* oid,
zUInt64* id
);
The Symlib File Scanner
Create Symlib Entries in the Database
zSymlibCreate
Create a symlib file.
zBool zSymlibCreate(
DB* db,
const char* filename
);
zSymlibScan
In normal mode, use symTable to lookup symbols (fast). In glob mode, loop over all cells and try to sequential match sym entries (slow).
zBool zSymlibScan(
DB* db,
zBool force
);
zSymlibCopy
Create primitives for each symbol. If withSpiceSymbols is zTrue additional primitives for spice mappings are created (if they do not contain pattern names with * and ?(.
zBool zSymlibCopy(
DB* db,
zBool withSpiceSymbols
);
zSymlibCheck
Check the value of the given @symbol attribute.
zBool zSymlibCheck(
DB* db,
Cell* cell,
const char* value,
zBool icase
);
zSymlibAdd
Parse whole file into db. Store header infos in Symlib struct. Symbols in symList, symio info in symioList, spice info in spiceList. If index mode store comments in commentList if there is no symlib allocate it.
zBool zSymlibAdd(
DB* db,
const char* fname,
zBool withComments
);
zSymlibParseStr
Like zSymlibAdd but read the input from a string.
zBool zSymlibParseStr(
DB* db,
const char* str,
zBool withComments
);
zSymlibParseDB
Look for @symbol attributes in DB at all cells and store them in Symlib struct. If the value of the Boolean parameter 'fromFunc' is true and no @symbol attribute was found at a cell but the cell has a function defined then also add a symbol entry for based on the function to the Symlib struct.
zBool zSymlibParseDB(
DB* db,
zBool fromFunc
);
zSymlibClear
Delete symlib structure. Clear symdef table and all @sym and @symbol attributes, the @libName attribute used for skillexport will be removed too (slow, because all objects need to be checked).
zBool zSymlibClear(
DB* db
);
zSymlibInfo
Get header infos out of first symlib. libName is returned in zLastErrorMsg Return zFalse if there is no symlib.
zBool zSymlibInfo(
DB* db,
zUInt16* vers,
zBool* icase,
zBool* glob
);
zSymlibGitRevisions
List of revisions of all symlibs. need to be zArrayFree-d.
const char** zSymlibGitRevisions(
DB* db
);
zSymlibScanSymDef
zBool zSymlibScanSymDef(
int argc,
char** argv,
zBool ic,
int** indexListPtr
);
zSymlibRemove
Remove all symlibs.
void zSymlibRemove(
DB* db
);
zSymlibMapGet
Search spice mappings for the given cell.
struct Symlib;
struct Cell2SpiceMapping;
struct Sspice;
struct Sspice* zSymlibMapGet(
struct Cell2SpiceMapping* mapTable,
Cell* cell
);
zSymlibMapAttrFind
Find a given attr name in attrmapList.
const char* zSymlibMapAttrFind(
struct Sspice* spice,
const char* name
);
zSymlibWrite
Write symlib file to ASCII format.
struct zWriteInfo;
void zSymlibWrite(
struct zWriteInfo* writeInfo
);
zSymlibNew
Add symlib to DB.
struct Symlib* zSymlibNew(
DB* db,
const char* libname,
double version,
const char* gitRevision,
zBool icase,
zBool glob,
zBool microsoft
);
zSymlibNewIO
struct Ssymio* zSymlibNewIO(
DB* db,
struct Symlib* symlib,
zFPos start,
const char* sname,
char type,
const char* oname,
const char* mname,
const char* lname,
const char* pname,
const char* netset
);
zSymlibNewSpice
struct Sspice* zSymlibNewSpice(
DB* db,
struct Symlib* symlib,
const char* sname,
const char* lname,
const char* mname,
const char* bulkattr,
const char* bulktype,
const char* prefix,
zFPos start,
zBool rename,
zBool icase
);
zSymlibNewBulk
void zSymlibNewSpiceBulk(
DB* db,
struct Sspice* spice,
const char* bulkattr,
const char* bulktype
);
enum SattrMapEvalType {
SattrMapEvalTeval, /* evaluate oname expression (e.g. "w/l" -> 2)*/
SattrMapEvalTconstant, /* use oname string as is (e.g. "w/l" -< "w/l")*/
SattrMapEvalTpartial /* eval without recursion (e.q. "w/l" -> "6/3")*/
};
zSymlibNewAttrMap
void zSymlibNewAttrMap(
DB* db,
struct Sspice* spice,
const char* mname,
const char* oname,
const char* type,
enum SattrMapEvalType evalType
);
zSymlibNewComment
if symlib is NULL use last symlib. return zFalse if there is no symlib.
zBool zSymlibNewComment(
DB* db,
struct Symlib* symlib,
const char* comment
);
zSymlibNewSymbol
struct Ssym* zSymlibNewSymbol(
DB* db,
struct Symlib* symlib,
const char* sname,
zFPos start,
int argc
);
zSymlibFillHashTable
call after all symbols are created.
void zSymlibFillHashTable(
DB* db,
struct Symlib* symlib
);
zSymlibNewSymArg
void zSymlibNewSymArg(
DB* db,
struct Symlib* symlib,
struct Ssym* sym,
int i,
const char* arg
);
zSymlibNewSymDefinition
zBool zSymlibNewSymDefinition(
DB* db,
struct Symlib* symlib,
struct Ssym* sym
);
zSymlibNewPortMap
void zSymlibNewPortMap(
DB* db,
struct Sspice* spice,
const char* mname,
const char* oname
);
zSymlibNewPortType
void zSymlibNewPortType(
DB* db,
struct Sspice* spice,
const char* oname,
const char* sigtype
);
zSymlibSetSymmapMode
void zSymlibSetSymmapMode(
DB* db,
struct Sspice* spice,
const char* symmapMode
);
Cone Extraction
Types for the Cone Extraction
Extraction Direction
Direction of the Cone extraction.
enum ConeEdir {
ConeEdirToOut = 0,
ConeEdirToIn = 1
};
Extraction Options
Target and extraction options.
#define ConeEFtargetIO 0x00001 /* Toplevel I/O ports */
#define ConeEFtargetDangle 0x00002 /* Dangling nets */
#define ConeEFtargetOpenPin 0x00004 /* Open pins */
#define ConeEFtargetOpenPort 0x00008 /* Open ports */
#define ConeEFtargetLoop 0x00010 /* Circuit loops */
#define ConeEFtargetPGNet 0x00020 /* Power/Ground nets (constant values) */
#define ConeEFtargetConstNet 0x00040 /* Constant value nets are target */
#define ConeEFdontDive 0x00100 /* Don't leave hierarchy-level */
#define ConeEFcheckArcs 0x00200 /* Consult zConeCalcArc() */
#define ConeEFcacheArcs 0x00400 /* Cache arcs at Modules */
#define ConeEFunknown2IO 0x00800 /* Pin-dir "unknown" is IO */
#define ConeEFcoarse 0x01000 /* Coarse the result */
#define ConeEFreachable 0x02000 /* Only targets to resultList */
#define ConeEFaddStartPin 0x04000 /* Add start pin to resultList */
#define ConeEFemptyModAsPrim 0x08000 /* Treat empty modules as primitives */
#define ConeEFflat 0x10000 /* Suppress hierarchical objs in result */
#define ConeEFcreateNetSeg 0x20000 /* Create net segments in result */
#define ConeEFautoPopulate 0x40000 /* Populate missing module content */
#define ConeEFprocessPGNets 0x80000 /* Continue tracing at PG nets */
#define ConeEFfilterLogicalInvalid 0x100000 /* filter paths with constant */
ResultPath
struct ResultPath {
OID* oidList; /* List of Segm of this path */
int depth; /* Number of logic levels */
};
typedef int (*ConeCustomCB)(void* ctx, const OID*);
Cone Extraction Function
zConeExtract
Start the Cone Extraction.
zBool zConeExtract(
const OID* startList, /* Extraction start list */
enum ConeEdir direction, /* Direction of the extraction */
zBool ignoreDir, /* Ignore module port dir */
unsigned flags, /* Extraction options */
CellFlags targetFlaggedCell, /* CellFxxx,... or 0 */
InstFlags targetFlaggedInst, /* InstFxxx,... or 0 */
PinFlags targetFlaggedPin, /* PortFxxx,... or 0 */
PortFlags targetFlaggedPort, /* PortFxxx,... or 0 */
NetFlags targetFlaggedNet, /* NetFxxx,... or 0 */
FNodeFlags targetFlatFlagged, /* FNodeFxxx,... or 0 */
FNodeFlags targetFlatNetNotFlagged,/*FNodeFxxx,... or 0 */
const OID* targetObj, /* target object or NULL */
DB* db, /* DB root */
const char** targetCell[4], /* 4 lists from -targetCell* */
const char** excludeCell, /* 1 list from -excludeCell */
CellFlags excludeFlaggedCell, /* CellFxxx,... or 0 */
InstFlags excludeFlaggedInst, /* InstFxxx,... or 0 */
PortFlags excludeFlaggedPin, /* PortFxxx,... or 0 */
PortFlags excludeFlaggedPort, /* PortFxxx,... or 0 */
NetFlags excludeFlaggedNet, /* NetFxxx,... or 0 */
FNodeFlags excludeFlatFlagged, /* FNodeFxxx,... or 0 */
int limit, /* Limit levels, 0 = no limit */
int pathLimit, /* Max # paths, 0 = no limit */
zBool excludeFuncPort, /* Exclude ports with special */
/* function (e.g. sel,clk) */
ConeCustomCB customCB, /* customize CB for pathList */
void* customCtx,
OID** resultList, /* RESULT: list of OIDs */
struct ResultPath** resultPathList /* RESULT: list of ResultPaths */
);
zConeExtractShortest
Special Cone Extraction.
zBool zConeExtractShortest(
const OID* startList, /* Extraction start list */
enum ConeEdir direction, /* Direction of the extraction */
zBool ignoreDir, /* Ignore module port dir */
unsigned flags, /* Extraction options */
CellFlags targetFlaggedCell, /* CellFxxx,... or 0 */
InstFlags targetFlaggedInst, /* InstFxxx,... or 0 */
PinFlags targetFlaggedPin, /* PortFxxx,... or 0 */
PortFlags targetFlaggedPort, /* PortFxxx,... or 0 */
NetFlags targetFlaggedNet, /* NetFxxx,... or 0 */
FNodeFlags targetFlatFlagged, /* FNodeFxxx,... or 0 */
FNodeFlags targetFlatNetNotFlagged,/*FNodeFxxx,... or 0 */
const OID* targetObj, /* target object or NULL */
DB* db, /* DB root */
const char** targetCell[4], /* 4 lists from -targetCell* */
const char** excludeCell, /* 1 list from -excludeCell */
CellFlags excludeFlaggedCell, /* CellFxxx,... or 0 */
InstFlags excludeFlaggedInst, /* InstFxxx,... or 0 */
PortFlags excludeFlaggedPin, /* PortFxxx,... or 0 */
PortFlags excludeFlaggedPort, /* PortFxxx,... or 0 */
NetFlags excludeFlaggedNet, /* NetFxxx,... or 0 */
FNodeFlags excludeFlatFlagged, /* FNodeFxxx,... or 0 */
zBool excludeFuncPort, /* Exclude ports with special */
/* function (e.g. sel,clk) */
OID* targetNets, /* Special for shortestPath */
OID** resultList, /* RESULT: list of OIDs */
OID*** resultLists /* RESULT: list of OIDs list */
);
zConeToPG
Find paths to Power/Ground over tdevices starting at given pin.
zBool zConeToPG(
DB* db,
PinRef* startPin,
zBool opposite,
int depthLimit,
int connLimit,
CellFlags excludeFlaggedCell,
InstFlags excludeFlaggedInst,
NetFlags onlyFlaggedNet,
PinRef** resultList
);
Define Arcs
Set/get "Arcs" at Operators (Module with a defined function).
Arc Functions
zConepClearArc
Clear user defined arcs of all (cellName == NULL) or only the given cell.
zBool zConepClearArc(
const char* cellname
);
zConepDefineArc
Add a user defined arc.
zBool zConepDefineArc(
const char* cellName,
const char* enterName,
const char** leaveNameList
);
zConepInvertArc
Invert user defined arcs of all (cellName == NULL) or only the given cell.
zBool zConepInvertArc(
const char* cellname
);
zConepUserdefArcCheck
Check user defined arcs and issue a warning if not all port arcs are defined.
void zConepUserdefArcCheck(
DB* db
);
zConepUserdefArcSet
Create user defined arc list from arcTab entries for the given cell.
void zConepUserdefArcSet(
DB* db,
Cell* cell,
CellFlags cflag,
PortFlags pflag
);
zConepCalcArcList
Calculate arc list for the port at the given cell.
int* zConepCalcArcList(
DB* db,
Cell* cell,
int port,
zBool toIn
);
Find Objects
Type Definitions for the Find API
Callback Return Value
The return value of the find callback function. zFindCallbackResult_Continue if the search should continue, zFindCallbackResult_Break if the search should stop, zFindCallbackResult_Error if an error has occurred.
typedef enum zFindCallbackResult_ {
zFindCallbackResult_Continue = 0,
zFindCallbackResult_Break = 1,
zFindCallbackResult_Error = 2
} zFindCallbackResult;
zFindCallbackResult
The zFindCallback callback function are called for each matching object. The given "context" is passed to the callback function.
The "oid" is referenced before the callback function is called, and is dereferenced afterwards.
typedef zFindCallbackResult (*zFindCallback)(void* context, const OID* oid);
zFindType
Specify the object type to find.
typedef enum zFindType_ {
zFindType_None = 0,
zFindType_Inst = (1 << 0),
zFindType_Port = (1 << 1),
zFindType_PortBus = (1 << 2),
zFindType_Net = (1 << 3),
zFindType_NetBus = (1 << 4),
zFindType_Pin = (1 << 5),
zFindType_PinBus = (1 << 6),
zFindType_Module = (1 << 7),
zFindType_Primitive = (1 << 8),
zFindType_Parasitic = (1 << 9),
zFindType_Any = (1 << 10) - 1
} zFindType;
zFindResultType
Specify the find result type.
typedef enum zFindResultType_ {
zFindResultType_modbased = (1 << 0),
zFindResultType_treebased = (1 << 1),
zFindResultType_both = zFindResultType_modbased |
zFindResultType_treebased
} zFindResultType;
Find Functions
zFind_simple
Parameters: db the data base to work on type the type of objects to search, a bitwise combination of zFindType pattern the search pattern ignoreCase if zTrue, be case insensitive exact if zTrue, perform fixed-string matching, else perform wild-card-style pattern matching hiersep the hiersep character used in pattern; if '\0', try to guess the hiersep character from the pattern callback the callback function to call on each match callbackContext a user-specified context to hand over to the callback function
Return values: zTrue if no error occurred zFalse if there was an error; in this case, the actual error message can be found in zLastErrorMsg
zBool zFind_simple(
DB* db,
int type,
const char* pattern,
zBool ignoreCase,
zBool exact,
char hiersep,
zBool autoPopulate,
zFindCallback callback,
void* callbackContext
);
zFind
Parameters: db the data base to work on type the type of objects to search, a bitwise combination of zFindType namePattern the object name search pattern namePatternIgnoreCase if true, namePattern is matched case insensitively. pathPattern the object path search pattern pathPatternIgnoreCase if zTrue, pathPattern is matched case insensitively. topPattern the object top search pattern topPatternIgnoreCase if zTrue, topPattern is matched case insensitively. cellPattern the cell search pattern; used when searching for instances (the instance must instantiate a matching cell), pins/pinBuses, ports/portBuses, nets/netBuses. cellPatternIgnoreCase if zTrue, cellPattern is matched case insensitively. exact if zTrue, perform fixed-string matching, else perform wild-card-style pattern matching hiersep the hiersep character used in pattern; if '\0', try to guess the hiersep character from the pattern dontMatchHiersep if zTrue, wild-cards in the pathPattern won’t match any hiersep characters resultType type of result objects to report callback the callback function to call on each match callbackContext a user-specified context to hand over to the callback function
Return values: zTrue if no error occurred zFalse if there was an error; in this case, the actual error message can be found in zLastErrorMsg
zBool zFind(
DB* db,
int type,
const char* namePattern,
zBool namePatternIgnoreCase,
const char* pathPattern,
zBool pathPatternIgnoreCase,
const char* topPattern,
zBool topPatternIgnoreCase,
const char* cellPattern,
zBool cellPatternIgnoreCase,
zBool exact,
char hiersep,
zBool dontMatchHiersep,
int resultType,
zBool autoPopulate,
zFindCallback callback,
void* callbackContext
);
Database Utilities
Subtract two OID Lists
zUtilsSubtract
Subtract oidList2 from oidList1. oidLists1: list of unref’d OIDs oidLists2: list of unref’d OIDs resultList: output list of ref’d OIDs
zBool zUtilsSubtract(
DB* db,
OID** resultList,
OID* oidList1,
OID* oidList2
);
Create a Path from a String
zUtilsPathFromString
Split the given string into a list of instances and a string containing the last part. The names are separated by a hierSep. The last part is separated by the given delim (or hierSep if '\0'). If guess is true an 'X' is prepended to instance names for a second chance, if the original instance name is not found. The resulting Instance list is stored in pathPtr and the returned oname must be freed by calls to zFree.
zBool zUtilsPathFromString(
DB* db,
Module* top,
OidType type,
const char* str,
char hierSep,
char delim,
char escape,
ce_Bool icase,
ce_Bool guess,
ce_Bool escapeVerilog,
ce_Bool autoPopulate,
const char* topInstName,
Module** topModulePtr,
Inst*** pathPtr,
char** onamePtr
);
zUtilsPathFromStringList
Split the given string into a list of instances and a string containing the last part. The names are separated by a hierSep. The last part is separated by the given delim (or hierSep if '\0'). If guess is true an 'X' is prepended to instance names for a second chance, if the original instance name is not found. The resulting Instance list is stored in pathPtr and the returned oname must be freed by calls to zFree.
zBool zUtilsPathFromStringList(
DB* db,
Module** topModule,
const char** pathList,
int pathListLength,
ce_Bool icase,
ce_Bool guessStart,
ce_Bool autoPopulate,
Inst*** pathPtr
);
zUtilsPath2Str
Concat path of a given oid to a string.
void zUtilsPath2Str(
const OID* oid,
char div,
DStr* str
);
zUtilsCmpInstNameVal
Compare instance by name and value (e.g. for zQsort).
int zUtilsCmpInstNameVal(
Inst** a,
Inst** b
);
zUtilsCmpInstNameValVP
Compare instance by name and value (e.g. for zQsort).
int zUtilsCmpInstNameValVP(
const void* objA,
const void* objB
);
zUtilsFormatValLabel
Format value label using vdi data.
zBool zUtilsFormatValLabel(
DB* db,
const char* topinfo,
const char* path,
const char* nlv,
OidType otype,
void* obj,
int pinNo,
char** attrList,
char** refAttrList,
char* val,
unsigned valSize,
const char* pseudoattr,
const char* pseudoval
);
zUtilsFormatOidValLabel
Format value label using oid.
zBool zUtilsFormatOidValLabel(
DB* db,
const OID* oid,
char* val,
unsigned valSize,
const char* pseudoattr,
const char* pseudoval,
const char* prepend
);
zUtilsNlv2Oid
.
void zUtilsNlv2Oid(
DB* db,
const char* nlvID,
const char* nlvTopInfo,
const OID* currentModule,
OID** oidList
);
zUtilsOid2Nlv
.
void zUtilsOid2Nlv(
DB* db,
const OID* oid,
const char* topInfo,
char** nlvID
);
The Database Operators
Generic Operators
zOperTSort
Sorts the given Cell-lists for traversals in a "defined before use" manner.
zBool zOperTSort(
Cell** cellList,
zBool checkOnly
);
zOperMakeTop
Computes top modules if the database currently defines less than topCnt tops.
zBool zOperMakeTop(
DB* db,
int topCnt
);
zOperUseAllTopCandidates
Use all modules of the top candidates as top modules. This list is generated while guessing top modules. If there are no top candidates present do nothing.
zBool zOperUseAllTopCandidates(
DB* db
);
zOperGuessTopModule
Guess top module(s) in the given database. If all modules which are not instantiated are flagged as libcell, use all of them as top, if useLibcellFlag is set. If singleTop is set, use only the best module as top. In all other cases use an educated guess.
zBool zOperGuessTopModule(
DB* db,
zBool useAllUnreferencedCells,
zBool useLibcellFlag,
zBool singleTop,
zBool force,
zBool restore
);
zOperSortTop
Divide the database’s topList into real-tops and library cells. Sort each section alphabetically.
zBool zOperSortTop(
DB* db
);
zOperDefTop
Defines the module as the new top (and deletes potential instances of it).
zBool zOperDefTop(
DB* db,
Module* topmod
);
zOperTmpTop
Defines the module as the new tmp top. If topmod is NULL reset topList to save original tops.
zBool zOperTmpTop(
DB* db,
Module* topmod
);
zOperSetTop
Define the module with the given name as the new top.
zBool zOperSetTop(
DB* db,
const char* topModuleName,
zBool icase
);
zOperDeleteUnused
Deleted the not-instantiated modules (except the top modules).
zBool zOperDeleteUnused(
DB* db
);
zOperZombieUnused
Flag cells with refCount == 0 as Zombies (except the top modules and libCells).
zBool zOperZombieUnused(
DB* db
);
zOperValidatePG
Search DB for Power/Ground nets. Return zFalse if non.
zBool zOperValidatePG(
DB* db
);
zOperMergeNet
Merges the two given nets.
zBool zOperMergeNet(
DB* db,
Module* module,
Net* toNet,
Net* fromNet,
zBool spos,
zBool ignorePortConn
);
zOperMergeNetBus
Merges the two given netBuses.
zBool zOperMergeNetBus(
DB* db,
Module* module,
NetBus* to,
NetBus* from,
zBool spos
);
zOperConnect
Connect a net to a pin.
zBool zOperConnect(
DB* db,
Module* module,
PinRef* ref,
Net* net
);
zOperDisconnect
Disconnect a pin.
Net* zOperDisconnect(
DB* db,
Module* module,
PinRef* ref
);
Device Related Operators
zOperBulk
Toggle the bulk visibility. mode: 0 = showwrong, 1 = all, 2 = none, 3 = nopg.
zBool zOperBulk(
DB* db,
int mode
);
zOperGroupMultiFinger
Group multifinger transistors.
zBool zOperGroupMultiFinger(
DB* db,
const char* sep
);
zOperEvalParams
Evaluate parameters. Hspice has two modes controlled by ".option parhier" GLOBAL (the default) and LOCAL. We process the whole hierarchy and set not constant attributes in the flat tree. In 'global' mode parameter which are set once, are NOT overwritten during going down the hierarchy. In 'local' mode, parameter get overwritten by instance attribute expressions and are preset by module default attribute expressions. Recursive expression using the value of other parameters are allowed. Attribute which have names beginning with '@' or '$' are ignored.
zBool zOperEvalParams(
DB* db,
zBool parhierLocal,
zBool icase
);
zOperPowerAndDirSettings
Set power and directions flags from -node settings.
zBool zOperPowerAndDirSettings(
DB* db,
struct SpiceNodes*,
zBool icase
);
zOperGuessPower
Guess power and ground nodes. Set NetFInternalPotentialPower/NetFInternalPotentialGround based on connected bulk pins. if setFlag is true NetFPower/NetFGround are set too.
zBool zOperGuessPower(
DB* db,
zBool setFlag
);
zOperGuessDir
Guess port dirs of modules.
zBool zOperGuessDir(
DB* db
);
zOperPowerAndDirGuess
Guess power nodes and port directions.
zBool zOperPowerAndDirGuess(
DB* db,
zBool icase,
zBool avoidShorted,
zBool evalVsrc2P,
zBool evalVsrc2I,
zBool addTopPorts,
zBool force,
int pwrprop
);
zOperHidePowerPorts
Check each subckt port. If connected to power/ground/negpower or unconnected set hide flags.
zBool zOperHidePowerPorts(
DB* db
);
zOperWeakFlow
Set weakflow instance flags for resistors and transistors. Check whether resistance is big enough. Check whether w/l is less than 1 (w-l is less than 0).
zBool zOperWeakFlow(
DB* db,
zBool hspice,
double resLimit
);
Database Modification Operators
zOperCleanup
-
If there were port flags modified, the pin flags need to be updated.
-
If there were global nets which are not power/ground, make warning.
-
Remove top (unreferenced) modules which contain only zombie insts.
void zOperCleanup(
DB* db
);
zOperSinglize
Make the given instance the only one referring to its down-module (make inst→cellRef→refCount == 1).
zBool zOperSinglize(
DB* db,
Inst* inst,
Module** reload
);
zOperSinglizePath
Make all instances in the given path refCount == 1.
zBool zOperSinglizePath(
DB* db,
int pathLen,
Inst* path[128],
Module** reload
);
zOperSinglizeTree
Traverse all database hierarchy and make refCount == 1.
zBool zOperSinglizeTree(
DB* db,
Module* mod
);
zUpdateSinglize
All three Singlize functions create duplicate Modules (clones with identical names). They call zUpdateSinglize to update OIDs that are affected. zUpdateSinglize is initially NULL, but can be set to a callback function - to get called directly after database objects have been singlized.
extern void (*zUpdateSinglize)(
DB*,
InstFlags
);
zOperFlatDesign
Flatten given top module
zBool zOperFlatDesign(
DB* db,
struct OID* top,
zBool spos,
zBool keep
);
zOperCollectSignalData
Transport net values, pg-flags, spos and attributes to the corresponding signal.
typedef zUInt8 ColWhat;
#define ColPG 0x01
#define ColValue 0x02
#define ColSpos 0x04
#define ColAttr 0x08
#define ColHilight 0x10
#define ColFAttr 0x20
#define ColFHilight 0x40
zBool zOperCollectSignalData(
DB* db,
Module* top,
ColWhat what
);
zOperHiersep
Scan the database inst/net/netBus names and return separator character. The given "mode" is: 0 for "scan" 1 for "get" 2 for "wish" 3 for "set"
zBool zOperHiersep(
DB* db,
int mode,
char* result,
unsigned char w
);
zOperUnused
Scan database and return characters which is not used in the design and by the hiersep. For each char in 'wish' a unused char is returned in the result.
zBool zOperUnused(
DB* db,
const char* wish,
char* res
);
zOperRenameAllUniq
Rename all Modules, Primitives, Ports and PortBusses.
zBool zOperRenameAllUniq(
DB* db,
zBool updateOIDs
);
zOperRenameDigit
Rename all nets and ports to avoid starting with a digit.
zBool zOperRenameDigit(
DB* db,
zBool icase
);
zOperRename
Rename the object given as an OID.
zBool zOperRename(
DB* db,
struct OID* oid,
const char* newName,
zBool updateOIDs,
zBool checkName
);
zOperChangeCellRef
Change the cell referenced by an instance. Special case: if inst == NULL: only call zUpdateRename.
zBool zOperChangeCellRef(
DB* db,
Module* mod,
Inst* inst,
Cell* newCellRef,
zBool updateOIDs
);
zOperChangeSimilar
Change cellRef of an instance with similar interface. Connectivity is copied to a cloned instance by using port names. Scalar port to portbus with same name is possible. The old instance is flagged zombie and needs to be removed by calling zDeleteZombies.
Modify Hierarchy
zOperAddHier
Move some instances into a new module (level of hierarchy). Create a new module "mname" and one instance "iname" of it. Place the instance "iname" in the given module "parent" and: + Move all instances "instList" from "parent" to the new module. + Move all connected local nets from "parent" to the new module. + Split all connected crossing nets (the original one stays at the outside and a new one is for the inside). + if useFirstInst is true, all nets connected to the first inst of instList are forced as interface nets, port names of this instance are used for new ports. + if pwrGndToo is true, all power gnd nets create interface ports/nets. Update all OIDs. Update flat-tree data structure. If "prefix" is not NULL, then remove prefix from instance, net and netBus names when they are moved or created inside the new module.
Inst* zOperAddHier(
DB* db,
Module* parent,
const char* mname,
const char* iname,
Inst** instList,
const char* prefix,
zBool useFirstInst,
zBool pwrGndToo
);
zOperRmHier
Remove one level or hierarchy. The given "rinst" (instance to remove) refers to "rmod" (module to remove), and rinst must be the only instance of rmod (no multiple instances).
Do this: + Move all instances from "rmod" to "parent". + Move all rmod’s local inside nets from "rmod" to "parent". + Merge connectivity of the crossing nets. + Remove "rmod" and "rinst". When moving the instances and local nets, then we may need to prefix their names to avoid name clashes. If so, then return the prefix string. Update all OIDs. Update flat-tree data structure.
zBool zOperRmHier(
DB* db,
Module* parent,
Inst* rinst,
char prefix[64],
const char* given_prefix,
zBool delZombies
);
zUpdateAddHier
UpdateRmHier and zUpdateRename are initially NULL, but they can be set to callback functions - to get called directly after database objects have been moved.
extern void (*zUpdateAddHier)(
DB*,
Module*,
InstFlags,
NetFlags,
NetFlags,
Inst*
);
extern void (*zUpdateRmHier)(
DB*,
Module*,
Inst*,
NetFlags,
NetFlags
);
extern int (*zUpdateRename)(
DB*
);
enum OperHierFoldMode {
OperHierFModeNone = 0,
OperHierFModeFold = 1,
OperHierFModeNoFlat = 2,
OperHierFModeAutoFold = 3
};
zOperHierStart
Start a set of HierAdd calls.
zBool zOperHierStart(
DB* db,
Module* top,
enum OperHierFoldMode fold
);
zOperHierAdd
Add an extra level of hierarchy.
Inst* zOperHierAdd(
DB* db,
const char* cname,
const char* iname,
const char** iList,
int bCount,
const char** oList,
const char** sList,
const char** memList,
zBool oneg,
int hsep,
const char* foldkey,
const char* base,
zBool doGuessPortDir,
zBool createSupplyPorts
);
zOperHierFinish
Finish and cleanup the set of zOperHierAdd calls.
zBool zOperHierFinish(
DB* db
);
zOperHierFoldCount
Return fold-table size (for debugging only).
int zOperHierFoldCount(
void
);
zOperHierPathCount
Return flat attr path count (for debugging only).
int zOperHierPathCount(
void
);
zOperHierFoldDupl
Return no of dupl entries in fold-table for given key.
int zOperHierFoldDupl(
const char*
);
zOperHierFoldBase
Return no of base entries in base-table for given base.
int zOperHierFoldBase(
const char*
);
zOperHierFoldList
Return list of modules inf fold-table (caller must call zArrayFree). Works outside of Start/Finish.
Module** zOperHierFoldList(
DB* db
);
zInvalidateFlagged
Initially NULL, but it can be set to a callback functions - to get called in zOperHierFinish to cut off all foreign pointers to visited inst and nets.
extern void (*zInvalidateFlagged)(
DB*,
CellFlags,
InstFlags,
NetFlags,
PortFlags,
VirtualFlags
);
zOperCreateHier
Completely create new levels of hierarchy by pathsep If top == NULL loop over all tops.
zBool zOperCreateHier(
DB* db,
Module* top,
char pathsep,
const char* prefix,
zBool doGuessPortDir,
zBool createSupplyPorts
);
Netlist Reduction
zOperCollectModuleParam
Find all instance attributes of each module.
void zOperCollectModuleParam(
DB* db
);
zOperGuessPortBus
Guess port buses.
zBool zOperGuessPortBus(
DB* db,
Cell* cell,
const char* open,
const char* close,
zBool down
);
zOperGuessNetBus
Guess net buses
zBool zOperGuessNetBus(
DB* db,
Module* mod,
const char* open,
const char* close,
zBool down
);
zOperGuessInstArray
Guess instance arrays.
zBool zOperGuessInstArray(
DB* db,
Module* module,
const char* startDelim,
const char* endDelim
);
zOperSortPorts
Sort ports in bus sequence, update pin connectivity.
zBool zOperSortPorts(
DB* db,
zBool down
);
zOperGuessBusses
Wrapper for the above GuessBus operators.
zBool zOperGuessBusses(
DB* db,
const char* startDelim,
const char* endDelim,
zBool down
);
zOperCreatePortBus
Create port bus.
zBool zOperCreatePortBus(
DB* db,
Cell* cell,
const char* busName,
int* portNos
);
zOperVerilogBusses
Create Verilog conform buses.
zBool zOperVerilogBusses(
DB* db,
Cell* cell
);
zOperExpand
Expand subckts and replace subckt instances by their contents and delete expanded instances and modules.
zBool zOperExpand(
DB* db,
zBool autoExpand,
zBool autoExpand0,
const char** expands,
zBool icase
);
zOperSubckt2Dev
Set primitive function for matching subckts.
zBool zOperSubckt2Dev(
DB* db,
struct StrTriple* subckt2dev,
zBool icase
);
zOperShortRes
Short resistors.
zBool zOperShortRes(
DB* db,
const char* limitStr,
zBool hspice
);
zOperMergeParallelInst
Merge parallel connected instances.
zBool zOperMergeParallelInst(
DB* db,
Module* mod,
zBool hspice,
zBool parasitic,
zBool icase,
struct MergeParallelInstEntry* entries
);
zOperMergeParallelCap
Merge parallel connected capacitors.
zBool zOperMergeParallelCap(
DB* db,
Module* mod,
zBool hspice,
zBool para
);
zOperMergeParallelRes
Merge parallel connected resistors.
zBool zOperMergeParallelRes(
DB* db,
Module* mod,
zBool hspice,
zBool parasitic
);
zOperMergeParallelDiode
Merge parallel connected diodes.
zBool zOperMergeParallelDiode(
DB* db,
Module* mod,
zBool hspice,
zBool parasitic
);
zOperMergeSerialRes
Merge serial connected resistors.
zBool zOperMergeSerialRes(
DB* db,
Module* mod,
zBool hspice,
zBool parasitic
);
zOperMergeSerialCap
Merge serial connected capacitors.
zBool zOperMergeSerialCap(
DB* db,
Module* mod,
zBool hspice,
zBool parasitic
);
zOperRemoveMOS
Remove mos.
zBool zOperRemoveMOS(
DB* db,
zBool useless
);
zOperRemoveUseless
Remove useless.
zBool zOperRemoveUseless(
DB* db
);
zOperRemoveRes
Remove res which are connected to only 1 net.
zBool zOperRemoveRes(
DB* db
);
zOperRemoveCap
Remove cap which are connected to only 1 net.
zBool zOperRemoveCap(
DB* db
);
zOperMergeParallel
Merge parallel connected transistors.
zBool zOperMergeParallel(
DB* db,
Module* mod,
zBool hspice,
zBool parasitic,
const char* multi,
double equality
);
zOperMergeSerial
Merge serial connected transistors.
zBool zOperMergeSerial(
DB* db
);
zOperMergeRams
Merge read/write ports into RAM instances.
zBool zOperMergeRams(
DB* db,
Module* mod
);
zOperRemoveEmptyModule
Remove empty modules.
zBool zOperRemoveEmptyModule(
DB* db,
zBool ckDanglingNets,
zBool ckZombies
);
zOperDeletePort
Delete ports from a cell.
zBool zOperDeletePort(
DB* db,
Cell* cell,
const char** portNames
);
zOperRtlSchem
Meaningful combination of the following operpp than can be used for RTL schematic visualization.
zBool zOperRtlSchem(
DB* db,
int level,
zBool preserveAssign
);
zOperRemoveBuf
Merge the nets connected to BUF and WIDE_BUF instances. Remove the BUF instance.
zBool zOperRemoveBuf(
DB* db,
Module* module,
unsigned opts
);
zOperRemoveInv
Remove inverter connected to power/ground.
zBool zOperRemoveInv(
DB* db,
Module* module,
unsigned opts
);
zOperCreateConst
Replace power/ground nets with a constant net.
zBool zOperCreateConst(
DB* db,
Module* module,
unsigned opts
);
zOperChain
Replace MUX chains by PRIO_SELECTOR instances. Replace boolean chains by reduced functions.
zBool zOperChain(
DB* db,
Module* module,
unsigned opts
);
zOperGuessWide
Combine scalar instances to wide instances if multiple outputs connect to same bus pin
zBool zOperGuessWide(
DB* db,
Module* module,
unsigned opts
);
zOperReducePins
Create extra hierarchy for Instances which have same nets connected to multiple pins.
zBool zOperReducePins(
DB* db,
Module* module,
unsigned opts
);
zOperRemoveDangle
Remove unconnected nets, and empty netbuses.
zBool zOperRemoveDangle(
DB* db,
Module* module,
unsigned opts
);
zOperBubbles
Replace inverters by bubbles (or change function)
zBool zOperBubbles(
DB* db,
Module* module,
unsigned opts
);
zOperNegEdge
Remove all inverter directly connected to a clk, set or rst pin of a Flip-Flop and add a bubble to the pin.
zBool zOperNegEdge(
DB* db,
Module* module,
unsigned opts
);
zOperInstArray
Find wide block by using instname.
zBool zOperInstArray(
DB* db,
Module* module,
unsigned opts
);
zOperGuessWideBus
ind bundle connecting to same driver.
zBool zOperGuessWideBus(
DB* db,
Module* module,
unsigned opts
);
zOperRemoveUnused
emove unreferenced cells.
zBool zOperRemoveUnused(
DB* db,
Module* module,
unsigned opts
);
zOperConnectByName
Mark net(s) as not to be routed.
zBool zOperConnectByName(
DB* db,
const char* netNamePattern,
zBool exact,
zBool caseSensitive
);
Parasitic Operators
zOperAnalyzeCoupling
Analyze coupling connections in parasitic modules.
zBool zOperAnalyzeCoupling(
DB* db,
zBool icase
);
zOperParaRmHier
Remove parasitic hierarchy.
zBool zOperParaRmHier(
DB* db,
Module* mod,
Inst* inst,
const char* prefix,
char div,
zBool delZombies
);
zOperParaRename
Rename instances of parasitic module.
zBool zOperParaRename(
DB* db,
Module* mod
);
zOperParaPex
Rename ports of parasitic modules using !PARAINST and !PARAPORTNO. Because the real port names are only known after subckt2dev macro guessing was done. In the pex file the subckt names are only numeric node numbers.
zBool zOperParaPex(
DB* db,
Module* mod
);
zOperParaMinMax
Calculate min/max cap/res/ind values.
zBool zOperParaMinMax(
DB* db,
Module* mod
);
zOperParaNetCap
Calculate netcap values.
zBool zOperParaNetCap(
DB* db,
Module* mod
);
zOperParaFinish
cleanup flags.
zBool zOperParaFinish(
DB* db,
zBool deleteUnmatched
);
zOperParaInline
Create inline parasitics in design.
zBool zOperParaInline(
DB* db,
zBool inlineMod,
const char* modPrefix
);
zOperParaRollback
Try to cleanup after interrupt db.
zBool zOperParaRollback(
DB* db,
zBool delZombies
);
zOperCreatePreplace
Create preplace info from @X,@Y.
zBool zOperCreatePreplace(
DB* db
);
zOperLayoutComments
add mapped layout attributes to attrList values of "@layer" attribute get mapped via mapFunc (if != NULL).
void zOperLayoutComments(
DB* db,
char*** attrListPtr,
const char* comment,
const char* (*layerValueMap)(int)
);
zOperReportParallelInst
Report parallel connected instances.
struct ReportParallelInstResult {
Module* mod;
Inst** instList;
};
zBool zOperReportParallelInst(
DB* db,
Module* mod,
zBool hspice,
zBool parasitic,
zBool icase,
struct MergeParallelInstEntry* entries,
struct ReportParallelInstResult** reportResultListPtr
);
zOperMergeSerialParallel
Merge serial and parallel connected transistors.
zBool zOperMergeSerialParallel(
DB* db,
Module* mod,
zBool hspice,
const char* multi,
double equality
);
zOperRmHierDynamicPrefix
Remove one level or hierarchy. The given "rinst" (instance to remove) refers to "rmod" (module to remove), and rinst must be the only instance of rmod (no multiple instances).
Do this: + Move all instances from "rmod" to "parent". + Move all rmod’s local inside nets from "rmod" to "parent". + Merge connectivity of the crossing nets. + Remove "rmod" and "rinst". When moving the instances and local nets, either the given_prefix, or an automatically created unique prefix (derived from "rinst"'s name) is prepended to avoid name clashes. The used prefix is returned in the allocated string "*used_prefix", which the caller must free with "zFree(*used_prefix)". Update all OIDs. Update flat-tree data structure.
zBool zOperRmHierDynamicPrefix(
DB* db,
Module* parent,
Inst* rinst,
zBool delZombies,
const char* given_prefix,
char** used_prefix
);
zOperFlattenSubtree
Flatten the complete subtree rooted at the given instance.
zBool zOperFlattenSubtree(
DB* db,
struct OID* rootInstance
);
Database Reduction Operators
Reduce Resistance
zOperReduceRes
Reduce resistance network if doMesh is true, n-star to mesh transformation is done. if doModify is true, the given modules gets modified. if intoModule is given, the reduced network is created in given module. if portNoList == NULL (or cnt==0) all nets connected to a port get not reduced. if portNoList != NULL only nets connected to listed port get not reduced. if resList != NULL, portNoList must even number of ports, for each pair the network get reduce to one resistor the resistance are returned in resList, which must have space for cnt/2 doubles.
zBool zOperReduceRes(
DB* db,
Module* mod,
int* portNoList,
int cnt,
zBool doMesh,
zBool doModify,
Module* intoModule,
double* resList
);
The Database Calculations
Calculate Resistance
zCalcRes
Calculate the resistance of a network between two ports.
zBool zCalcRes(
DB* db,
Module* module,
int portNo1,
int portNo2,
long loopLimit,
double minChange,
double* res
);
zCalcResList
Calculate resistances between port pairs.
zBool zCalcResList(
DB* db,
Module* mod,
int len,
int* portNoPairList,
long loopLimit,
double minChange,
double* resList
);
Convert Values
ce_Radix Enumeration
Enumeration to define all supported radix types.
typedef enum {
ce_UnknownRadix = 0,
ce_Bin = 2,
ce_Oct = 8,
ce_Dec = 10,
ce_Hex = 16
} ce_Radix;
ce_ConvertStringToRadix
Get ce_Radix enum type for bin|oct|dec|hex|? (case insensitive) string.
ce_Radix ce_ConvertStringToRadix(const char* inputValue);
ce_ConvertRadixToString
Return the string representation for a ce_Radix enum type.
const char* ce_ConvertRadixToString(ce_Radix radix);
ce_ConvertRadixUsageList
Add all ce_Radix values except ce_UnknownRadix to the list.
void ce_ConvertRadixUsageList(const char*** list);
Spice Conversions
ce_ConvertSpiceUnitToDouble
Get the scale for a given string like 'K' (→ 1e3) or 'p' (→ 1e-12). Set hspice to ce_True to enable the usage of 'a' (atto → 1e-18). Return ce_False and set ce_ErrorLastMsg on errors.
ce_Bool ce_ConvertSpiceUnitToDouble(const char* inputValue, ce_Bool hspice,
double* result);
ce_ConvertSpiceValueToDouble
Convert a Spice value into a double. Set hspice to ce_True to enable the usage of 'a' (atto → 1e-18). Return ce_False and set ce_ErrorLastMsg on errors.
ce_Bool ce_ConvertSpiceValueToDouble(const char* inputValue, ce_Bool hspice,
double* result);
ce_ConvertDoubleToSpice
Convert a double into Spice string representation. Set hspice to ce_True to enable the usage of 'a' (atto → 1e-18). Result needs to be initialized by the caller. Return ce_False and set ce_ErrorLastMsg on errors.
ce_Bool ce_ConvertDoubleToSpice(double inputValue, ce_Bool hspice,
ce_DString* result);
Binary Conversions
ce_ConvertFromBinary
Convert binary bits to one string value with given radix. Set radix to the desired radix of result. Set addPrefix to ce_True to add a preceding 'O' if radix is ce_Oct or "0x" if radix is ce_Hex. Set addVerilogPrefix to add a preceding "len'(b|o|d|h)" in Verilog style to the result, depending on the given radix. Set singleNoValue will convert a vector with many '?' to one "?". Set noValueAsX will convert '?' to "X". Setting both addPrefix and addVerilogPrefix to ce_True is not allowed! Set noOfBits to add preceding zeros to the result (ignored if noOfBits is too small). Result needs to be initialized by the caller. Return ce_False and set ce_ErrorLastMsg on errors.
ce_Bool ce_ConvertFromBinary(const char* inputValue, ce_Radix radix,
ce_Bool addPrefix, ce_Bool addVerilogPrefix,
ce_Bool singleNoValue, ce_Bool noValueAsX,
unsigned noOfBits, ce_DString* result);
ce_ConvertToBinary
Convert a string with optional prefix to binary bits. Set radix to the radix of the inputValue. Set hasPrefix if the inputValue starts with 'O' (octal) or "0x" (hexadecimal). Set addVerilogPrefix to add a preceding "len'(b|o|d|h)" in Verilog style to the result, depending on the given radix. Set noOfBits to add preceding zeros to the result (ignored if noOfBits is too small). Result needs to be initialized by the caller. Return ce_False and set ce_ErrorLastMsg on errors.
ce_Bool ce_ConvertToBinary(const char* inputValue, ce_Radix radix,
ce_Bool hasPrefix, ce_Bool addVerilogPrefix,
unsigned noOfBits, ce_DString* result);
Verilog Conversions
ce_ConvertFromVerilogValue
Format: [0-9_]* or [0-9_]\'[bodh][0-9a-fxz]. Convert a Verilog value into ce_BigInt. Result needs to be initialized by the caller. Return ce_False and set ce_ErrorLastMsg on errors.
ce_Bool ce_ConvertFromVerilogValue(const char* inputValue, ce_BigInt* result);
ce_ConvertToVerilogValue
Convert a ce_BigInt number in to a ce_DString in Verilog format: noOfBits\'[bodh][0-9a-f]. Set radix to the desired radix of result. Set noOfBits to add preceding zeros to the result (ignored if noOfBits is too small). Set sepDistance to x > 0 to include underscore separators every x digits or to 0 to disable underscore separators. Result needs to be initialized by the caller. Return ce_False and set ce_ErrorLastMsg on errors.
ce_Bool ce_ConvertToVerilogValue(ce_BigInt* inputValue, ce_Radix radix,
unsigned noOfBits, unsigned sepDistance,
ce_DString* result);
ce_ConvertChangeVerilogRadix
Convert a Verilog number in format ([0-9]\'[bodh][0-9a-f] or [0-9a-f]) to a ce_DString in Verilog format ([0-9]\'[bodh][0-9a-f]) with different radix. Set radix to the desired radix of result. Result needs to be initialized by the caller. Return ce_False, set ce_ErrorLastMsg and copy inputValue to result on errors.
ce_Bool ce_ConvertChangeVerilogRadix(ce_DString* inputValue, ce_Radix radix,
ce_DString* result);
Format Value
ce_ConvertAddThousandsSeparator
Format value with separators. Result needs to be initialized by the caller. Return ce_False and set ce_ErrorLastMsg on errors.
ce_Bool ce_ConvertAddThousandsSeparator(ce_Long inputValue, const char* sep,
ce_DString* result);
Clone and Merge
Clone Database Objects
zClonePrimitive
Clone a primitive.
Primitive* zClonePrimitive(
DB* db,
Cell* orig,
const char* rename,
zBool bitblasted,
PortFlags skipFlaggedPort,
zBool spos
);
zCloneModule
Clone the complete module.
Module* zCloneModule(
DB* db,
Module* orig,
const char* rename,
zBool bitblasted,
PortFlags skipFlaggedPort,
InstFlags skipFlaggedInst,
zBool skipContent,
zBool spos
);
zCloneInst
Clone an instance.
Inst* zCloneInst(
DB* db,
Module* dest,
Inst* orig,
const char* rename,
zBool spos
);
zCloneNet
Clone a net.
Net* zCloneNet(
DB* db,
Module* dest,
Net* orig,
const char* rename,
zBool spos
);
zCloneAttrList
Clone an attribute list.
char** zCloneAttrList(
DB* db,
char** attrList
);
Clone a Database
zCloneDB
Clone all flagged objects of the given database and either return the cloned database or clone into an existing database.
DB* zCloneDB(
DB* src,
DB* into,
CellFlags keepCell,
InstFlags keepInst,
NetFlags keepNet,
PortFlags keepPort,
PinFlags keepPin,
zBool spos
);
Merge two Databases
zMergeDB
Clone cells from one db into another. if resolveWithRename is true already existing cells get renamed. already existing instances still reference the renamed cell. if resolveWithRename is false only the contents of modules is cloned if the existing module is empty.
zBool zMergeDB(
DB* src,
DB* dst,
zBool spos,
zBool resolveWithRename
);
zClonePrimitiveNoUniq
Clone a primitive do not find an uniq name.
Primitive* zClonePrimitiveNoUniq(
DB* db,
Cell* orig,
const char* rename,
zBool bitblasted,
PortFlags skipFlaggedPort,
zBool spos
);
zCloneDBEx
Similar to zCloneDB, but add the option to create modules for all primitives in the source database.
DB* zCloneDBEx(
DB* src,
DB* into,
CellFlags keepCell,
InstFlags keepInst,
NetFlags keepNet,
PortFlags keepPort,
PinFlags keepPin,
zBool primAsModule,
zBool spos);
Clock Domain Analyzer Functions
The CDC Object
zCdcNew
Create a new CDC object and calculate the clkPinOidList, the clkDomainList with clkSrc and clkPinOidList as well as the reducedClkPinIdxList of all clkDomains.
struct zCdc* zCdcNew(
DB* db,
Module* top,
zBool compr,
zBool skipUndriven,
int skipLess
);
zCdcFree
Cleanup the CDC object.
void zCdcFree(
struct zCdc* cdc
);
zCdcGetDB
Get the associated database.
DB* zCdcGetDB(
struct zCdc* cdc
);
zCdcSetHook
Set hook for the Tcl command.
void zCdcSetHook(
struct zCdc* cdc,
void* hook
);
zCdcGetHook
Return the hook for the Tcl command.
void* zCdcGetHook(
struct zCdc* cdc
);
Clock Domains
zCdcGetDomainCnt
Get the number of clock domains.
int zCdcGetDomainCnt(
struct zCdc* cdc
);
zCdcGetDomainList
List of domain indices, sorted by the number of contained clkPins.
int* zCdcGetDomainList(
struct zCdc* cdc,
zBool incr
);
zCdcGetSrc
return clkSrc of given Domain, or NULL
OID* zCdcGetSrc(
struct zCdc* cdc,
int clkDomainIdx
);
zCdcGetAllSources
Return list of all clock source OIDs, or NULL.
OID* zCdcGetAllSources(
struct zCdc* cdc,
int clkDomainIdx
);
zCdcGetClkPinList
Return clkPinOidList of given Domain.
OID* zCdcGetClkPinList(
struct zCdc* cdc,
int clkDomainIdx
);
zCdcGetClkPinCount
Return physical clock pin count of the given Domain.
zLong zCdcGetClkPinCount(
struct zCdc* cdc,
int clkDomainIdx
);
zCdcGetReducedClkPinList
Return reduced clkPinOidList of given Domain.
OID* zCdcGetReducedClkPinList(
struct zCdc* cdc,
int clkDomainIdx
);
zCdcGetTreeList
Get OIDs of the clock domain for the given domain index; include control logic if controlLogic==1.
OID* zCdcGetTreeList(
struct zCdc* cdc,
int clkDomainIdx,
zBool cache,
zBool controlLogic
);
zCdcGetReducedTreeList
Get the reduced OID list of the clock domain for the given domain index; include control logic if controlLogic==1.
OID* zCdcGetReducedTreeList(
struct zCdc* cdc,
int clkDomainIdx,
zBool cache,
zBool controlLogic
);
Clock Domain Crossing
zCdcGetTreeCrossCnt
Get the number of domain crossings.
int zCdcGetTreeCrossCnt(
struct zCdc* cdc
);
zCdcGetTreeCrossList
Get domain cross indices sorted by the number of contained src|clkPins.
int* zCdcGetTreeCrossList(
struct zCdc* cdc,
int mode
);
zCdcGetTreeCrossSrcList
Return clkSrcOidList of given domain crossing.
OID* zCdcGetTreeCrossSrcList(
struct zCdc* cdc,
int treeCrossIdx
);
zCdcGetTreeCrossClkPinList
Return clkPinOidList of given domain crossing.
OID* zCdcGetTreeCrossClkPinList(
struct zCdc* cdc,
int treeCrossIdx
);
zCdcGetTreeCrossCone
Return the cone for the given domain crossing.
OID* zCdcGetTreeCrossCone(
struct zCdc* cdc,
int treeCrossIdx
);
zCdcGetClkPinDomains
Return domainIdxList of the given clkPinOid.
int* zCdcGetClkPinDomains(
struct zCdc* cdc,
OID* clkPinOid
);
zCdcCalcDomainCross
Calculate the domain crossings and return the number of crossings.
int zCdcCalcDomainCross(
struct zCdc* cdc,
zBool removeDRS,
int* domainIdxList
);
zCdcGetDomainCrossCnt
Get the number of domain crossings.
int zCdcGetDomainCrossCnt(
struct zCdc* cdc
);
zCdcGetDomainCrossList
Get the domain cross indices sorted by the number of contained clkpins.
int* zCdcGetDomainCrossList(
struct zCdc* cdc,
zBool incr
);
zCdcGetDomainCrossDomainPair
Fill lists with source and target domain indices. Return zFalse for wrong domain cross idx.
zBool zCdcGetDomainCrossDomainPair(
struct zCdc* cdc,
int domainCrossIdx,
int* srcDomainIdx,
int* trgDomainIdx
);
zCdcGetDomainCrossTrgList
Return OID list for the given domain crossing.
OID* zCdcGetDomainCrossTrgList(
struct zCdc* cdc,
int domainCrossIdx
);
zCdcGetDomainCrossCone
Return cone for the given domain crossing.
OID* zCdcGetDomainCrossCone(
struct zCdc* cdc,
int domainCrossIdx
);
Database Report Functions
Count Object
zReportInstCount
Traverses the database hierarchy tree rooted at the given top and counts the number of instances of each primitive and each module.
struct InstCount {
Cell* cell;
zUInt64 count;
};
zBool zReportInstCount(
DB* db,
Module* top,
struct InstCount** resultListPtr
);
zReportNetCount
Traverses the database hierarchy tree rooted at the given "top" and count the number of nets.
zReportportCount
Traverses the database hierarchy tree rooted at the given "top" and count the number of ports.
zBool zReportPortCount(
DB* db,
Module* top,
zUInt64* resultCount,
zBool nofunc
);
ReportType
List object types that can be reported by the report functions below.
typedef zUInt16 ReportType;
#define ReportNone 0x0000
#define ReportCell 0x0001
#define ReportModInst 0x0002
#define ReportPrimInst 0x0004
#define ReportInst (ReportModInst|ReportPrimInst)
#define ReportPin 0x0008
#define ReportNet 0x0010
#define ReportNetBus 0x0020
#define ReportPort 0x0040
#define ReportPortBus 0x0080
#define ReportParasitic 0x0100
#define ReportAll 0x01FF
zReportObjCount
Traverses the database hierarchy tree rooted at the given "top" and count the number of objs.
zBool zReportObjCount(
DB* db,
Module* top,
zUInt64* resultCount,
zBool nofunc,
ReportType type
);
zReportHierObjCount
Loop over all modules in the database and count the total number of objects.
zUInt64 zReportHierObjCount(
DB* db,
zBool nofunc,
ReportType type
);
Design Histogram
zReportHistogram
Report statistic (histogram) data for the given database.
struct zHistogram {
zUInt64 cellCount;
zUInt64 cellPlacement;
zUInt64 deviceCount;
zUInt64 devicePlacement;
zUInt64 netCount;
zUInt64 cellPinCount;
zUInt64 devicePinCount;
zUInt64 pinCount;
zUInt64 portCount;
};
zBool zReportHistogram(
DB* db,
struct zHistogram** histogramListPtr
);
Design Statistics
zReportDesignStatistics
Report design statistics for the given database into a file.
zBool zReportDesignStatistics(
DB* db,
const char* filename
);
Database Tools
Electrical Rule Checks
zFloatingNodes
The zFloatingNodes function loops over all modules and count the number of pins for each net. Power/Ground nets are skipped. All nets with exactly one pin are stored in the resultList.
void zFloatingNodes(
DB* db,
OID** resultList
);
zFlatfloatNodes
The zFlatfloatNodes function loops over all signals and count the number of pins for each signal. Power/Ground nets are skipped. All signals with exactly one pin are stored in the resultList.
void zFlatfloatNodes(
DB* db,
OID** resultList
);
zHeavyNodes
The zHeavyNodes function loops over all signals and count the number of pins for each signal. Power/Ground nets are skipped. The 10 biggest signals are stored in the resultList.
void zHeavyNodes(
DB* db,
OID** resultList
);
zHeavyCR
The zHeavyCR function loops over all C or R and checks each value (capacitance or resistance) and collects 10 objects with the biggest values. The 10 biggest Cs and 10 biggest Rs are stored in the resultList.
void zHeavyCR(
DB* db,
OID** resultList
);
zCCoupling
The zCCoupling function loops over all Cs and checks if they connect neither to power nor to ground that means they couple two data wires. The coupling Cs are stored in the resultList.
void zCCoupling(
DB* db,
OID** resultList
);
zWrongBulk
The zWrongBulk function loops over all PMOS and NMOS transistors and checks if their bulks are connected to power and ground respectively. If not, then the transistor is stored in the resultList.
void zWrongBulk(
DB* db,
OID** resultList
);
zMultiDriver
The zMultiDriver function loops over all signals and checks if a signal has more than one driver. The signals with more than one driver pin are stored in the resultList.
void zMultiDriver(
DB* db,
OID** resultList
);
zZeroDriver
The zZeroDriver function loops over all signals and checks if a signal has no driver. The signals with no driver pin are stored in the resultList.
void zZeroDriver(
DB* db,
OID** resultList
);
zOpenGate
The zOpenGate function loops over all transistors to find open/unconnected gate pins.
void zOpenGate(
DB* db,
OID** resultList
);
Recreate Hierarchy
zCreateHier
The zCreateHier function loops over a flat design and recreates the hierarchy based on the instance names.
int zCreateHier(
DB* db,
const char* hiersep
);
Analyze the Database
zFindGuessedSupplyNets
This function reports all nets that have been guessed by zOperGuessPower as a supply net.
void zFindGuessedSupplyNets(
DB* db,
OID** resultList
);
Blocklevel Functions
The Blocklevel Object
zBlocklevelNew
zBlocklevel* zBlocklevelNew(DB* db, DB* blockDb);
zBlocklevelCreate
Module* zBlocklevelCreate(zBlocklevel *blocklevel, Module *module);
zBlocklevelExistsByPath
zBool zBlocklevelExistsByPath(zBlocklevel *blocklevel,
const char** path, int plen);
zBlocklevelCreateByPath
zBool zBlocklevelCreateByPath(zBlocklevel *blocklevel,
const char** path, int plen, struct OID* blocklevelModOid);
zBlocklevelBuildTree
zBool zBlocklevelBuildTree(zBlocklevel *blocklevel);
zBlocklevelFree
void zBlocklevelFree(zBlocklevel *blocklevel);
The Blocklevel View
Dump the Database
Internal Database Dump
Dump Options
The options can be specified using the name of the DUMPF_* macro.
typedef ce_UInt64 zDumpFlags;
/* No dump flags set */
#define DUMPF_NO_OPTIONS 0x0000000000000000
#define DUMPS_NO_OPTIONS "NoFlags"
/* Sort all primitives */
#define DUMPF_SORT_PRIMS 0x0000000000000001
#define DUMPS_SORT_PRIMS "SortPrimitives"
/* Sort all modules */
#define DUMPF_SORT_MODS 0x0000000000000002
#define DUMPS_SORT_MODS "SortModules"
/* Sort all files */
#define DUMPF_SORT_FILES 0x0000000000000004
#define DUMPS_SORT_FILES "SortFiles"
/* Sort all pins */
#define DUMPF_SORT_PINS 0x0000000000000008
#define DUMPS_SORT_PINS "SortPins"
/* Sort all instances */
#define DUMPF_SORT_INSTS 0x0000000000000010
#define DUMPS_SORT_INSTS "SortInstances"
/* Sort all nets */
#define DUMPF_SORT_NETS 0x0000000000000020
#define DUMPS_SORT_NETS "SortNets"
/* Sort all ports */
#define DUMPF_SORT_PORTS 0x0000000000000040
#define DUMPS_SORT_PORTS "SortPorts"
/* Sort all sub-ports */
#define DUMPF_SORT_SUBPORTS 0x0000000000000080
#define DUMPS_SORT_SUBPORTS "SortSubPorts"
/* Dump ports by order number */
#define DUMPF_DUMP_PORT_ORDER 0x0000000000000100
#define DUMPS_DUMP_PORT_ORDER "DumpPortOrder"
/* Dump flags by name */
#define DUMPF_DUMP_FLAGS 0x0000000000000200
#define DUMPS_DUMP_FLAGS "DumpFlags"
/* Dump primFunction */
#define DUMPF_DUMP_FUNC 0x0000000000000400
#define DUMPS_DUMP_FUNC "DumpFunc"
/* Dump spos information */
#define DUMPF_DUMP_SPOS 0x0000000000001000
#define DUMPS_DUMP_SPOS "DumpSpos"
/* Dump attributes */
#define DUMPF_DUMP_ATTR 0x0000000000002000
#define DUMPS_DUMP_ATTR "DumpAttr"
/* Prefix module/primitives names with uniq index */
#define DUMPF_DUMP_INDEX 0x0000000000004000
#define DUMPS_DUMP_INDEX "DumpIndex"
* Special "comparable" dump:
* - the interface of Primitives and Operators (if a function is given)
* is printed without cellname and without portname (but port-order, like
* with the DumpPortOrder option); portnames are also suppressed for
* Blackbox Modules (CellFUndefined).
* - empty Modules and Operators are always printed as Primitives
* (without contents - see dumpContents.)
* - the name of power/ground nets is printed as "0" or "1".
* - unnamed instances ("i%d", "i_%d" or " I%d") is replaced by "-".
* - map REDUCE primitive functions to their "normal" counterparts by ignoring
* the PortBus.
* - map AND with only one input to a BUF.
#define DUMPF_DUMP_COMPARABLE 0x0000000000008000UL
#define DUMPS_DUMP_COMPARABLE "Comparable"
/* Sort spos */
#define DUMPF_SORT_SPOS 0x0000000000010000UL
#define DUMPS_SORT_SPOS "SortSpos"
/* Skip hidden ports */
#define DUMPF_NO_HIDE_PORT 0x0000000000020000UL
#define DUMPS_NO_HIDE_PORT "NoHidePort"
/* Sort all net buses */
#define DUMPF_SORT_NET_BUSES 0x0000000000040000UL
#define DUMPS_SORT_NET_BUSES "SortNetBuses"
/* Dump unconnected pins */
#define DUMPF_UNCONNECTED_PIN 0x0000000000080000UL
#define DUMPS_UNCONNECTED_PIN "UnconnectedPin"
/* Skip contents of modules */
#define DUMPF_NO_CONTENT 0x0000000000100000UL
#define DUMPS_NO_CONTENT "NoContent"
/* Sort attr */
#define DUMPF_SORT_ATTR 0x0000000000200000UL
#define DUMPS_SORT_ATTR "SortAttr"
/* Skip primitives */
#define DUMPF_NO_PRIM 0x0000000000400000UL
#define DUMPS_NO_PRIM "NoPrim"
/* Dump bus range */
#define DUMPF_DUMP_RANGE 0x0000000000800000UL
#define DUMPS_DUMP_RANGE "DumpRange"
/* Dump filetype of spos files */
#define DUMPF_DUMP_SPOS_FILE_TYPE 0x0000000001000000UL
#define DUMPS_DUMP_SPOS_FILE_TYPE "DumpSposFileType"
/* Not dump parasitic content */
#define DUMPF_NO_PARASITIC_CONTENT 0x0000000002000000UL
#define DUMPS_NO_PARASITIC_CONTENT "NoParaContent"
/* Not dump root attr */
#define DUMPF_NO_ROOT_ATTR 0x0000000004000000UL
#define DUMPS_NO_ROOT_ATTR "NoRootAttr"
/* Normalize long float attr */
#define DUMPF_NORM_FLOAT_ATTR 0x0000000008000000UL
#define DUMPS_NORM_FLOAT_ATTR "NormalizeFloatAttr"
/* Dump only module names */
#define DUMPF_MODULE_ONLY 0x0000000010000000UL
#define DUMPS_MODULE_ONLY "ModuleOnly"
/* Special case dump flat attr tree */
#define DUMPF_DUMP_FLAT_ATTR 0x0000000020000000UL
#define DUMPS_DUMP_FLAT_ATTR "DumpFAttr"
/* Unify the names of auto generated primitives */
#define DUMPF_UNIFY_AUTOGEN_PRIM_NAMES 0x0000000080000000UL
#define DUMPS_UNIFY_AUTOGEN_PRIM_NAMES "UnifyAutogenPrimNames"
/* Remove nets which are only connected to one port/pin */
#define DUMPF_REMOVE_DANGLING_NETS 0x0000000100000000UL
#define DUMPS_REMOVE_DANGLING_NETS "RemoveDanglingNets"
/* Sort all elements */
#define DUMPF_SORT ( \
DUMPF_SORT_SPOS | \
DUMPF_NO_HIDE_PORT | \
DUMPF_SORT_NET_BUSES | \
DUMPF_SORT_PORTS | \
DUMPF_SORT_NETS | \
DUMPF_SORT_INSTS | \
DUMPF_SORT_PRIMS | \
DUMPF_SORT_MODS | \
DUMPF_SORT_PINS | \
DUMPF_SORT_ATTR | \
DUMPF_SORT_FILES )
#define DUMPS_SORT "Sort"
/* Built-in default dump flags */
#define DUMPF_DEFAULT ( \
DUMPF_SORT | \
DUMPF_DUMP_FLAGS | \
DUMPF_DUMP_FUNC | \
DUMPF_DUMP_SPOS | \
DUMPF_DUMP_ATTR )
#define DUMPS_DEFAULT "Default"
zDumpDatabase
Dump the contents of the database to the a file with the given name. The output file can be compressed using the IOType option. Return false and set the last error message if something went wrong. If is cellPattern is not NULL, only cells matching the given pattern are dumped. The dump details can be controlled using the dump flags.
ce_Bool zDumpDatabase(
DB* db,
const char *filename,
ce_IOType ioType,
const char *cellPattern,
zDumpFlags flags
);
zDump
Map the legacy function name.
#define zDump(db, fname, type, cellPattern, flags) \
zDumpDatabase(db, fname, type, cellPattern, flags)
zDumpDatabase_OptionString
Dump the contents of the database to the a file with the given name. The output file can be compressed using the IOType option. Return false and set the last error message if something went wrong. If is cellPattern is not NULL, only cells matching the given pattern are dumped. The dump details can be controlled using the stringFlags: dump flag names separated by the pipe character, e.g. DumpFlags|DumpAttr.
ce_Bool zDumpDatabase_OptionString(
DB* db,
const char *filename,
ce_IOType ioType,
const char *cellPattern,
const char *stringFlags
);
zDumpOpt
Map the legacy function name.
#define zDumpOpt(db, fname, type, cellPattern, strflags) \
zDumpDatabase_OptionString(db, fname, type, cellPattern, strflags)
zDumpDatabase_OptionArray
Dump the contents of the database to the a file with the given name. The output file can be compressed using the compress option. Return false and set the last error message if something went wrong. If is cellPattern is not NULL, only cells matching the given pattern are dumped. The dump details can be controlled using the flagNames string array: A list of flag names, e.g. [0] = DumpFlags, [1] = DumpAttr.
ce_Bool zDumpDatabase_OptionArray(
DB *db,
ce_IOType ioType,
const char *cellPattern,
const char **flagNames,
const char *filename
);
Database Writer
Write zdb data as either Tcl or a standard netlist format like Verilog or Spice.
Write Standard Netlist Formats
zWriteTcl
Write the db as Tcl '$db load …' commands to a file named fname.
zBool zWriteTcl(
DB* db,
const char* fname,
IOType type,
zBool doTSort,
zBool doSpos,
zBool doAttrs,
zBool doFlags,
zBool doFlat,
zBool doMangle,
zBool doSposIdx,
zBool doTableAlloc,
zBool doContent,
int comments,
const char* cellPattern
);
zWriteVerilog
Write the database as a Verilog file.
zBool zWriteVerilog(
DB* db,
const char* fname,
IOType type,
zBool named,
int comments,
zBool objcomments,
zBool preserveNet,
PortFlags ignorePort,
CellFlags ignoreCell,
CellFlags ignoreRCell,
InstFlags ignoreInst,
zBool ignoreAutoGen,
zBool implementFunction,
zBool originalName,
zBool writeCellDefine
);
zWriteSpice
Write the db as a Spice file.
zBool zWriteSpice(
DB* db,
const char* fname,
IOType type,
int comments,
const char* valueNetNames[4],
zBool deviceAsSubckt,
zBool subcktx,
zBool noModel,
zBool addDotEnd,
zBool originalName
);
zWriteSpef
Write the db as a Spef file.
zBool zWriteSpef(
DB* db,
const char* fname,
IOType type,
int comments,
zBool nameMap,
zBool ignoreEmpty,
Module* top,
const char* design,
const char* program,
const char* version,
const char* vendor,
const char* date,
const char* designflow,
const char* divider,
const char* delimiter,
const char* busdelimiter,
const char* timescale,
const char* timeunit,
const char* capscale,
const char* capunit,
const char* resscale,
const char* resunit,
const char* indscale,
const char* indunit,
const char** powernets,
const char** gndnets,
const char** onlys,
zBool renameLocals,
zBool noEsc
);
zWriteDspf
Write the db as a DSPF file.
zBool zWriteDspf(
DB* db,
const char* fname,
IOType type,
int comments,
zBool ignoreEmpty,
Module* top,
const char* design,
const char* program,
const char* version,
const char* vendor,
const char* date,
const char* divider,
const char* delimiter,
const char* busdelimiter,
const char** gndnets,
const char** onlys,
zBool noEsc
);
Generic Write Interface
zWriteInfo
Write info struct.
struct zWriteFunctions;
struct zWriteInfo {
IOWriter* wrt;
const char* fname;
DB* db;
IOType type;
zBool doSpos;
zBool doAttrs;
zBool doFlags;
zBool doFlat;
zBool doMangle;
zBool doStopCell;
zBool ok;
zBool dbgRecord;
int doComments;
int mangleId;
char unused[4];
struct zWriteFunctions* functions;
struct zStrTab mangleMap;
struct StrSpace strspace;
char buf[100];
};
zWriteMangleName
Mangle object names.
char* zWriteMangleName(struct zWriteInfo* writeInfo, const char* name);
zWriteGzPutS
Write a string to the output file.
void zWriteGzPutS(
struct zWriteInfo*,
const char*
);
zWriteGzPutC
Write a char to the output file.
void zWriteGzPutC(
struct zWriteInfo*,
char
);
zWriteGzPutLen
Write a string to the output file.
void zWriteGzPutLen(
struct zWriteInfo*,
int len,
const char*
);
zWriteGzPutI
Write a decimal number to the output file.
void zWriteGzPutI(
struct zWriteInfo* writeInfo,
int i
);
zWriteGzPutL
Write a decimal number to the output file.
void zWriteGzPutL(
struct zWriteInfo* writeInfo,
zLong i
);
zWriteGzPutU
Write a decimal number to the output file.
void zWriteGzPutU(
struct zWriteInfo* writeInfo,
unsigned i
);
zWriteGzPutUL
Write a decimal number to the output file.
void zWriteGzPutUL(
struct zWriteInfo* writeInfo,
zULong i
);
zWriteGzPutULL
Write a decimal number to the output file.
void zWriteGzPutULL(
struct zWriteInfo* writeInfo,
zUInt64 i
);
zWriteVHDL
Write the db as VHDL netlist.
zBool zWriteVHDL(
DB* db,
const char* fname,
IOType type,
int comments,
zBool implementFunction
);
zWriteLiberty
Write the db as Liberty library.
zBool zWriteLiberty(
DB* db,
const char* fname,
IOType type,
const char* libraryName,
zBool allCells,
int generatedDataRepeat
);
zWriteGzPutD
Write a decimal number to the output file.
void zWriteGzPutD(
struct zWriteInfo* writeInfo,
double d
);
zWriteGzPutX
Write a decimal number to the output file.
void zWriteGzPutX(
struct zWriteInfo* writeInfo,
int i
);
zWriteBinR
Write a record marker to the output file.
void zWriteBinR(
struct zWriteInfo*,
char
);
zWriteBinC
Write a char to the output file.
void zWriteBinC(
struct zWriteInfo*,
char
);
zWriteBinI
Write int to the output file.
void zWriteBinI(
struct zWriteInfo*,
int
);
zWriteBinU
Write unsigned to the output file.
void zWriteBinU(
struct zWriteInfo*,
unsigned
);
zWriteBinL
Write long (8 bytes) to the output file.
void zWriteBinL(
struct zWriteInfo*,
zLong
);
zWriteBinUL
Write unsigned long to the output file.
void zWriteBinUL(
struct zWriteInfo*,
zULong
);
zWriteBinLL
Write long long to the output file.
void zWriteBinLL(
struct zWriteInfo*,
long long
);
zWriteBinULL
Write long long to the output file.
void zWriteBinULL(
struct zWriteInfo*,
unsigned long long
);
zWriteBinS
Write a string to the output file.
void zWriteBinS(
struct zWriteInfo*,
const char*
);
zWriteBinSLen
Write a beginning of string to the output file.
void zWriteBinSLen(
struct zWriteInfo*,
int len,
const char*
);
zWriteSposComment
Write comment with spos to the corresponding module.
void zWriteSposComment(
struct zWriteInfo* writeInfo,
struct Spos* spos,
const char* commentChar
);
Write Functions
Function pointer that are called by zWrite to output objects.
struct zWriteFunctions {
void (*writeHeader) (struct zWriteInfo*);
void (*writeFooter) (struct zWriteInfo*);
void (*writeDatabaseAttribute) (struct zWriteInfo*, char* attr);
void (*writeSposFile) (struct zWriteInfo*, Sfile* sfile);
void (*writeSposLineInfo) (struct zWriteInfo*, Sfile* sfile);
void (*writePrimitiveBegin) (struct zWriteInfo*, Primitive* prim);
void (*writePrimitiveEnd) (struct zWriteInfo*, Primitive* prim);
void (*writeModuleBegin) (struct zWriteInfo*, Module* mod,
zBool ignoreContent);
void (*writeModuleEnd) (struct zWriteInfo*, Module* mod);
void (*writeInterfaceBegin) (struct zWriteInfo*);
void (*writePort) (struct zWriteInfo*, Cell* cell, Port* p);
void (*writePortBus) (struct zWriteInfo*, Cell* cell, PortBus* p);
void (*writeInterfaceEnd) (struct zWriteInfo*);
void (*writeInstListBegin) (struct zWriteInfo*);
void (*writeInst) (struct zWriteInfo*, Module* mod, Inst* i);
void (*writeInstListEnd) (struct zWriteInfo*);
void (*writeNetListBegin) (struct zWriteInfo*);
void (*writeNetBegin) (struct zWriteInfo*, Module* mod, Net* n);
void (*writePinRef) (struct zWriteInfo*, Module* mod, PinRef* p);
void (*writeNetEnd) (struct zWriteInfo*, Module* mod, Net* n);
void (*writeNetListEnd) (struct zWriteInfo*);
void (*writeNetBusListBegin) (struct zWriteInfo*);
void (*writeNetBus) (struct zWriteInfo*, Module* mod, NetBus* n);
void (*writeNetBusListEnd) (struct zWriteInfo*);
void (*writeFlatHicol) (struct zWriteInfo*, const char* oid,
HiCol* hicol);
void (*writeFlatFlags) (struct zWriteInfo*, const char* oid,
FNodeFlags flags);
void (*writeFlatAttrs) (struct zWriteInfo*, const char* oid,
FAttr* attrs, int);
void (*writeFlatOOMRs) (struct zWriteInfo*, const char* pinOid,
const char* netOid);
void (*writeFlatId) (struct zWriteInfo*,const char* oid,zUInt64);
void (*writeVirtualObject) (struct zWriteInfo*, VirtualObject* obj);
void (*writeTmpTop) (struct zWriteInfo*, Module* tmpTop);
void (*writeFlatHierTree) (struct zWriteInfo*);
void (*writeModuleContent) (struct zWriteInfo*, Module* mod);
void (*writeModuleFlat2) (struct zWriteInfo*, Module* mod);
void (*writeEof) (struct zWriteInfo*);
};
zWrite
Generic structural ZDB output interface.
zBool zWrite(
struct zWriteInfo* writeInfo,
DB* db,
const char* fname,
IOType type,
zBool doTSort,
zBool doSpos,
zBool doAttrs,
zBool doFlags,
zBool doFlat,
zBool doMangle,
zBool doStopCell,
int doComments,
const char* cellPattern,
struct zWriteFunctions* functions
);
Write and Read ASCII Format
ASCII Tokens
Tokens to identify database object.
#define AsciiMagicNum (0x12345678)
enum AsciiToken {
AsciiTNull = '\0',
AsciiTRec = '\n',
AsciiTEsc = 0x1B,
AsciiTEof = 0x03,
AsciiTMagic = '*',
AsciiTVersion = 'A',
AsciiTPlatform = '+',
AsciiTAttr = 'B',
AsciiTSfile = 'C',
AsciiTSline = 'D',
AsciiTSpos = 'E',
AsciiTNullType = 'F',
AsciiTPort = 'G',
AsciiTPbus = 'H',
AsciiTPrim = 'I',
AsciiTMod = 'J',
AsciiTTopMod = 'K',
AsciiTPara = 'L',
AsciiTInst = 'M',
AsciiTInstInfo = 'N',
AsciiTPin = 'O',
AsciiTNet = 'P',
AsciiTNetInfo = 'Q',
AsciiTPinRef = 'R',
AsciiTPortRef = 'S',
AsciiTNbus = 'T',
AsciiTNbusMem = 'U',
AsciiTHiCol = 'V',
AsciiTVirtualObject = 'W',
AsciiTPinInternal = 'X',
AsciiTFlatTopNode = 'a',
AsciiTFlatAttrName = 'b',
AsciiTFlatNamNode = 'c',
AsciiTFlatIdxNode = 'd',
AsciiTFlatAttr = 'e',
AsciiTFlatNetSeg = 'h',
AsciiTFlatPinOOMR = 'i',
AsciiTFlatNetOOMR = 'j',
AsciiTSymlibHeader = 'k',
AsciiTSymlibIO = 'l',
AsciiTSymlibSpice = 'm',
AsciiTSymlibAmap = 'n',
AsciiTSymlibSym = 'o',
AsciiTSymlibComment = 'p',
AsciiTSymdef = 'q',
AsciiTTmpTop = 'r',
AsciiTHeader = 't',
AsciiTInstPara = 'v',
AsciiTCellCnt = 'w',
AsciiTParaModPos = 'x',
AsciiTModPos = 'y',
AsciiTSeekEnd = 'z',
AsciiTReloadPara = '1',
AsciiTReload = '2',
AsciiTFlatModPos = '3',
AsciiTSfilePos = '4',
AsciiTFlatHierNode = '5',
AsciiTFlatHierInstNode = '6',
AsciiTFlatPrimInstNode = '7',
AsciiTFlatChildEnd = '8',
AsciiTFlatIdNode = '9'
};
zWriteAscii
Write the database as an ASCII file.
zBool zWriteAscii(
DB* db,
const char* fname,
IOType type
);
zWriteAsciiFlatNodeInfoAdd
add fnode to uniq number mapping. Internal use.
void zWriteAsciiFlatNodeInfoAdd(
struct zWriteInfo* writeInfo,
struct FNode* fnode
);
zWriteAsciiFlatModInfoGet
get fnode to uniq number mapping. Internal use.
zULong zWriteAsciiFlatNodeInfoGet(
struct zWriteInfo* writeInfo,
struct FNode* fnode
);
zWriteAsciiFlatModInfoAdd
add module to fnode number mapping. Internal use.
void zWriteAsciiFlatModInfoAdd(
struct zWriteInfo* writeInfo,
Module* mod,
struct FTopNode* topNode,
struct FNode* n
);
zWriteAsciiFlatModInfoGet
get module to fnode number mapping. Internal use.
struct FlatModInfo* zWriteAsciiFlatModInfoGet(
struct zWriteInfo* writeInfo,
Module* mod
);
zReadAscii
Read an ASCII file and fill a database.
typedef struct {
int major;
int minor;
int parserBits;
} zAsciiHead;
zBool zReadAscii(
DB* db,
const char* fname,
IOType type,
zAsciiHead* head,
zBool quick
);
zBool zReadAscii_autoPopulateModule(
DB* db,
Module* mod
);
zBool zReadAscii_autoPopulateModuleOID(
DB* db,
const OID* oid
);
zReadAscii_PopulateModule
Populate the database with the contents of the given module.
zBool zReadAscii_PopulateModule(
DB* db,
const char* moduleName,
zBool parasitic,
zBool withFlat
);
zReadAscii_PopulateFlat
Populate the database with the flat data of the given module.
zBool zReadAscii_PopulateFlat(
DB* db,
const char* moduleName
);
zReadAscii_PopulateSourceFileInfo
Incrementally fill the source file information in the database for the source file with the given index.
zBool zReadAscii_PopulateSourceFileInfo(
DB* db,
int sFileIdx
);
zTestAscii
Internal use.
void zTestAscii(
DB* db
);
Interface between Tcl and ZDB
Get the Database by Name
zT_GetDbFromName
Get DB* struct for a db tcl cmd name.
DB* zT_GetDbFromName(
Tcl_Interp* interp,
CONST char* name
);
Work with OIDs
zT_SetOIDObj
The Tcl_Obj is made an OID-type by setting its internal representation.
void zT_SetOIDObj(
DB* db,
Tcl_Obj* theObj,
const OID* source
);
zT_GetOIDFromObj
Get the OID from the given Tcl_Obj.
int zT_GetOIDFromObj(
DB* db,
Tcl_Interp* interp,
Tcl_Obj*,
OID* resultPtr
);
zT_GetOIDListFromObj
Get an OID list from the given Tcl_Obj.
int zT_GetOIDListFromObj(
DB* db,
Tcl_Interp* interp,
Tcl_Obj* CONST,
OID**
);
zT_GetUnsharedOID
Make *varP point to an unshared (i.e. writable) OID-type Tcl_Obj and return the OID pointer.
OID* zT_GetUnsharedOID(
DB* db,
Tcl_Interp* interp,
Tcl_Obj** varP,
const OID*
);
Set the Tcl Result
zT_SetOIDResult
Set an OID as the Tcl object result.
void zT_SetOIDResult(
DB* db,
Tcl_Interp* interp,
const OID* result
);
zT_GetObjFromOID
Get the Tcl object from an OID.
Tcl_Obj* zT_GetObjFromOID(
DB* db,
const OID* oid
);
zT_ErrorSetResult
Set an Tcl error result.
void zT_ErrorSetResult(
Tcl_Interp* interp,
const char*,
Tcl_Obj*,
const char*
);
The OEM Specific Header Files
FlexNet License Check for OEM Customers
Functions to Interact with the License Sub-System
zLicenseCheckoutFeature
Check out a the given FlexNet feature. In case of an error the error message can be retrieved with zGetError().
zBool zLicenseCheckoutFeature(
const char* featureName
);
zLicenseSetParserBit
Set parser bit to identify the creator of a database.
zBool zLicenseSetParserBit(
DB* zdb,
const char* featureName
);