SystemVerilog API

The SystemVerilog API provides two levels of Python API access:

  • Direct access to the Python C API

  • An abstracted class-based convenience API

Class-Based API

class py_object

Convenience wrapper class for PyObject handles

Subclassed by py_dict, py_list, py_tuple

Public Functions

virtual void dispose()

Drops ownership of handle

virtual py_object get_attr(string name)

Returns the named Python attribute as a py_object

virtual py_object call(py_tuple args = null, py_object kwargs = null)

Calls the object as a Python callable

py_iter iter()

Creates an iterator for the given object

virtual py_object call_attr(string name, py_tuple args = null, py_object kwargs = null)

Calls a named attribute of the object as a method

virtual int to_int()

Obtains the integer value of this object and releases ownership

virtual longint to_long()

Obtains the long-int value of this object and releases ownership

virtual void to_void()

Disposes of the object

virtual string to_str()

Obtains the string value of the object and disposes of the object

int as_int()

Obtains the integer value of the object

longint as_long()

Obtains the long-int value of the object

virtual string as_str()

Obtains the string value of the object

class py_dict : public py_object

Public Functions

py_list keys()

Obtains a list of keys

Public Static Functions

static py_dict mk(py_object obj)

Constructs a py_dict wrapper around an existing object

class py_list : public py_object

Public Functions

int size()

Returns the number of elements in the list

py_object get_item(int idx)

Gets the item at the specified list index

void append(py_object obj)

Appends a new element to the list

Public Static Functions

static py_list mk(py_object obj)

Creates a new list object that wraps an existing object

static py_list mk_init(py_object objs[])

Creates a new list object from an initial list of items

class py_tuple : public py_object

Public Functions

void set_item(int idx, py_object obj)

Sets the specified tuple element

py_object get_item(int idx)

Gets the specified tuple element

Public Static Functions

static py_tuple mk(py_object obj)

Creates a new tuple by wrapping an existing object

static py_tuple mk_new_sz(int sz)

Creates a new empty tuple of the specified size

static py_tuple mk_init(py_object elems[])

Creates a new tuple from the specified elements

Utility Methods

py_object py_from_int(int val)

Create a Python integer-value object

py_object py_from_uint(int unsigned val)

Create a Python unsigned integer-value object

py_object py_from_long(longint val)

Create a Python longint-value object

py_object py_from_ulong(unsigned long long val)

Create a Python unsigned longint-value object

py_object py_from_str(string str)

Create a Python string object

py_object py_import(string mod)

Import a module

py_object py_call_builtin(string name, py_tuple args, py_dict kwargs = null)

Call a built-in function

void py_gil_enter()

Acquire the GIL

void py_gil_leave()

Release the GIL

Direct API