# Python Programming Integration with IC-CAP

Blog Post created by rajsodhi on Mar 16, 2017

Python is a programming language that lets you work quickly and integrate systems more effectively. It’s been used in many areas such as Statistical Analysis, or Artificial Intelligence; and it is also very useful in Device Modeling.

Today we are going to introduce the Python integration with Keysight IC-CAP device modeling platform (version 2013 and up), where we can readily use Python to gain additional productivity.

We will go through one example to get the MOSFET threshold voltage (Vth) using Python, but first, let’s take a look at what version and libraries are supported in IC-CAP.

 Python Version 2.7.3 Platform Windows and Linux IC-CAP support

Supported Libraries:

 iccap The built-in IC-CAP APIs dedicated to device modeling. NumPy The fundamental package for scientific computing with Python. SciPy Goes hand-in-hand with NumPy, is an ecosystem for mathematics, science, and engineering. matplotlib A Python 2D plotting library which produces publication quality figures. PySide Python bindings for the Qt to create innovative devices, modern UIs.

“iccap” is a built-in Python module in IC-CAP which provides objects (such as Model, Dut and Input) to interact with IC-CAP data structures. Below is the Python API tree, and more detailed API explanation and Python tutorial can be found in IC-CAP’s user manual.

Now, let’s take a look at how to use Python to do data analysis, such as to calculate Vth from an IdVg curve in IC-CAP. The example is based on the built-in model file: \$ICCAP_ROOT/examples/model_files/mosfet/nmos3.mdl.

Figure 1. Vth algorithm using Icon method with deltaW(xw) and deltaL(xl)

NOTE: There are many possible methods to calculate Vth 1. For today’s example, we will use the constant current approach1,2, which is widely used in industry due to its simplicity.

The steps are:

1. Open the “nmos3.mdl” file from ICCAP Main window.

2. Open the nmos3 model window, as shown below:

3. Switch to the “Macros” tab, where we see some pre-defined PEL macros.

4. Now, we can add a macro via the “New…” button at left, name it “cal_vth”, and set the Macro type to be “Python (Local Namespace) option, as highlighted below:

The Python script shown above calculates Vth from the IdVg@Vb=0 curve from the large DUT.
5. On line 23, we used a Python class called VthCon in which the Vth extraction algorithm is implemented. This calculation can be implemented in the IC-CAP UI, or one can create and refer to an existing Python script created outside of IC-CAP. We will show both methods.
1. Create the VthCon Python Class in ICCAP
Use “New…” to create another macro, name it VthCon, and add the content, as  shown below:

After the class VthCon and calculate functions have been defined, click on the “Execute” button so that the class gets registered in ICCAP memory and can now be used by other Python macros.
To see this in action, go back to the “cal_vth” macro, click the “Execute” button, and see the Vth value printed in IC-CAP’s Status window.

2. Refer to a Python Class defined outside of ICCAP
If we have existing Python files that have utility functions or Python classes defined, we can certainly use them directly without re-creating them again in ICCAP.
This approach requires we set an OS environment variable called ICCAP_USER_PYTHON_PATH to the directory where those python files are located, as shown below:

Python source code files are then stored in the directory specified:

If files were newly added to that directory, you will need to restart IC-CAP, load the nmos3.mdl again and go back to the Macros tab to access these programs. To test this, add another new Macro, name it ‘cal_vth_use_external’, and again set the Type to be Python (Local Namespace).

We now can import the class or functions from the external files by adding the 2 lines highlighted below to the top of the macro. The remainder of code is the same

as for the cal_vth function we saw above.

from iccap_vth import VthCon

from iccap_util import *