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-2.5.1.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-2.5.1-py3-none-any.whl (15.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyquesta-2.5.1.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.7.6

File hashes

Hashes for pyquesta-2.5.1.tar.gz
Algorithm Hash digest
SHA256 897c21b817eb7f66db146854a4533829c9c1cb54a4a0d4da44b6d29ed7173182
MD5 41e4e2361fbfc7e69ee03cf3c4f042ab
BLAKE2b-256 c3a1cb720a3b1462cd974e1f9265b91a8fe710427da01847445dc0a170f17996

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pyquesta-2.5.1-py3-none-any.whl
  • Upload date:
  • Size: 15.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.7.6

File hashes

Hashes for pyquesta-2.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 77b2ff8ad89082a9a5a219c25d68e7bb09d921820c5e8c7e4caa1ddbcd78f4dc
MD5 d447007a05fdd3281b60edc80399e781
BLAKE2b-256 76346b4a5bbc67a7f5c6cd7fd8279d09cf9b3099ab8a66d7483080d4bbc23c17

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