In an attempt to address that helpless
feeling that comes when a GDSII file will sometimes not work,
a simple CPP program has been written to be able to look inside and
experiment with a GDSII binary file.
An IC layout essentially involves the placement of objects often
referred to as geometries.
Geometries are things like boxes (polygons), paths (wires), text
Transistors are made out of a collection of geometries grouped
together in a file which is called a cell.
A circuit mainly involves just placing a bunch of transistor cells
together and wiring all their nodes up using metal layer wires.
Text can (should) be added to make the layout process much easier.
The layout below adds an example of all those geometries. Both GDSII and layout files are normally
stored in binary format.
ICEDIT also has a way to print out a layout in text format.
When a GDSII file is translated to text format (shown below) is
in a similar style.
Each piece of data in a GDSII
is stored in own self contained
block of code.
two bytes read in tell how big
the block is.
two bytes tell what the block
And the remaining
bytes are read into a simple byte array which can
either be a number(s) or text.
The listing above is from a printout from a simple GDSII file
This programs just reads each block one at a time and prints out the
Block Name ID and the value(s) contained within.
Hopefully it should be possible to read and printout a troublesome
GDSII stream file until it gets into trouble.
And then go in and maybe adjust some code to look at troublesome
There are some name changes between the ICEDIT format and GDSII. Boxes
(polygons) are indicated by the BOUNDARY ID.
Wires (path) are PATHS which
have a width.
seems to the geometries contained inside the BGNSTR
The placement of a cell appears to use the SREF ID.
All Cells which are referenced are completely contained in the GDSII
like cell rotation and hierarchy need to be included in a GDSII file as
The text printout for this layout above shows only cell placement and
ID=143 AT (-1.8, 7.3)
ADD CELL "AT_ZERO"
ID=141 AT ( 0.0, 0.0)
ADD CELL "NMOS"
AT ( 6.3,-1.5)
ADD CELL "NMOS" ID=145
AT (16.4, 7.3)
ADD CELL "NMOS" ID=144
AT ( 7.5, 6.6)
is not a problem for layout since the all the cell are usually
contained in one directory.
But the GDSII file needs to contain all cell geometries including
cells that are placed inside other cells.
GFDSII format of storing all information is shown above.
Apparantly a mirror in the X direction is being done with a reflection
and a 180 degree rotation.
The simple GDSII_read_Program
is given here for reference sake only.
This program is written more in a style to make some hard to see
critical details stand out.
It was written on a MacBook and is intended more for personal debugging
There are several GDSII translation programs online which do the same
The latest mac version is GdsDump-OSX.
So far, the GdsDump-OSX program has yet to crash on a GDSII file.
For information sake, the following are listings of the various types
Code Mnemonic Data Type description
0 0002 HEADER Two-Byte
Signed Integer version number
1 0102 BGNLIB Two-Byte
Signed Integer begin of library, last modification date and time
2 0206 LIBNAME Two-Byte
Signed Integer name of library
3 0305 UNITS
Eight-Byte Real user and database units
4 0400 ENDLIB No Data
end of library
5 0502 BGNSTR Two-Byte
Signed Integer begin of structure + creation and modification time
6 0606 STRNAME ASCII string
name of structure
7 0700 ENDSTR No Data
end of structure
8 0800 BOUNDARY No Data begin of
9 0900 PATH
No Data begin of path element
10 0A00 SREF No
Data begin of structure reference element
11 0B00 AREF No
Data begin of array reference element
12 0C00 TEXT No
Data begin of text element
13 0D02 LAYER Two-Byte
Signed Integer layer number of element
14 0E02 DATATYPE Two-Byte Signed Integer
Datatype number of element
15 0F03 WIDTH Four-Byte
Signed Integer width of element in db units
Four-Byte Signed Integer list of xy coordinates in db units
17 1100 ENDEL No Data
end of element
18 1206 SNAME ASCII
string name of structure reference
19 1302 COLROW Two-Byte
Signed Integer number of colomns and rows in array reference
21 1500 NODE No
Data begin of node element
22 1602 TEXTTYPE Two-Byte Signed Integer
23 1701 PRESENTATION Bit Array text presentation, font
25 1906 STRING ASCII string
character string for text element
26 1A01 STRANS Bit Array
array reference, structure reference and text transform flags
27 1B05 MAG
Eight Byte Real magnification factor for text and references
28 1C05 ANGLE Eight
Byte Real rotation angle for text and references
31 1F06 REFLIBS ASCII string name
of referenced libraries
32 2006 FONTS ASCII
string name of text fonts definition files
33 2102 PATHTYPE Two-Byte Signed Integer
type of PATH element end ( rounded, square)
34 2202 GENERATIONS Two-Byte Signed Integer number of
deleted structure ?????
35 2306 ATTRTABLE ASCII string attribute table,
used in combination with element properties
38 2601 ELFLAGS Two-Byte Signed
Integer template data
42 2A02 NODETYPE Two-Byte Signed Integer
node type number for NODE element
43 2B02 PROPATTR Two-Byte Signed Integer
44 2C06 PROPVALUE ASCII string attribute name
45 2D00 BOX
No Data begin of box element
46 2E02 BOXTYPE Two-Byte Signed
Integer boxtype for box element
47 2F03 PLEX
Four-Byte Signed Integer plex number
50 3202 TAPENUM Two-Byte Signed
Integer Tape Number
51 3302 TAPECODE Two-Byte Signed Integer
54 3602 FORMAT Two-Byte
Signed Integer format type
55 3706 MASK
ASCII string list of layers
56 3800 ENDMASKS No Data end of MASK