# VLSI SAPD Documentation

Presentation | AGDS | CIF | DTR | OPENCHAMS | SPICE | Links & Contact

AGDS Format

# Presentation

The Ascii Graphic Database System (AGDS) format is an ascii (text) version of the wellknown and industry standard GDS II binary format. This format hierarchicaly represents geometric shapes, labels and other layout informations (see http://en.wikipedia.org/wiki/GDSII for more informations).
The ascii format has several advantages versus binary format:

- human readable,
- easy to edit manually or with dedicated tools,
- easy to search or grep into,
- easy to compare and understand differences between two files,
- easy to convert.

The conversion from Ascii GDS to binary GDS and vice versa can be done with OwlVision GDSII Viewer available at http://owlvision.org
Since it has been developped in java, it can be run on all platforms.

## Author

Damien Dupuis: damien.dupuis(at)lip6(.)fr

## Limitations

Currently the only supported shape in this driver is the rectangle.

# Stand alone database structure

The database conists in for simple objects :

- AGDS::Library contains all AGDS library informations such as the name, the units used (user and physical) and the list of all Structures.
- AGDS::Structure describes a GDS Structure with a name and a list of Elements.
- AGDS::Element is an abstract class from which derived the AGDS::Rectangle.
- AGDS::Rectangle describes a rectangle element of a structure.

## Using the driver

To drive an AGDS file, user has to create one AGDS::Library and add AGDS::Structure objects to it with the AGDS::Library::addStructure() method. Each AGDS::Structure contains at least one AGDS::Element added with AGDS::Structure::addElement() method.
All objects can be independently created as far as they are correctly added to their parent.
Once the library is completely specified, simply call the AGDS::Library::writeToFile() method to drive the database to file.

# Examples

As said is the global presentation, VLSI SAPD project provides C++ libraries and Python modules for each supported format. In this section we present two simple code examples to drive a AGDS file using C++ or Python. These two examples drive the same file `transistor.agds:`

HEADER 5;
BGNLIB;
LASTMOD {10-06-11 14:02:15};
LASTACC {10-06-11 14:02:15};
LIBNAME myTestLib.DB;
UNITS;
USERUNITS 0.001;
PHYSUNITS 1.000000e-09;
BGNSTR;
CREATION {10-06-11 14:02:15};
LASTMOD {10-06-11 14:02:15};
STRNAME Transistor;
BOUNDARY;
LAYER 17;
DATATYPE 0;
XY 5;
X: 305; Y: 150;
X: 305; Y: 830;
X: 365; Y: 830;
X: 365; Y: 150;
X: 305; Y: 150;
ENDEL;
BOUNDARY;
LAYER 6;
DATATYPE 0;
XY 5;
X: 130; Y: 290;
X: 130; Y: 690;
X: 540; Y: 690;
X: 540; Y: 290;
X: 130; Y: 290;
ENDEL;
ENDSTR;
ENDLIB;
AGDS example layout

## C++

Here is the C++ code (`driveAgds.cpp`) used to generate the transistor.agds file. (Source is available in examples directory).

#include <string>
using namespace std;
#include "vlsisapd/agds/Library.h"
#include "vlsisapd/agds/Structure.h"
#include "vlsisapd/agds/Rectangle.h"
int main(int argc, char * argv[]) {
AGDS::Library* lib = new AGDS::Library(string("myTestLib"));
lib->setUserUnits(0.001);
lib->setPhysUnits(1.0E-9);
AGDS::Rectangle* poly = new AGDS::Rectangle( 17, 305, 150, 365, 830 );
AGDS::Rectangle* active = new AGDS::Rectangle( 6, 130, 290, 540, 690 );
AGDS::Structure* str = new AGDS::Structure("Transistor");
str->addElement(poly);
str->addElement(active);
lib->addStructure(str);
lib->writeToFile("./transistor.agds");
return 0;
}

Note
  In order to compile this code, a CMakeLists.txt file is provided. User must set the $VLSISAPD_TOP variable before running these commands in the directory containing the CMakeLists.txt file:
  %> mkdir build; cd build
  %> cmake ..
  %> make

## Python

Here is the Python code (`driveAgds.py`) used to generate the transistor.agds file. (Source is available in examples directory).

import AGDS
lib = AGDS.Library("myTestLib")
lib.setUserUnits(0.001)
lib.setPhysUnits(1.0e-9)
active = AGDS.Rectangle( 6, 120, 290, 540, 690) # layer 6 corresponds to active
poly = AGDS.Rectangle(17, 305, 150, 365, 830) # layer 17 corresponds to polysilicium
str = AGDS.Structure("Transistor")
str.addElement(active)
str.addElement(poly)
lib.addStructure(str)
lib.writeToFile("./transistor.agds")

Note
  In order to run the `driveAgds.py` script, user must ensure that $PYTHONPATH variable points to the directory containing AGDS.so module.