PyVerilator


NamePyVerilator JSON
Version 0.7.0 PyPI version JSON
download
home_pagehttps://github.com/csail-csg/pyverilator
SummaryPython interface to Verilator models
upload_time2021-05-20 18:27:29
maintainer
docs_urlNone
authorCSAIL CSG
requires_python
license
keywords verilator wrapper verilog
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            PyVerilator
===========

This package provides a wrapper to generate and use verilator
hardware models in python.


Installing Non-Development Version
----------------------------------

If you want to just install the `pyverilator` package, you should be able to
using the following command:


    $ pip3 install pyverilator


Usage
-----

Assume you have the following verilog module stored in ``counter.v``.

.. code:: verilog

    module counter (
            input        clk,
            input        rst,
            input        en,
            output [7:0] out
        );
        reg [7:0] count_reg;
        wire [7:0] next_count_reg;
        assign next_count_reg = (en == 1) ? count_reg + 1 : count_reg;
        assign out = next_count_reg;
        always @(posedge clk) begin
            if (rst == 1) count_reg <= 0;
            else          count_reg <= next_count_reg;
        end
    endmodule'''

Then you can use ``pyverilator`` to simulate this module using verilator in
python.

.. code:: python

    sim = pyverilator.PyVerilator.build('counter.v')

    # start gtkwave to view the waveforms as they are made
    sim.start_gtkwave()

    # add all the io and internal signals to gtkwave
    sim.send_signals_to_gtkwave(sim.io)
    sim.send_signals_to_gtkwave(sim.internals)

    # add all the io and internal signals to gtkwave
    sim.send_to_gtkwave(sim.io)
    sim.send_to_gtkwave(sim.internals)

    # tick the automatically detected clock
    sim.clock.tick()

    # set rst back to 0
    sim.io.rst = 0

    # check out when en = 0
    sim.io.en = 0
    curr_out = sim.io.out
    # sim.io is a pyverilator.Collection, accessing signals by attribute or
    # dictionary syntax returns a SignalValue object which inherits from int.
    # sim.io.out can be used just like an int in most cases, and it has extra
    # features like being able to add it to gtkwave with
    # sim.io.out.send_to_gtkwave(). To just get the int value, you can call
    # sim.io.out.value
    print('sim.io.out = ' + str(curr_out))

    # check out when en = 1
    sim.io.en = 1
    curr_out = sim.io.out
    print('sim.io.out = ' + str(curr_out))

    sim.clock.tick()

    # check out after ticking clock
    curr_out = sim.io.out
    print('sim.io.out = ' + str(curr_out))

The full code for this and other examples can be found in the examples folder
of the git repository.

Installing for Development
--------------------------

To install this package for development, you should use a virtual environment,
and install the package in editable mode using pip.

To create a virtual environment for this project, run the command below.

    $ python3 -m venv path/to/new-venv-folder

To start using your new virtual environment, run the command below.
This needs to be run each time you open a new terminal.

    $ source path/to/new-venv-folder/bin/activate

At this point you are now using your new virtual environment.
Python packages you install in this environment will not be available outside
your virtual environment.
If you want to stop using the virtual environment, just run ``deactivate``.

To install the ``pyverilator`` package in editable mode, inside the
``pyverilator`` top git repository folder, run the command below.

    $ pip3 install -e .



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/csail-csg/pyverilator",
    "name": "PyVerilator",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "Verilator Wrapper Verilog",
    "author": "CSAIL CSG",
    "author_email": "acwright@mit.edu, bthom@mit.edu",
    "download_url": "https://files.pythonhosted.org/packages/9b/02/68f33790a73a3a16beb329f916a4e5f62a7379e2542fc1b2cd8c67e910e8/PyVerilator-0.7.0.tar.gz",
    "platform": "",
    "description": "PyVerilator\n===========\n\nThis package provides a wrapper to generate and use verilator\nhardware models in python.\n\n\nInstalling Non-Development Version\n----------------------------------\n\nIf you want to just install the `pyverilator` package, you should be able to\nusing the following command:\n\n\n    $ pip3 install pyverilator\n\n\nUsage\n-----\n\nAssume you have the following verilog module stored in ``counter.v``.\n\n.. code:: verilog\n\n    module counter (\n            input        clk,\n            input        rst,\n            input        en,\n            output [7:0] out\n        );\n        reg [7:0] count_reg;\n        wire [7:0] next_count_reg;\n        assign next_count_reg = (en == 1) ? count_reg + 1 : count_reg;\n        assign out = next_count_reg;\n        always @(posedge clk) begin\n            if (rst == 1) count_reg <= 0;\n            else          count_reg <= next_count_reg;\n        end\n    endmodule'''\n\nThen you can use ``pyverilator`` to simulate this module using verilator in\npython.\n\n.. code:: python\n\n    sim = pyverilator.PyVerilator.build('counter.v')\n\n    # start gtkwave to view the waveforms as they are made\n    sim.start_gtkwave()\n\n    # add all the io and internal signals to gtkwave\n    sim.send_signals_to_gtkwave(sim.io)\n    sim.send_signals_to_gtkwave(sim.internals)\n\n    # add all the io and internal signals to gtkwave\n    sim.send_to_gtkwave(sim.io)\n    sim.send_to_gtkwave(sim.internals)\n\n    # tick the automatically detected clock\n    sim.clock.tick()\n\n    # set rst back to 0\n    sim.io.rst = 0\n\n    # check out when en = 0\n    sim.io.en = 0\n    curr_out = sim.io.out\n    # sim.io is a pyverilator.Collection, accessing signals by attribute or\n    # dictionary syntax returns a SignalValue object which inherits from int.\n    # sim.io.out can be used just like an int in most cases, and it has extra\n    # features like being able to add it to gtkwave with\n    # sim.io.out.send_to_gtkwave(). To just get the int value, you can call\n    # sim.io.out.value\n    print('sim.io.out = ' + str(curr_out))\n\n    # check out when en = 1\n    sim.io.en = 1\n    curr_out = sim.io.out\n    print('sim.io.out = ' + str(curr_out))\n\n    sim.clock.tick()\n\n    # check out after ticking clock\n    curr_out = sim.io.out\n    print('sim.io.out = ' + str(curr_out))\n\nThe full code for this and other examples can be found in the examples folder\nof the git repository.\n\nInstalling for Development\n--------------------------\n\nTo install this package for development, you should use a virtual environment,\nand install the package in editable mode using pip.\n\nTo create a virtual environment for this project, run the command below.\n\n    $ python3 -m venv path/to/new-venv-folder\n\nTo start using your new virtual environment, run the command below.\nThis needs to be run each time you open a new terminal.\n\n    $ source path/to/new-venv-folder/bin/activate\n\nAt this point you are now using your new virtual environment.\nPython packages you install in this environment will not be available outside\nyour virtual environment.\nIf you want to stop using the virtual environment, just run ``deactivate``.\n\nTo install the ``pyverilator`` package in editable mode, inside the\n``pyverilator`` top git repository folder, run the command below.\n\n    $ pip3 install -e .\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Python interface to Verilator models",
    "version": "0.7.0",
    "split_keywords": [
        "verilator",
        "wrapper",
        "verilog"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "dd1cbdfd0bdf0d0630d5bc1d00f770fd",
                "sha256": "dc150aa9e31fa4a1534dbc58fd37718c5e7eedb11d81742a6eea99a2c3beea01"
            },
            "downloads": -1,
            "filename": "PyVerilator-0.7.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "dd1cbdfd0bdf0d0630d5bc1d00f770fd",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 14999,
            "upload_time": "2021-05-20T18:27:27",
            "upload_time_iso_8601": "2021-05-20T18:27:27.425850Z",
            "url": "https://files.pythonhosted.org/packages/c0/e3/bb797b52e233f2ea1c56fbef9119dad56dd857ca6d5f6a331b83e88513e1/PyVerilator-0.7.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "md5": "6cfa258f4f8a1ce933dc56fd9b98a2f4",
                "sha256": "66168ba0151e1a31825a237ed296d2457e9e38e313a23f51c0d4f19b1fefe59c"
            },
            "downloads": -1,
            "filename": "PyVerilator-0.7.0.tar.gz",
            "has_sig": false,
            "md5_digest": "6cfa258f4f8a1ce933dc56fd9b98a2f4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 14101,
            "upload_time": "2021-05-20T18:27:29",
            "upload_time_iso_8601": "2021-05-20T18:27:29.027830Z",
            "url": "https://files.pythonhosted.org/packages/9b/02/68f33790a73a3a16beb329f916a4e5f62a7379e2542fc1b2cd8c67e910e8/PyVerilator-0.7.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-05-20 18:27:29",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "csail-csg",
    "github_project": "pyverilator",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pyverilator"
}
        
Elapsed time: 0.01980s