SWIG/Python bindings for the Unified Coverage Interoperability Standard (UCIS) API from Accellera.
Requires a recent version of SWIG (http://www.swig.org/) [ tested with SWIG v3.0.5 ]
Modify the Makefile to point to your EDA tool release of the UCIS API and associated implementation.
UCIS_INCLUDE_PATH should point to the location of the ucis.h and UCIS_LIB_PATH should point to the associated libucis.so file.
The tests run at the end of make all will not completely pass. In fact one of them will fail (increment cover). So you will see a score of 22 tests run and 20 passed. That is OK. With Python 3 the pass rate will decrease to 16.
Your LD_LIBRARY_PATH environment variable needs to point to at least the UCIS_LIB_PATH to access the libucis.so and the location of the resulting _ucis.so from running make for PyUCIS. You'll also need to have the ucis.py, pyucis.py files in your PYTHONPATH. Then run python and
# access methods through namespace, e.g. pyucis.ucis_Open() import pyucis
# access methods directly, e.g. ucis_Open() from pyucis import *
All features of the UCIS API then have the same names as defined there.
from ucis import * import sys db = ucis_Open('sink.ucdb') si = ucis_ScopeIterate(db, None, sys.maxint) sh = ucis_ScopeScan(db, si) print ucis_GetStringProperty( db, sh, 0, UCIS_STR_INSTANCE_DU_NAME)
Pythonic UCIS extensions
There are also wrappers around many of the API calls, to provide a more Pythonic interface. E.g., iterators for scope, history etc are defined, so you don't need to use ucis_xxxxIterate/ ucis_xxxxScan/ ucis_FreeIterator set of functions. Use the equivalent pyucis_xxxx_itr call, as shown below, which will set up the iterator, build a generator that will call Scan and also clean up the iterator at the end of use. The various Scan arguments are supported, such as initial scope and MaskType. See the pydoc documentation for more details.
from pyucis import * with PyUCISDB('sink.ucdb') as db: for sh in pyucis_scope_itr(db): print sh.GetStringProperty(property=UCIS_STR_SCOPE_HIER_NAME)
Another group of functions add the ability to figure out the raw hit count of either bins, cover items, whole groups or even assertions or cover statements. With that functionality one could implement sanity or plausibility checks for a certain coverage model. E.g.
from pyucis import * with PyUCISDB('sink.ucdb') as db: if (pyucis_get_count(db, "/top/assert_prop") == 0): print("ERROR: ... !")
Run cov_checker.py for an example.
- Callbacks to API methods from Python don't currently work.
- Some constants such as INT64_NEG1 cannot be used in API places where uint64_t are used in the UCIS standard.
- Pythonic wrappers not all implemented (some iterators not tested)
Copyright 2013 Gordon McGregor (email@example.com) Copyright 2015 Andre Winkelmann (firstname.lastname@example.org) Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.