PREV UP NEXT

# XSCHEM SKY130 INTEGRATION

To use Xschem with the Google-Skywater 130nm process (here: Sky130) The following items must be followed:

- Install Xschem. Follow the Manual Install instructions

If you install xschem from sources ensure no xschem package is already installed in your linux system. Packaged xschem versions are too old so you should remove the installed package. The command for ubuntu/Debian systems is `sudo apt-get remove --purge xschem`

- Install the Magic VLSI layout editor. Instructions here.
- Install ngspice, by cloning the git source repository and building the program.

    ## clone the source repository into a local ngspice_git directory
    git clone https://git.code.sf.net/p/ngspice/ngspice ngspice_git
    cd ngspice_git
    mkdir release
    ./autogen.sh
    cd release
    ## by default if no --prefix is provided ngspice will install under /usr/local/{bin,share,man,lib}
    ## you can add a --prefix=/home/username to install into your home directory.
    ../configure --with-x --enable-xspice --disable-debug --enable-cider --with-readline=yes --enable-openmp --enable-osdi
    ## build the program
    make
    ## install the program and needed files.
    sudo make install

## IMPORTANT!!

You need to create the following `.spiceinit` file in the directory where simulations are run (typically `~/.xschem/simulations`) or in your home directory. This file sets some default behavior for reading .lib files and speeds up loading pdk model files. `
set ngbehavior=hsa
set ng_nomodcheck
`

- Install Open_Pdks that will provide among other things all the sky130 PDK data, including standard cells, SPICE models, layout data, timing information, design rules and provides also also the Xschem symbols of available silicon primitive devices and the set of locic standard cells built on top of these primitive devices. Instructions are here.
  Please ensure sufficient disk space is available (Open_pdks uses several GB, a lot of space can be recovered after installation by removing the source files if needed). Also keep in mind that the installation takes considerable time. The following steps are needed:

    ## fetch the repository with git:
    git clone git://opencircuitdesign.com/open_pdks
    cd open_pdks
    ## configure the build, a --prefix option can be given to install
    ## in a different place, by default after installation a
    ## /usr/local/share/pdk directory is created if no --prefix is provided.
    ## Below line for example requests installation in my home directory
    ## (/home/schippes/share/pdk):
    ## ./configure --enable-sky130-pdk --prefix=/home/schippes
    ## Do the following steps one at a time and ensure no errors are
    ##  reported after each step.
    ./configure --enable-sky130-pdk
    make
    sudo make install

If you want to install also the gf180mcu pdk replace the above ./configure command with the following:

     ./configure --enable-sky130-pdk --enable-gf180mcu-pdk

- At this point the complete PDK has been installed in `/usr/local/share/pdk` (or `<prefix>/share/pdk` if --prefix was provided).
  Xschem libraries also have been installed and are located under `<prefix>/share/pdk/sky130A/libs.tech/xschem/` or `<prefix>/share/pdk/sky130B/libs.tech/xschem/`.
  the `sky130B` directory contains the ReRAM Sky130 process option in addition to all `Sky130A` devices.
- After completing the above steps you can do a test run of xschem and use the Sky130 devices. You need to create a new empty drectory, create a new xschemrc file with the following content: (`source <prefix>/share/pdk/sky130B/libs.tech/xschem/xschemrc`) and run xschem:

    mkdir test_xschem_sky130
    cd test_xschem_sky130
    echo 'source /usr/local/share/pdk/sky130B/libs.tech/xschem/xschemrc' > ./xschemrc
    xschem

- If all went well the following welcome page will be shown. The page contains some example circuits on the left and shows all the available silicon devices on the right. You can descend into the example circuits on the left by clicking the symbols (they will turn to grey meaning they are selected) and press the `e` key or by menu `Edit->Push schematic`. You can return to the parent level by pressing `Ctrl-e` or by menu `Edit->Pop`.
  You can disable the welcome page by commenting the following line in the xschemrc file:

      set XSCHEM_START_WINDOW {sky130_tests/top.sch}

  or:

      unset XSCHEM_START_WINDOW

