cocotbext-ryusim 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,82 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+ schedule:
7
+ - cron: "0 3 * * 1" # weekly, Mondays 03:00 UTC: catches new RyuSim releases
8
+ workflow_dispatch:
9
+
10
+ jobs:
11
+ smoke:
12
+ name: smoke (py${{ matrix.python }}, ${{ matrix.cocotb }})
13
+ runs-on: ubuntu-24.04
14
+ strategy:
15
+ fail-fast: false
16
+ matrix:
17
+ python: ["3.9", "3.13"]
18
+ cocotb: ["cocotb==2.1.0", "cocotb>=2.1,<2.2"] # cap floor, newest under cap
19
+ steps:
20
+ - uses: actions/checkout@v4
21
+ - uses: actions/setup-python@v5
22
+ with:
23
+ python-version: ${{ matrix.python }}
24
+ - name: Install toolchain, Icarus and RyuSim
25
+ run: |
26
+ sudo apt-get update
27
+ sudo apt-get install -y --no-install-recommends clang cmake iverilog
28
+ curl -fsSL https://ryusim.seiraiyu.com/install.sh | bash
29
+ echo "$HOME/.ryusim/bin" >> "$GITHUB_PATH"
30
+ - name: Install package
31
+ run: |
32
+ python -m pip install --upgrade pip
33
+ pip install "${{ matrix.cocotb }}" -e ".[test]"
34
+ - name: Versions
35
+ run: |
36
+ ryusim --version
37
+ python -c "import cocotb; print('cocotb', cocotb.__version__)"
38
+ - run: pytest -v
39
+
40
+ conformance:
41
+ # cocotb's full Verilog regression through this package (§7.2). It takes
42
+ # about 10 minutes, so it runs on main and weekly, not on every PR.
43
+ if: github.ref == 'refs/heads/main'
44
+ runs-on: ubuntu-24.04
45
+ steps:
46
+ - uses: actions/checkout@v4
47
+ - uses: actions/setup-python@v5
48
+ with:
49
+ python-version: "3.12"
50
+ - name: Install toolchain and RyuSim
51
+ run: |
52
+ sudo apt-get update
53
+ sudo apt-get install -y --no-install-recommends clang cmake
54
+ curl -fsSL https://ryusim.seiraiyu.com/install.sh | bash
55
+ echo "$HOME/.ryusim/bin" >> "$GITHUB_PATH"
56
+ - name: Install cocotb and this package
57
+ run: pip install "cocotb>=2.1,<2.2" .
58
+ - name: Check out cocotb's test suite at the installed version
59
+ run: |
60
+ V=$(python -c "import cocotb; print(cocotb.__version__)")
61
+ git clone --depth 1 --branch "v$V" https://github.com/cocotb/cocotb.git cocotb-src
62
+ - name: Install cocotb's test dependencies (psutil, pexpect, ...)
63
+ run: |
64
+ python -m pip install --upgrade pip # --group needs pip >= 25.1
65
+ pip install --group cocotb-src/pyproject.toml:test_common
66
+ - name: Make RyuSim visible to cocotb's stock test Makefiles
67
+ # CI-only: users never do this (§5.1). cocotb's test Makefiles use the
68
+ # stock include, which only searches cocotb's own install dir.
69
+ run: |
70
+ cp "$(cocotbext-ryusim-config --makefiles)/simulators/Makefile.ryusim" \
71
+ "$(cocotb-config --makefiles)/simulators/"
72
+ - name: Run cocotb's Verilog regression
73
+ working-directory: cocotb-src
74
+ env:
75
+ SIM: ryusim
76
+ TOPLEVEL_LANG: verilog
77
+ # Stock Makefile.inc doesn't know ryusim; our shim sets this for users.
78
+ COCOTB_TRUST_INERTIAL_WRITES: "1"
79
+ # cocotb's test_ci.test_python_version runs under GITHUB_ACTIONS and
80
+ # expects its CI to export this; keep in step with setup-python above.
81
+ PYTHON_VERSION: "3.12"
82
+ run: make -k test
@@ -0,0 +1,82 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags: ["v*"]
6
+
7
+ jobs:
8
+ build:
9
+ runs-on: ubuntu-24.04
10
+ steps:
11
+ - uses: actions/checkout@v4
12
+ - uses: actions/setup-python@v5
13
+ with:
14
+ python-version: "3.12"
15
+ - name: Tag matches package version
16
+ run: |
17
+ V=$(python -c "import tomllib; print(tomllib.load(open('pyproject.toml','rb'))['project']['version'])")
18
+ test "v$V" = "${GITHUB_REF_NAME}" || { echo "tag ${GITHUB_REF_NAME} != v$V"; exit 1; }
19
+ - run: pip install build && python -m build
20
+ - uses: actions/upload-artifact@v4
21
+ with:
22
+ name: dist
23
+ path: dist/
24
+
25
+ testpypi:
26
+ needs: build
27
+ runs-on: ubuntu-24.04
28
+ environment: testpypi
29
+ permissions:
30
+ id-token: write
31
+ steps:
32
+ - uses: actions/download-artifact@v4
33
+ with:
34
+ name: dist
35
+ path: dist/
36
+ - uses: pypa/gh-action-pypi-publish@release/v1
37
+ with:
38
+ repository-url: https://test.pypi.org/legacy/
39
+
40
+ verify:
41
+ needs: testpypi
42
+ runs-on: ubuntu-24.04
43
+ steps:
44
+ - uses: actions/checkout@v4
45
+ - uses: actions/setup-python@v5
46
+ with:
47
+ python-version: "3.12"
48
+ - name: Install toolchain, Icarus and RyuSim
49
+ run: |
50
+ sudo apt-get update
51
+ sudo apt-get install -y --no-install-recommends clang cmake iverilog
52
+ curl -fsSL https://ryusim.seiraiyu.com/install.sh | bash
53
+ echo "$HOME/.ryusim/bin" >> "$GITHUB_PATH"
54
+ - name: Install the published artifact from TestPyPI
55
+ # Dependencies come from real PyPI first. Only this package is fetched
56
+ # from TestPyPI, with --no-deps: anyone can upload to TestPyPI, and
57
+ # mixing the indexes would let a planted "cocotb" there win on version.
58
+ run: |
59
+ V=${GITHUB_REF_NAME#v}
60
+ pip install "cocotb>=2.1,<2.2" pytest
61
+ for i in 1 2 3 4 5 6; do
62
+ pip install --no-deps --index-url https://test.pypi.org/simple/ \
63
+ "cocotbext-ryusim==$V" && break
64
+ sleep 20 # TestPyPI's index can lag the upload
65
+ done
66
+ python -c "import cocotbext.ryusim"
67
+ - name: Smoke tests against the installed artifact
68
+ # Remove the source tree so tests import the installed wheel, not ./src.
69
+ run: rm -rf src && pytest -v tests
70
+
71
+ pypi:
72
+ needs: verify
73
+ runs-on: ubuntu-24.04
74
+ environment: pypi
75
+ permissions:
76
+ id-token: write
77
+ steps:
78
+ - uses: actions/download-artifact@v4
79
+ with:
80
+ name: dist
81
+ path: dist/
82
+ - uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,9 @@
1
+ .venv/
2
+ __pycache__/
3
+ *.egg-info/
4
+ dist/
5
+ build/
6
+ sim_build/
7
+ results.xml
8
+ *.vcd
9
+ .pytest_cache/
@@ -0,0 +1,30 @@
1
+ Copyright cocotb contributors
2
+ Copyright (c) 2013 Potential Ventures Ltd
3
+ Copyright (c) 2013 SolarFlare Communications Inc
4
+ Copyright (c) 2026 Seiraiyu
5
+ All rights reserved.
6
+
7
+ Redistribution and use in source and binary forms, with or without
8
+ modification, are permitted provided that the following conditions are met:
9
+
10
+ 1. Redistributions of source code must retain the above copyright notice, this
11
+ list of conditions and the following disclaimer.
12
+
13
+ 2. Redistributions in binary form must reproduce the above copyright notice,
14
+ this list of conditions and the following disclaimer in the documentation
15
+ and/or other materials provided with the distribution.
16
+
17
+ 3. Neither the name of the copyright holder nor the names of its
18
+ contributors may be used to endorse or promote products derived from
19
+ this software without specific prior written permission.
20
+
21
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,122 @@
1
+ Metadata-Version: 2.5
2
+ Name: cocotbext-ryusim
3
+ Version: 0.1.0
4
+ Summary: RyuSim simulator support for cocotb
5
+ Project-URL: Homepage, https://github.com/Seiraiyu/cocotbext-ryusim
6
+ Project-URL: Issues, https://github.com/Seiraiyu/cocotbext-ryusim/issues
7
+ Author: Seiraiyu
8
+ License-Expression: BSD-3-Clause
9
+ License-File: LICENSE
10
+ Classifier: Framework :: cocotb
11
+ Classifier: Operating System :: POSIX :: Linux
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Topic :: Scientific/Engineering :: Electronic Design Automation (EDA)
14
+ Requires-Python: >=3.9
15
+ Requires-Dist: cocotb<2.2,>=2.1
16
+ Provides-Extra: test
17
+ Requires-Dist: pytest>=8; extra == 'test'
18
+ Description-Content-Type: text/markdown
19
+
20
+ # cocotbext-ryusim
21
+
22
+ [RyuSim](https://ryusim.com) simulator support for [cocotb](https://www.cocotb.org).
23
+
24
+ Adds `SIM=ryusim` to all three cocotb flows (Makefile, Python Runner and pytest)
25
+ on stock, released cocotb. Pure Python: no fork of cocotb, no C++ toolchain, no
26
+ compiled extension.
27
+
28
+ ## Requirements
29
+
30
+ - cocotb **2.1.x**
31
+ - Python 3.9+
32
+ - Linux
33
+ - RyuSim on `PATH`: `curl -fsSL https://ryusim.com/install.sh | bash`
34
+
35
+ ## Install
36
+
37
+ ```bash
38
+ pip install cocotbext-ryusim
39
+ ```
40
+
41
+ This installs a compatible cocotb alongside it.
42
+
43
+ ## Makefile flow
44
+
45
+ Change one line in your testbench Makefile:
46
+
47
+ ```make
48
+ # before
49
+ include $(shell cocotb-config --makefiles)/Makefile.sim
50
+ # after
51
+ include $(shell cocotbext-ryusim-config --makefiles)/Makefile.sim
52
+ ```
53
+
54
+ Then run `make SIM=ryusim`. Any other `SIM` value is passed to cocotb's own
55
+ `Makefile.sim` unchanged, so the same Makefile still runs Icarus, Verilator and
56
+ the other simulators.
57
+
58
+ Standard cocotb variables work as usual (`COCOTB_TOPLEVEL`, `VERILOG_SOURCES`,
59
+ `COCOTB_HDL_TIMEUNIT`, `WAVES=1` and so on). Set `RYUSIM_BIN_DIR` to use a
60
+ `ryusim` that isn't on `PATH`. `make help` isn't available for `SIM=ryusim`.
61
+
62
+ ## Python Runner
63
+
64
+ ```python
65
+ import cocotbext.ryusim # registers "ryusim"
66
+ from cocotb_tools.runner import get_runner
67
+
68
+ runner = get_runner("ryusim")
69
+ runner.build(sources=["dut.sv"], hdl_toplevel="dut", timescale=("1ns", "1ps"))
70
+ runner.test(hdl_toplevel="dut", test_module="test_dut")
71
+ ```
72
+
73
+ You can also construct `cocotbext.ryusim.RyuSim()` directly. `hdl_toplevel` is
74
+ required, and `pre_cmd` is not supported.
75
+
76
+ ## pytest
77
+
78
+ The plugin loads automatically once the package is installed. Select RyuSim
79
+ explicitly:
80
+
81
+ ```bash
82
+ pytest -p cocotb_tools._pytest.plugin --cocotb-simulator ryusim
83
+ ```
84
+
85
+ With `--cocotb-simulator auto`, cocotb picks the first supported simulator it
86
+ finds on `PATH`, and RyuSim comes last in that order. Pass `ryusim` explicitly
87
+ if other simulators are also installed.
88
+
89
+ ## What RyuSim supports
90
+
91
+ Verilog and SystemVerilog through VPI. There is no VHDL support.
92
+
93
+ These parts of IEEE 1800-2023 are not implemented: switch-level modelling
94
+ (clause 28; gate-level support covers the basic gate primitives only),
95
+ user-defined primitives (29), `specify` blocks (30), timing checks (31), SDF
96
+ back-annotation (32), design configurations (33), and the VPI assertion,
97
+ coverage-control and data-read APIs (39–41).
98
+
99
+ RyuSim rejects anything it doesn't implement at compile time, so an unsupported
100
+ construct is always a compile error rather than a silent mis-simulation.
101
+
102
+ Inertial writes are trusted by default (`COCOTB_TRUST_INERTIAL_WRITES=1`), as
103
+ cocotb does for Verilator, GHDL and NVC.
104
+
105
+ ## How it works
106
+
107
+ RyuSim's VPI callback behavior matches Verilator's, so this package loads
108
+ cocotb's own `libcocotbvpi_verilator.so`. It adds `ryusim` to cocotb's runner and
109
+ pytest registries, and ships the RyuSim makefile. It never modifies cocotb's
110
+ installed files.
111
+
112
+ ## cocotb compatibility
113
+
114
+ This package relies on some cocotb internals, so it pins `cocotb>=2.1,<2.2`. A
115
+ new cocotb minor release gets a new cocotbext-ryusim release once CI passes
116
+ against it. Until then, pip keeps a compatible cocotb rather than breaking at
117
+ runtime. CI runs cocotb's full Verilog regression through this package.
118
+
119
+ ## License
120
+
121
+ BSD-3-Clause. Portions are derived from cocotb, © cocotb contributors; see
122
+ [LICENSE](LICENSE).
@@ -0,0 +1,103 @@
1
+ # cocotbext-ryusim
2
+
3
+ [RyuSim](https://ryusim.com) simulator support for [cocotb](https://www.cocotb.org).
4
+
5
+ Adds `SIM=ryusim` to all three cocotb flows (Makefile, Python Runner and pytest)
6
+ on stock, released cocotb. Pure Python: no fork of cocotb, no C++ toolchain, no
7
+ compiled extension.
8
+
9
+ ## Requirements
10
+
11
+ - cocotb **2.1.x**
12
+ - Python 3.9+
13
+ - Linux
14
+ - RyuSim on `PATH`: `curl -fsSL https://ryusim.com/install.sh | bash`
15
+
16
+ ## Install
17
+
18
+ ```bash
19
+ pip install cocotbext-ryusim
20
+ ```
21
+
22
+ This installs a compatible cocotb alongside it.
23
+
24
+ ## Makefile flow
25
+
26
+ Change one line in your testbench Makefile:
27
+
28
+ ```make
29
+ # before
30
+ include $(shell cocotb-config --makefiles)/Makefile.sim
31
+ # after
32
+ include $(shell cocotbext-ryusim-config --makefiles)/Makefile.sim
33
+ ```
34
+
35
+ Then run `make SIM=ryusim`. Any other `SIM` value is passed to cocotb's own
36
+ `Makefile.sim` unchanged, so the same Makefile still runs Icarus, Verilator and
37
+ the other simulators.
38
+
39
+ Standard cocotb variables work as usual (`COCOTB_TOPLEVEL`, `VERILOG_SOURCES`,
40
+ `COCOTB_HDL_TIMEUNIT`, `WAVES=1` and so on). Set `RYUSIM_BIN_DIR` to use a
41
+ `ryusim` that isn't on `PATH`. `make help` isn't available for `SIM=ryusim`.
42
+
43
+ ## Python Runner
44
+
45
+ ```python
46
+ import cocotbext.ryusim # registers "ryusim"
47
+ from cocotb_tools.runner import get_runner
48
+
49
+ runner = get_runner("ryusim")
50
+ runner.build(sources=["dut.sv"], hdl_toplevel="dut", timescale=("1ns", "1ps"))
51
+ runner.test(hdl_toplevel="dut", test_module="test_dut")
52
+ ```
53
+
54
+ You can also construct `cocotbext.ryusim.RyuSim()` directly. `hdl_toplevel` is
55
+ required, and `pre_cmd` is not supported.
56
+
57
+ ## pytest
58
+
59
+ The plugin loads automatically once the package is installed. Select RyuSim
60
+ explicitly:
61
+
62
+ ```bash
63
+ pytest -p cocotb_tools._pytest.plugin --cocotb-simulator ryusim
64
+ ```
65
+
66
+ With `--cocotb-simulator auto`, cocotb picks the first supported simulator it
67
+ finds on `PATH`, and RyuSim comes last in that order. Pass `ryusim` explicitly
68
+ if other simulators are also installed.
69
+
70
+ ## What RyuSim supports
71
+
72
+ Verilog and SystemVerilog through VPI. There is no VHDL support.
73
+
74
+ These parts of IEEE 1800-2023 are not implemented: switch-level modelling
75
+ (clause 28; gate-level support covers the basic gate primitives only),
76
+ user-defined primitives (29), `specify` blocks (30), timing checks (31), SDF
77
+ back-annotation (32), design configurations (33), and the VPI assertion,
78
+ coverage-control and data-read APIs (39–41).
79
+
80
+ RyuSim rejects anything it doesn't implement at compile time, so an unsupported
81
+ construct is always a compile error rather than a silent mis-simulation.
82
+
83
+ Inertial writes are trusted by default (`COCOTB_TRUST_INERTIAL_WRITES=1`), as
84
+ cocotb does for Verilator, GHDL and NVC.
85
+
86
+ ## How it works
87
+
88
+ RyuSim's VPI callback behavior matches Verilator's, so this package loads
89
+ cocotb's own `libcocotbvpi_verilator.so`. It adds `ryusim` to cocotb's runner and
90
+ pytest registries, and ships the RyuSim makefile. It never modifies cocotb's
91
+ installed files.
92
+
93
+ ## cocotb compatibility
94
+
95
+ This package relies on some cocotb internals, so it pins `cocotb>=2.1,<2.2`. A
96
+ new cocotb minor release gets a new cocotbext-ryusim release once CI passes
97
+ against it. Until then, pip keeps a compatible cocotb rather than breaking at
98
+ runtime. CI runs cocotb's full Verilog regression through this package.
99
+
100
+ ## License
101
+
102
+ BSD-3-Clause. Portions are derived from cocotb, © cocotb contributors; see
103
+ [LICENSE](LICENSE).