-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from jchabloz/pre_1.1.0
Merge for release 1.1.0
- Loading branch information
Showing
18 changed files
with
434 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Test building docs | ||
|
||
on: | ||
push: | ||
branches-ignore: | ||
- 'main' | ||
paths: | ||
- 'docs/**' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
name: Build documentation | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
- name: Setup Python | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: "3" | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -e ./python | ||
pip install sphinx sphinx-rtd-theme myst-parser | ||
- name: Render | ||
run: | | ||
sphinx-build -M html ./docs ./docs/_build | ||
- name: Upload artifact | ||
uses: actions/upload-pages-artifact@v3 | ||
with: | ||
path: "./docs/_build/html" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Verisocks example - Hello World | ||
|
||
## Introduction | ||
|
||
This example shows how to use Verisocks with a minimalistic test case. The test | ||
does nothing except asking Verisocks for the simulator name and version and | ||
then send an "Hello World!" string to the simulator using the `info` command of | ||
the TCP protocol. | ||
|
||
This example uses the helper function `setup_sim()` in order to easily set up | ||
the simulation. | ||
|
||
## Files | ||
|
||
The example folder contains the following files: | ||
|
||
* [hello_world_tb.v](hello_world_tb.v): Top verilog testbench | ||
* [test_hello_world.py](test_hello_world.py): Verisocks Python testbench file | ||
|
||
## Running the example | ||
|
||
This example can be run by directly executing the Python file or by using | ||
[`pytest`](https://docs.pytest.org). | ||
|
||
### Standalone execution | ||
|
||
Simply run the test script: | ||
```sh | ||
python test_hello_world.py | ||
``` | ||
|
||
The results of the test script execution can be checked from the content of the | ||
`vvp.log` file, which should look like this: | ||
|
||
```log | ||
INFO [Verisocks]: Server address: 127.0.0.1 | ||
INFO [Verisocks]: Port: 44041 | ||
INFO [Verisocks]: Connected to localhost | ||
INFO [Verisocks]: Command "get(sel=sim_info)" received. | ||
INFO [Verisocks]: Command "info" received. | ||
INFO [Verisocks]: Hello World! | ||
INFO [Verisocks]: Command "finish" received. Terminating simulation... | ||
INFO [Verisocks]: Returning control to simulator | ||
``` | ||
|
||
### Using pytest | ||
|
||
If you already have it installed, simply run `pytest` from within the SPI | ||
master example directory or from a parent directory. | ||
Otherwise, follow [installation instruction](https://docs.pytest.org/en/latest/getting-started.html#install-pytest). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/****************************************************************************** | ||
File: hello_world_tb.v | ||
Description: Hello world example testbench for Verisocks | ||
******************************************************************************/ | ||
|
||
/******************************************************************************* | ||
Includes and misc definitions | ||
*******************************************************************************/ | ||
`timescale 1us/10ps //Time scale definitions | ||
|
||
`ifndef VS_NUM_PORT | ||
`define VS_NUM_PORT 5100 | ||
`endif | ||
|
||
`ifndef VS_TIMEOUT | ||
`define VS_TIMEOUT 120 | ||
`endif | ||
|
||
/******************************************************************************* | ||
Testbench | ||
*******************************************************************************/ | ||
module hello_world_tb(); | ||
|
||
initial begin | ||
|
||
/* Launch Verisocks server after other initialization */ | ||
$verisocks_init(`VS_NUM_PORT, `VS_TIMEOUT); | ||
|
||
/* Make sure that the simulation finishes after a while... */ | ||
#1000 | ||
$finish(0); | ||
|
||
end | ||
|
||
endmodule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[pytest] | ||
log_file = pytest.log | ||
log_file_level = DEBUG | ||
log_file_format = [%(levelname)s][%(module)s] %(asctime)s - %(message)s | ||
log_file_date_format = %Y-%m-%d %H:%M:%S |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
from verisocks.verisocks import Verisocks | ||
from verisocks.utils import setup_sim, find_free_port | ||
import socket | ||
import time | ||
import pytest | ||
import logging | ||
import os.path | ||
|
||
|
||
HOST = socket.gethostbyname("localhost") | ||
PORT = find_free_port() | ||
VS_TIMEOUT = 10 | ||
LIBVPI = "../../build/verisocks.vpi" | ||
CONNECT_DELAY = 0.1 | ||
|
||
|
||
def setup_test(): | ||
setup_sim( | ||
LIBVPI, | ||
"hello_world_tb.v", | ||
cwd=os.path.dirname(__file__), | ||
ivl_args=[ | ||
f"-DVS_NUM_PORT={PORT}", | ||
f"-DVS_TIMEOUT={VS_TIMEOUT}" | ||
] | ||
) | ||
time.sleep(CONNECT_DELAY) | ||
|
||
|
||
@pytest.fixture | ||
def vs(): | ||
setup_test() | ||
_vs = Verisocks(HOST, PORT) | ||
_vs.connect() | ||
yield _vs | ||
# Teardown | ||
try: | ||
_vs.finish() | ||
except ConnectionError: | ||
logging.warning("Connection error - Finish command not possible") | ||
_vs.close() | ||
|
||
|
||
def test_hello_world(vs): | ||
|
||
assert vs._connected | ||
answer = vs.get("sim_info") | ||
assert answer['type'] == "result" | ||
print(f"Simulator: {answer['product']}") | ||
print(f"Version: {answer['version']}") | ||
|
||
answer = vs.info("Hello World!") | ||
assert answer['type'] == "ack" | ||
|
||
|
||
if __name__ == "__main__": | ||
|
||
setup_test() | ||
with Verisocks(HOST, PORT) as vs_cli: | ||
test_hello_world(vs_cli) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.