## PDK_ROOT and PDK environment variables

Xschem (via the xschemrc file) looks for a `PDK_ROOT` environment variable that points to the installed pdk to use. This is expecially useful if multiple or different versions of the pdk are installed. If the pdk is installed in `/usr/local/share/pdk` PDK_ROOT should be set to `/usr/local/share/pdk`. For `Sky130` another variable `PDK` tells the process variant to use (currently `sky130A`) or `sky130B`). If `PDK` is unset the default `sky130A` will be used. If no PDK_ROOT variable is defined xschem will look into the following locations and pick the first existing found in the order listed below:

1. `/usr/share/pdk`
2. `/usr/local/share/pdk`
3. `~/share/pdk`

If no pdk is found a warning message is displayed on the xschem launching terminal.

## Simulating a circuit with sky130 devices

The best way to quickly set up a simulation with Xschem is to look at some of the provided examples. If you descend into the `test_inv` component you see a working circuit ready for simulation.
One line is needed in the spice netlist to load the spice models:

    .lib /usr/local/share/pdk/sky130A/libs.tech/ngspice/sky130.lib.spice tt

The exact path depends on the install location of the pdk as explained above. In the picture above the `TT_MODELS` component takes care of generating the .lib line in the netlist. the `tt` at the end of the `.lib` line is the process corner (tt = typical n, typical p transistors). You can change the corner to `ss, sf, fs, ff` to verify your design across process variations.

You see in the circuit a `COMMANDS2` component. This component allows to enter text to specify the simulation to run, giving simulator commands and options. You place this component by pressing the `Insert` or `i` key, browsing into the standard xschem `devices` directory and placing `code_shown.sym` or `code.sym` into the schematic.
Once placed in the schematic, you may click the component, press `q` to edit its attributes, set the `Edit attr.` listbox on the right to `value` and enter the simulator commands to run the simulation. You can give a reference name to this component by setting the `Edit attr.` listbox to `name` and give it a name that will be diplayed in the schematic. (`COMMANDS2` in the example).

Note in above commands a `write test_inv_ngspice.raw` command. This example runs simulation with both Xyce and ngspice so the output raw file is differentiated. If you just plan to use one simulator a good suggestion is to write a raw file with the same name as the circuit, so `write test_inv.raw`.

If you select the TT_MODELS component and press `q` you see the reference to the PDK top library SPICE file. The path is specified using TCL variables that have been generated by xschem when the pdk installation was looked up. This allows to have portable schematics, no absolute path is hardcoded in the schematic files.
If everything is set up correctly pressing the `Netlist` button or hitting the `n` key will produce a spice netlist of the circuit. The netlist location is by default set to your home directory: `~/.xschem/simulations`

    schippes@mazinga:~/x/test_open_pdks$ ls -ltr ~/.xschem/simulations/
    ...
    ...
    -rw-r--r-- 1 schippes schippes      3266 ott 18 15:26  test_inv.spice

You can then simulate the circuit. Select the simulator to use by clicking menu `Simulation->Configure simulators and tools` and selecting (for this example) `ngspice`
Press the `Simulation` button and see the ngspice running in a terminal:

The default terminal used by xschem to run the simulator is `xterm`. I strongly suggest you to install xterm (on ubuntu/debian Linux: `sudo apt-get install xterm`) since it is a very small package and is not a broken terminal like most Gnome/KDE/LXDE stuff. You can however use any terminal editor by specifying the one to use in your xschemrc. If not specified xschem defaults to `xterm` `
## set terminal xterm
set terminal gnome-terminal
`

After completing simulation you can add into the schematic a graph (`Simulation->Add waveform graph`) and a waveform reload launcher (`Simulation->Add waveform reload launcher`). The launcher has a `tclcommand` attribute that loads the simulator data file (`test_inv.raw`) and specifies the type of analysis (`op, dc, ac, tran`)
See the manual for details