Skip to main content

A link between Questa and Python

Project description

License

© 2022 Siemens.

This material may only be used with products of Siemens Industry Software Inc. or its affiliates, and for no other purpose.

License continued below

pyquesta module

*pyquesta provides resources for Python programmers using Questa. The first resource released is SVconduit

SVConduit

The SystemVerilog Conduit system with the SVConduit module allows a Python testbench writer to exchange an object with SystemVerilog. This allows the Python programmer to leverage Questa's advanced constraint-solver, and functional coverage and the UCDB.

SVconduit introduction

The first step to using SVConduit is to define a class using YAML. The system will generated modules that define a Python version of the class and a SystemVerilog version of the class.

Define the communication class

For example, here is a transction class (ALUCommand) that sends instructions to the TinyALU, which has two 8-bit legs and four operations.

ALUCommand:
  A:
   uchar
  B:
   uchar
  op:
   uchar

The gen_svconduit_pkgs program reads this YAML file and generates a Python module and SystemVerilog package that define the class in those languages along with the serialization methods to pass it between Python and SystemVerilog.

Commuinate with SystemVerilog from Python

This snippet of test code creates a cmd using the SystemVerilog constraint-solver and writes the command into a SystemVerilog covergroup:

from pyquesta import SVConduit
from ALUCommand import *

<snip>
    for _ in range(2):
        cmd = SVConduit.get(ALUCommand)  # get random command
        SVConduit.put(cmd)  # put in coverage
<snip>

SVConduit.get() class method knows where to get the object based on the ALUCommand class passed to it. The SVConduit.put() class method knows where to send the object based on its type.

Populate the SystemVerilog functions

The ALUCommand.sv file defines a package named ALUCommand. This package defines sv_put() and sv_get() which define the SystemVerilog behavior associated with ALUCommand objects.

The sv_get() function uses the constraint solver to randomize an ALUCommand object and return it to Python:

function string sv_get();
    ALUCommand obj;
    string obj_str;
    obj = new();
    // Insert user to populate obj
    void'(obj.randomize() with {op inside {[1:4]};});
    // User code ends. You must have populated obj
    obj_str = obj.serialize();
    return obj_str;
endfunction

The sv_put() function gets a handle to a singleton containing a covergroup and samples the command:

function void sv_put(ALUCommand_buf_t byte_buf);
    ALUCommand obj;
    obj = new(byte_buf);
    // Replace with user code for put function
    cov = Coverer::get();
    cov.A = obj.A;
    cov.B = obj.B;
    cov.op = obj.op;
    cov.op_cov.sample();
    // User code ends. You have used data from obj
endfunction

Now the Python code can get objects and send objects to the SystemVerilog package.

Learn more about SVConduit

You can get a copy of the example used in this README.md file as well as read a tutorial and documentation about SVConduit at the Verification Academy.

Full license

© 2022 Siemens.

This material may only be used with products of Siemens Industry Software Inc. or its affiliates, and for no other purpose.

If you have a signed license agreement with Siemens for the product with which this Software will be used, your use of this Software is subject to the scope of license and the software protection and security provisions of that agreement. If you do not have such a signed license agreement, your use is subject to the Siemens Universal Customer Agreement, which may be viewed at https://www.sw.siemens.com/en-US/sw-terms/base/uca/, as supplemented by the electronic design automation (EDA) specific terms which may be viewed at https://www.sw.siemens.com/en-US/sw-terms/supplements/.

NOTWITHSTANDING ANYTHING TO THE CONTRARY IN YOUR SIGNED LICENSE AGREMENT WITH SISW OR THE SISW END USER LICENSE AGREEMENT, THIS SOFTWARE IS BEING PROVIDED “AS IS;” SISW MAKES NO WARRANTY OF ANY KIND WITH REGARD TO THIS SOFTWARE INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT OF INTELLECTUAL PROPERTY. SISW SHALL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL OR PUNITIVE DAMAGES, LOST DATA OR PROFITS, EVEN IF SUCH DAMAGES WERE FORESEEABLE, ARISING OUT OF OR RELATED TO THIS SOFTWARE OR THE INFORMATION CONTAINED IN IT, EVEN IF SISW HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

Unless agreed in writing, SISW has no obligation to support or otherwise maintain this Software.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyquesta-1.0.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyquesta-1.0-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file pyquesta-1.0.tar.gz.

File metadata

  • Download URL: pyquesta-1.0.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.2.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.6

File hashes

Hashes for pyquesta-1.0.tar.gz
Algorithm Hash digest
SHA256 ce9eb53cf872755f089790223517c036525ce67ae64c74f02592eda3e7dac5fd
MD5 b91100b26b219700432e6711a65c6fb6
BLAKE2b-256 68799165224904b9b264355abdf431c95f5defcbe8672ae3da2f587851f35a6d

See more details on using hashes here.

File details

Details for the file pyquesta-1.0-py3-none-any.whl.

File metadata

  • Download URL: pyquesta-1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.2.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.7.6

File hashes

Hashes for pyquesta-1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 32fe98b2b8a857e94f863c0abb7f0357385c785c2db626991d9b776b93c43f35
MD5 da66336af230d011c424809bc327ffbe
BLAKE2b-256 90a43be874f90535dc4d798798f645652f54f2c8317f233a14ba48406ecd1a30

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page