Skip to main content

3D GDS viewer based on OpenSCAD

Project description

gds3xtrude

A simple layout to 3D converter.

gds3xtrude takes the layers of your layout and converts them into 3D volumes by extrusion.

gds3xtrude is intended to be used in two different ways:

  • as KLayout extension: Show 3D model of the active view.
  • as standalone tool: Convert GDS to OpenSCAD from the command line.

Screenshot

Dependencies

  • OpenSCAD: 3D modelling tool. Can be installed using the package manager of most linux distributions.
  • solidpython: Python library for creating OpenSCAD models.
  • klayout: Python module of KLayout used for GDS input/output and polygon operations.

Install (Linux)

As KLayout package

Use the KLayout package manager to install gds3xtrude. Dependencies (gds3xtrude python package, OpenSCAD) must be installed manually:

apt install openscad
pip3 install --user gds3xtrude

As standalone tool

When used as a standalone tool gds3xtrude additionally depends on the klayout Python package.

pip3 install --user gds3xtrude
pip3 install --user klayout

Install from Git (instead of installing using pip)

git clone [this repo]
cd gds3xtrude
python3 setup.py install --user

Install (Windows)

Windows is currently not supported but very likely you can get gds3xtrude running there with some tweaks. Here are some ideas how to install it:

Usage

As KLayout module

  • Open a layout.
  • Zoom in to the region you want to pass to gds3xtrude.
  • Select Tools -> gds3xtrude -> run script
  • Select the layerstack file for your technology. (Example for FreePDK45 can be found in examples/freepdk45.layerstack)

As standalone tool

Example usage:

# Get layerstack file for FreePDK45.
wget https://codeberg.org/tok/gds3xtrude/raw/branch/master/examples/freepdk45.layerstack

# Get a GDS file.
wget https://codeberg.org/tok/gds3xtrude/raw/branch/master/examples/NAND2X1.gds

# Run gds3xtrude
gds3xtrude --tech freepdk45.layerstack --input NAND2X1.gds --view

If you get an error like gds3xtrude: command not found the program is probably not in your PATH environment variable. Try to add the pip binary directory to the PATH variable first:

PATH=$PATH:$HOME/.local/bin
# And now again: gds3xtrude ...

Layer stack definition

To convert a 2D layout into a 3D model some information about the physical layer stack is necessary. This information must be passed to gds3xtrude as a file. An example of a simple layer stack description for the FreePDK45 can be found in examples/freepdk45.layerstack. Use this file as a starting point and adapt it to your needs.

Essentially a layerstack file is just a python script that defines some data structures.

Example:

from gds3xtrude.include import layer

# Define layers
poly = layer(15)
contact = layer(16)
metal1 = layer(21)

# Define RGB colors (optional)
poly.color = [0.8, 0.2, 0.2]
metal1.color = [0.2, 0.2, 0.8]

# Define additional layers from boolean operation
contact_to_silicon = contact - poly

# Define layer stack structure as a list of (layer thickness, [masks, ...]).
# The 3D model is created layer by layer from bottom to top.
layerstack = [
    (10, contact_to_silicon),
    (20, [contact, poly]),
    (50, contact),
    (50, metal1),
]

The crossection of the layer stack described in the example above is shown here. Note that the contact from metal1 down to silicon (which is not shown nor included in the example) consists of three parts. This is only due to the layer by layer creation of the 3D model but it is important to understand for writing the layerstack definition. For instance on the lowest layer there is only a piece of contact down to silicon. Contacts wich have polysilicon below do not reach this lowest layer. This is modelled as the boolean difference contact_to_silicon = contact - poly. Masks can be merged by putting them into a list as used for the second layer ([contact, poly]).

layer stack illustration

FreeCAD / Blender

The generated OpenSCAD models (.scad) can be imported into FreeCAD. If you want to use Blender for rendering, export the model from FreeCAD as a Wavefront (.obj) file. This can be imported in blender.

Color Issue

When applying a boolean union FreeCAD strips away colors. Therefore an exported .obj model will by totally gray. There is a workaround:

  • Open the OpenSCAD model in FreeCAD
  • Open the Model tab in Combo View
  • Expand the list of the imported model which is likely to be named Unnamed
  • Find a child node labelled union, select and delete it
  • Select the full model to be exported (Ctrl-A)
  • Now you can export to .obj without loosing color information

Additionally to the .obj file FreeCAD will also create a .mtl file containing material/color information. Blender will automatically read it when importing the .obj file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gds3xtrude-0.0.7.tar.gz (24.0 kB view hashes)

Uploaded Source

Built Distribution

gds3xtrude-0.0.7-py3-none-any.whl (36.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page