KLayout Mask Generation SOP

KLayout is an open-source layout viewer and editor that offers advanced GUI, is scriptable in Ruby or Python, and has built-in DRC support. We will discuss installation, setup, and use of DRC and macros.

KLayout Installation

  1. Go to this page and select the correct operating system for your laptop.

  2. Follow the installation wizard’s instructions, and leave all options as default.

WARNING: If you install KLayout in an existing folder, the uninstaller will erase this folder including everything else there is! There are reports of users who by mistake installed KLayout in the root of the "C:" drive and the uninstaller tried to wipe the whole disk.

Once installed, there should be three versions of KLayout: an “editor” version, a “default” version, and a “viewer” version. The “editor” version will be used when you create your own layouts, while the “viewer” version is pulled up when opening an existing GDS file. While in the “viewer” version, edits cannot be made to the layout.

Setup of PCells, Macros, and DRC

You will need the files in this folder.

  1. Open the “editor” version of KLayout.

  2. In the top tab, click Macros >> Macro Development.

  1. A new Macro Development tab should appear. Select Ruby >> Local in the window on the left.

  1. Download pcell_library.lym in the folder. Inside the Local folder, right click and select Import, then select pcell_library.lym. If there is another pcell file in the folder, delete it.

  2. Press the plain green Play button on the top right bar. This will instantiate the PCell Library, and you will now be able to use PMOS, NMOS, Resistor, and Template PCells.

  3. Now, click the Local - ruby branch folder in the left window (shown in the images above).

  4. Download the parse_exposures.rb file in the folder. Right click inside the left window, select Import, then select parse_exposures.rb. Now you are able to use the GDS separating macro.

  5. Select DRC >> Local in the same left window

  1. Download drc.lydrc from the folder, right click inside the left window, select Import, and import drc.lydrc. If there is another file inside the DRC tab, delete it.

  2. Press the plain green Play button on the top right bar (shown in a previous image). This will allow you to use the set of DRC rules you have defined.

Creating A New Layout

  1. To create a new layout, open the “editor” version of KLayout.

  2. Click File >> New Layout.

  1. Set the layer and database unit values in the popup window.

Layers used for the PCell library written are: via (1/0), metal (2/0), poly (3/0), contact (4/0), ndiff (5/0), pdiff (6/0), nwell (7/0), psub (8/0)

Set the database unit to 1 um.

  1. A new layout tab should be added.

If you want to hide a layer, double click it in the Layers tab. If you want to adjust colors of each layer, go to View >> Layer Toolbox. To create a new layer, go to Edit >> Layer >> New Layer in the top left of the tab.

  1. To draw shapes in KLayout, use the tools in the top tab.

“Box” will allow you to draw a box in the selected layer. “Polygon” allows you to draw a polygon in the selected layer. “Partial” allows you to drag and drop sides of your shape to change them.

If you have a shape selected, pressing “q” will allow you to type in shape properties.

  1. To add PCell components, click “Instance.” This will open up a tab on the right side of the window.

If we want to select cells from the PCell Library we wrote, Click on “Library” and select “Lib - My PCell Library with Resistor.”

If we want to select a different kind of PCell, press the magnifying glass next to “Cell” and the image to the right will pop up as a window. Select the cell you want and press “OK.”

  1. To place a PCell, click on the grid where you want it to be placed. It will appear as a white box with text inside. If you want to view the layers, go to Display >> Full Hierarchy, and it will show the layers within the PCells.

  1. To adjust PCell parameters, go to Select, then click the PCell you want to change. Press “q”, then go to “PCell Parameters” and adjust the values as needed.

Designing and Exporting Masks

  1. Open a new layout with the layer setup below.

via (1/0), metal (2/0), poly (3/0), contact (4/0), ndiff (5/0), pdiff (6/0), nwell (7/0), psub (8/0)

  1. Place a “Template” PCell instance where you want . This shows the size of one exposure and places the alignment marks. If your design has multiple exposures, place one “Template” PCell per exposure, like shown. Make sure the alignment marks are properly aligned.

  1. Place components, boxes, shapes, etc. to create the circuit/device array you want, then save the layout as a GDS file. MAKE NOTE OF WHERE THE LAYOUT IS SAVED.

  2. Click Macro >> Macro Development.

  3. Go to the Ruby tab inside the Macro Development window, then open parse_exposures.

  4. Click the green play button with a line through it (highlighted below).

This will run the macro, and create separate GDS files for each exposure (“Template” instance) inside the layout. The files will be titled template_<NUMBER>.gds, and will be stored inside the same folder as the original layout.

  1. Upload all the template_<NUMBER>.gds files.

  2. Adjust the parameters in the bottom-most block of code according to your Fabublox process.

num_exposures = 3 # List number of exposures in layout here

layers_dark = ["metal", "poly"] # List layers that blocks light where the pattern is

layers_clear = ["n+"] # List layers that lets light through where the pattern is

  1. Click Runtime >> Run All. The mask PNGs will be generated inside the Files tab on the left.

To download a mask, hover over the file, press the three dots that appear on the right, and press “Download.”

Last updated