Foreign Function Interface for Cadence SKILL
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


With the Foreign Function Interface (FFI) for SKILL C-Type Libraries can be loaded and used within the SKILL environment.

State of Development

This is not a finished product and still very early in development.

For now the only data type supported is float other data types as well as defining custom structs is still in development.


Build Utils:

  • GCC version 4.8.5
  • GNU Make version 3.82


  • ffi.h
  • dlfcn.h

Getting Started


Make sure the latest version of GNU Make and GCC are installed and build the project with

$ make ffi

This should result in an executable named skillFFI.

Example Usage

Start by loading in the CIW:

(load "")

This should print a confirmation

FFI up and running

To load a shared library either the complete and absolute path must be provided or it has to be located in the LD_LIBRARY_PATH environment variable.

Loading the C math library is accomplished like so:

(setq libm (ffiOpenLib "")

ffiOpenLib loads the library and returns a memory address as handle, which in this example will be stored in the variable libm. Since there is no access to header files in SKILL the function prototype must be defined manually.

(setq sqrtf (ffiDefun libm "sqrtf" "float" (list "float")))

If successful ffiDefun returns a handle to the prototyped function, which can be called with ffiCallFun.

(setq res (ffiCallfun fnSqrt (list 144.0)))

Function Reference


(ffiOpenLib libName) => libHandle

Opens a shared library and returns a handle to it. libName can either be the entire absolute path to a library or just its name if the path is in the LD_LIBRARY_PATH environment variable.

  • libName is a string with the entire absolute path to the library.


(ffiDefun libHandle fnName rType aTypes) => fnHandle

Defines the prototype for a C function and returns a handle to it if succesful. The libHandle is a handle returned by ffiOpenLib. The name of the function has to be known in advance and passed as fnName. The return type of the function is the string rType. aTypes is a string list with the types of arguments.

  • libHandle is a string containing a handle to an open shared library.
  • The name of the function is a string in fnName.
  • rType is the return type of the function as a string.
  • aTypes is a string list containing the types of the function arguments.


(ffiCallfun fnHandle fnArgs) => result

Calls a previously defined function with the given arguemnts in fnArgs and returns whatever this function call retured.

  • fnHandle is a string containing a function handle obtained by ffiDefun.
  • fnArgs is a list of arguments corresponding to the correct types given in the definition.


ffiCloseLib libHandle)

Closes the library.