Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added argument parser, json input & example sky130 layer json file #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 22 additions & 34 deletions gdsiistl.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,50 +17,38 @@
user units (often microns).
"""

import sys # read command-line arguments
import gdspy # open gds file
from stl import mesh # write stl file (python package name is "numpy-stl")
import numpy as np # fast math on lots of points
import triangle # triangulate polygons
import argparse, json # parse args, json

# get the input file name
if len(sys.argv) < 2: # sys.argv[0] is the name of the program
print("Error: need exactly one file as a command line argument.")
sys.exit(0)
gdsii_file_path = sys.argv[1]

########## CONFIGURATION (EDIT THIS PART) #####################################

# choose which GDSII layers to use
layerstack = {
# (layernumber, datatype) : (zmin, zmax, 'layername'),

(235,4): (0, 0.1, 'substrate'),

(64,20): (0, 0.1, 'nwell'),
(65,44): (0, 0.1, 'tap'),
(65,20): (0, 0.1, 'diff'),
(66,20): (0, 0.1, 'poly'),
(66,44): (0, 0.1, 'licon'),
(67,20): (0, 0.1, 'li1'),
(67,44): (0, 0.1, 'mcon'),
(68,20): (0, 0.1, 'met1'),
(68,44): (0, 0.1, 'via'),
(69,20): (0, 0.1, 'met2'),
(69,44): (0, 0.1, 'via2'),
(70,20): (0, 0.1, 'met3'),
(70,44): (0, 0.1, 'via3'),
(71,20): (0, 0.1, 'met4'),
(71,44): (0, 0.1, 'via4'),
(72,20): (0, 0.1, 'met5'),
# (83,44): (0, 0.1, 'text'),
parser = argparse.ArgumentParser(
prog="gdsiistl",
description="Convert a GDSII 2D layout file to multiple 3D STL files that can be visualised in an external program."
)

parser.add_argument("gds_path", help="Specify the path to the GDSII file to process")
parser.add_argument("-l",
"--layers",
metavar="layer_file.json",
help="Specify the path to the JSON file containing the layers to extract. (Default: sky130.json)",
default="sky130.json")

args = parser.parse_args()
gdsii_file_path = args.gds_path

}

layers = None
with open(args.layers) as f:
layers = json.load(f)


## need to convert the json into the same format as the original layerstack dict
# layerstack = (layernumber, datatype) : (zmin, zmax, 'layername')
layerstack = {}
for layer in layers:
# min pos max pos
layerstack[(layer["LAYER_NUMBER"], layer["DATA_TYPE"])] = (layer["Z_POSITION"][0], layer["Z_POSITION"][1], layer["LAYER_NAME"])


########## INPUT ##############################################################
Expand Down
98 changes: 98 additions & 0 deletions sky130.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
[
{
"LAYER_NUMBER": 235,
"DATA_TYPE": 4,
"LAYER_NAME": "substrate",
"Z_POSITION": [-0.5, 0]
},
{
"LAYER_NUMBER": 64,
"DATA_TYPE": 20,
"LAYER_NAME": "nwell",
"Z_POSITION": [-0.24, -0.1]
},
{
"LAYER_NUMBER": 65,
"DATA_TYPE": 20,
"LAYER_NAME": "diff",
"Z_POSITION": [-0.5, 0.1]
},
{
"LAYER_NUMBER": 66,
"DATA_TYPE": 20,
"LAYER_NAME": "poly",
"Z_POSITION": [0, 0.2]
},
{
"LAYER_NUMBER": 66,
"DATA_TYPE": 44,
"LAYER_NAME": "licon",
"Z_POSITION": [0, 0.94]
},
{
"LAYER_NUMBER": 67,
"DATA_TYPE": 20,
"LAYER_NAME": "li1",
"Z_POSITION": [0.94, 1.04]
},
{
"LAYER_NUMBER": 67,
"DATA_TYPE": 44,
"LAYER_NAME": "mcon",
"Z_POSITION": [1.04, 1.38]
},
{
"LAYER_NUMBER": 68,
"DATA_TYPE": 20,
"LAYER_NAME": "met1",
"Z_POSITION": [1.38, 1.74]
},
{
"LAYER_NUMBER": 68,
"DATA_TYPE": 44,
"LAYER_NAME": "via",
"Z_POSITION": [1.74, 2.01]
},
{
"LAYER_NUMBER": 69,
"DATA_TYPE": 20,
"LAYER_NAME": "met2",
"Z_POSITION": [2.01, 2.37]
},
{
"LAYER_NUMBER": 69,
"DATA_TYPE": 44,
"LAYER_NAME": "via2",
"Z_POSITION": [2.37, 2.79]
},
{
"LAYER_NUMBER": 70,
"DATA_TYPE": 20,
"LAYER_NAME": "met3",
"Z_POSITION": [2.79, 3.64]
},
{
"LAYER_NUMBER": 70,
"DATA_TYPE": 44,
"LAYER_NAME": "via3",
"Z_POSITION": [3.64, 4.03]
},
{
"LAYER_NUMBER": 71,
"DATA_TYPE": 20,
"LAYER_NAME": "met4",
"Z_POSITION": [4.03, 4.88]
},
{
"LAYER_NUMBER": 71,
"DATA_TYPE": 44,
"LAYER_NAME": "via4",
"Z_POSITION": [4.88, 5.38]
},
{
"LAYER_NUMBER": 72,
"DATA_TYPE": 20,
"LAYER_NAME": "met5",
"Z_POSITION": [5.38, 6.65]
}
]