Installing and “tuning up” xschem

For skywater 130nm PDK integration install at least xschem version 3.0.0
If the version of xschem available through Ubuntu is adequate you can install it using:

sudo apt install xschem

Otherwise, download and compile the latest version from the source distribution

xschem requires a number of supporting software packages

  • build-essential

  • flex

  • bison

  • libx11-6

  • libx11-dev

  • libxcb1

  • libx11-xcb-dev

  • libxrender1

  • libxrender-dev

  • libcairo2

  • libcairo2-dev

  • libxpm4

  • libxpm-dev

  • tcl8.6

  • tcl8.6-dev

  • tk8.6

  • tk8.6-dev

  • gawk

  • graphicsmagick

  • vim-gtk3

  • libjpeg-dev

To check what packages are installed use apt list package-name

To install the missing packages use sudo apt install package-name

Most packages are already presents on the systems since we already installed them for magic and ngspice

Here are the steps for installing, setting up and configuring xschem:

1. download xschem:

cd
git clone https://github.com/StefanSchippers/xschem.git git_xschem

2. configure and install xschem

cd ./git_xschem
./configure --prefix=/home/$(whoami)/opt/xschem
make
make install

the location of xschem's binaries (xschem and rawtovcd) is /home/<unixusername>/opt/xschem/bin

3. edit the .bash_profile file to add the xschem's binaries to the PATH

cd
.bash_profile
#!/usr/bin/bash

PATH=${PATH}

# Careful:
# when there is .bash_profile the WSL terminal does not source .bashrc by default
source ~/.bashrc

# prevent "Warning: Missing charset in String to FontSet conversion"
export LC_ALL=C

# magic: binaries location
MAGIC_BIN=$HOME/opt/magic/bin
export CAD_ROOT=$HOME/opt/magic/lib

# netgen: binaries location
NETGEN_BIN=$HOME/opt/netgen/bin

# ngspice: binaries location
NGSPICE_BIN=$HOME/opt/magic/bin

# xschem: binaries location
XSCHEM_BIN=$HOME/opt/xschem/bin

# setting up PDK root location
export PDK_ROOT=$HOME/share/pdks

# PATH
PATH="$XSCHEM_BIN:$NGSPICE_BIN:$MAGIC_BIN:$NETGEN_BIN:$PATH"

# eliminate duplicates from the PATH
PATH="$(perl -e 'print join(":", grep { not $seen{$_}++ } split(/:/, $ENV{PATH}))')"

# and finally export the PATH
export PATH="$PATH"

4. xschem and tclsh

  • xschem relies on the use of tclsh in interactive mode

  • to use the tab key (for command completion) and the up and down arrow keys (for retrieving commands from the history buffer) we need to install the
    package tcl-tclreadline

sudo apt install tcl-tclreadline
  • and add the following lines to ~/.tclshrc

.tclshrc
if {$tcl_interactive} {
    package require tclreadline
    ::tclreadline::Loop
}

5. setting up xschem

  • xschem default preferences are in the file xschemrc located in the directory xschem_install_dir/share/xschem/
    (with xschem_install_dir set to ~/opt/xschem)

  • to customize the default preferences xschem provides a special directory ~/.xschem/

  • copy the default xschmrc file into ~/.xschem/ and edit it according to your preferences

xschemrc (customization example)
...

# CT: 20211201
set XSCHEM_LIBRARY_PATH {}
append XSCHEM_LIBRARY_PATH $env(HOME_DIR)/ngs406/xSchems
append XSCHEM_LIBRARY_PATH :$env(HOME_DIR)/Lib406
append XSCHEM_LIBRARY_PATH :${XSCHEM_SHAREDIR}/xschem_library
append XSCHEM_LIBRARY_PATH :${XSCHEM_SHAREDIR}/xschem_library/devices
append XSCHEM_LIBRARY_PATH :$env(HOME)/share/pdks/sky130A/libs.tech/xschem
# end CT

...

# CT: 20211201
# set XSCHEM_START_WINDOW {sky130_tests/top.sch}
# end CT

...

# CT: 20211201
set netlist_dir $env(HOME_DIR)/ngs406/xSchems
# end CT

...

# CT: 20211201
# uncommented first two lines, added last two lines}
set hspice_netlist 1
set verilog_2001 1
set flat_netlist 0
set netlist_show 1
# CT end

...

