Gds21

docs

Gds21 Integrated Circuit Layout Parser & Writer

GDSII is the IC industry's de facto standard for storing and sharing layout data. Gds21 is a library for reading and creating GDSII data, similar to and largely inspired by libraries such as gdstk and its predecessor gdspy. Gds21 differs in being designed primarily as an interface layer to GDSII for the larger Layout21 library. Reading and generating GDSII-format data are primary goals; offering ease-of-use functionality for more elaborate manipulations of GDS data is not. (Although these manipulations can be performed on Gds21's data structures). Gds21 accordingly stores layout data on GDSII's terms, using GDSII's idioms, naming conventions, and datatypes.

Layout data is represented in three primary forms:

Usage

Loading a [GdsLibrary] from disk:

skip let lib = GdsLibrary::load("sample.gds")?;

Creating a new and empty [GdsLibrary], and adding a [GdsStruct] cell-definition:

rust use gds21::{GdsLibrary, GdsStruct}; let mut lib = GdsLibrary::new("mylib"); lib.structs.push(GdsStruct::new("mycell"));

Saving a [GdsLibrary] to disk:

skip lib.save("mylib.gds");

Serialization

Each element in Gds21's [GdsLibrary] tree is [serde]-serializable. GDSII data can be straightforwardly serialized in any serde-supported format. Examples:

let lib = gds21::GdsLibrary::new("mylib"); let json = serde_json::to_string(&lib); let yaml = serde_yaml::to_string(&lib); let toml = toml::to_string(&lib);

Gds21 includes built-in support for a subset of serde-formats via its [SerializationFormat] enumeration, and support for directly reading and writing files in each format via its accompanying [SerdeFile] trait. Example using [SerializationFormat::Yaml]:

```skip use gds21::SerializationFormat::Yaml; let lib = gds21::GdsLibrary::new("mylib");

// Write to YAML-format file Yaml.save(&lib, "mylib.gds.yaml")?; // And read back from file let lib2: gds21::GdsLibrary = Yaml.open("mylib.gds.yaml")?; ```

Note these text-based representations will generally be substantially larger than binary GDSII data.