# CT: 20211201
# SKYWATER PDK SPECIFIC VARIABLES
set SKYWATER_MODELS $env(HOME)/share/pdks/sky130A/libs.tech/ngspice
set SKYWATER_STDCELLS $env(HOME)/share/pdks/sky130A/libs.ref/sky130_fd_sc_hd/spice
# CT end

  • modify .bash_profile again to add xschem's HOME_DIR location

.bash_profile
#!/usr/bin/bash

PATH=${PATH}

# Careful:
# when there is .bash_profile the WSL terminal does not source .bashrc by default
source ~/.bashrc

# prevent "Warning: Missing charset in String to FontSet conversion"
export LC_ALL=C

# magic: binaries location
MAGIC_BIN=$HOME/opt/magic/bin
export CAD_ROOT=$HOME/opt/magic/lib

# netgen: binaries location
NETGEN_BIN=$HOME/opt/netgen/bin

# ngspice: binaries location
NGSPICE_BIN=$HOME/opt/magic/bin

# xschem: binaries location
XSCHEM_BIN=$HOME/opt/xschem/bin

# setting up PDK root location
export PDK_ROOT=$HOME/share/pdks

# setting xschem's HOME_DIR variable
export HOME_DIR=$HOME/ihome

# PATH
PATH="$XSCHEM_BIN:$NGSPICE_BIN:$MAGIC_BIN:$NETGEN_BIN:$PATH"

# eliminate duplicates from the PATH
PATH="$(perl -e 'print join(":", grep { not $seen{$_}++ } split(/:/, $ENV{PATH}))')"

# and finally export the PATH
export PATH="$PATH"
  • to make sure xschem's variables are set according to you expectations

    • start xschem and in the tcl shell prompt type the following commands:

puts $XSCHEM_LIBRARY_PATH
puts $XSCHEM_SHAREDIR
puts $USER_CONF_DIR
puts $SKYWATER_MODELS
puts $SKYWATER_STDCELLS
puts $netlist_dir
Response to the puts command (example)
/home/talarico/ihome/ngs406/xSchems:/home/talarico/ihome/Lib406:/home/talarico/opt/xschem/share/xschem/xschem_library:/home/talarico/opt/xschem/share/xschem/xschem_library/devices:/home/talarico/share/pdks/sky130A/libs.tech/xschem
/home/talarico/opt/xschem/share/xschem
/home/talarico/.xschem
/home/talarico/share/pdk/sky130A/libs.tech/ngspice
/home/talarico/share/pdk/sky130A/libs.ref/sky130_fd_sc_hd/spice
/home/talarico/ihome/ngs406/xSchems
  • for further details please look up the documentation and tutorials provided by xschem's author (Stefan Schippers)

6. Circuit simulation and visualization of the output waveforms
For the simulation and visualization of the outputs xschem provides the ability to interface with ngspice and gaw (Gtk Anaog Wave viewer).

7. Installing gaw
gaw (Gtk Analog Wave Viewer) does not come pre-packaged, so it must be installed from source, and in addition it requires the installation of the libgtk-3-dev package.

  • install the libgtk-3-dev package

sudo apt-get install libgtk-3-dev
  • download gaw source's code from here
    the latest version of gaw (@ 2 Dec. 2021) is ver. 20200922

  • extract, configure and compile the source code

tar zxvf gaw3-20200922.tar.gz
cd gaw-20200922
./configure
make
sudo make install
  • the gaw binary file is located at /usr/local/bin/gaw

  • the first time gaw gets started it creates a directory ~/.gaw containing the preference file gawrc

8. configure xschem for analog simulation (ngspice and gaw)

  • start xschem

  • go to Simulation > Configure simulators and tools

  • edit the configurations for ngspice, ngspice batch, and gaw viewer as follows:

alt text 
  • Click on Save Configuration to file
    the location of the configuration file is ~/.xschem/simrc

  • the meaning of the various variables used in the configuration settings is the following:

    • $N - netlist file full path (example: ~/ihome/ngs406/xSchems/tgate.spice)

    • $n - netlist file full path with extension chopped (example: ~/ihome/ngs406/xSchems/tgate)

    • $s - schematic name (example: tgate)

    • $d - netlist directory (example: ~/ihome/ngs406/xSchems)

    • for - more details lookup the file ~/opt/xschem/share/xschem/xschem.tcl

9. install the xschem's library for the skywater 130nm PDK

Instead of manually installing the xschem's skywater library from github (git clone https://github.com/StefanSchippers/xschem_sky130.git)
install it directly through the open_pdks as shown here.

The current (@ 3 Dec. 2021) xschem_sky130 examples use the model file locations installed by open_pdks