Skip to content

Use args in build, manage flushCall bug #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 50 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
2adc288
tick() now does a posedge first
ivanvig Jul 4, 2022
d972ba9
added 'i_clock' as a clock signal
ivanvig Jul 4, 2022
08a5835
Added option to compile files before design
ivanvig Jul 4, 2022
d8a8b87
Added .sv to file extension checking
ivanvig Jul 4, 2022
bf7ea18
fixed regexp '&' error
ivanvig Jul 4, 2022
181d357
Use command_args in build
bat52 Dec 26, 2022
deb478f
Create verilator_tools.py
bat52 Dec 26, 2022
70fc21e
replace flushCall with runFlushCallbacks
bat52 Dec 26, 2022
25e9c6b
command_args default empty list
bat52 Dec 26, 2022
493512d
added args input instead of command_args
bat52 Dec 26, 2022
d33ff22
add main
bat52 Dec 26, 2022
471b1fd
only import tclwrapper when start_gtkwave
bat52 May 23, 2023
ea2cf7b
add install from github instructions
bat52 May 23, 2023
94b0c9f
add packaging as test requirement
bat52 May 23, 2023
a783fbd
fix finished
bat52 May 23, 2023
abe02b2
import subprocess on top
bat52 May 23, 2023
de76917
remove internal signals tests
bat52 May 23, 2023
a586db5
remove unused import sys
bat52 May 23, 2023
a2442b5
add gtkwave_tcl to __init__
bat52 May 23, 2023
66d3091
f-string fixes
bat52 May 23, 2023
6cf021b
Merge pull request #1 from ivanvig/master
bat52 May 24, 2023
c32a747
remove non-working --top argument
bat52 May 24, 2023
733f9e1
updated readme
bat52 May 24, 2023
4a9f47e
add pypi script
bat52 May 24, 2023
b4f5683
update gitignore
bat52 May 24, 2023
792e2dd
full hierarchy dump and .fst working
bat52 Jun 13, 2023
c108c46
create python package when uploading to pypi
bat52 Jun 13, 2023
c1a03f5
update version
bat52 Jun 13, 2023
26b6335
update readme
bat52 Jun 13, 2023
c662175
stop dump when simulation finished
bat52 Jun 13, 2023
7b0d8f6
add dump_level parameter
bat52 Jun 14, 2023
debd8ef
add function verilator_verilog_tb_ok
bat52 Jan 21, 2024
15022aa
add test_verilator_tools to unittest
bat52 Jan 21, 2024
4fe505b
remove errors related to vcd
bat52 Jan 21, 2024
b2f71d3
update version to 0.7.6
bat52 Jan 21, 2024
ff3f55c
fix lint
bat52 Feb 10, 2024
510b4ef
Create test_ubuntu_20p04.yml
bat52 Feb 10, 2024
ce1a38b
fix test automation
bat52 Feb 10, 2024
8063a04
fix test automation
bat52 Feb 10, 2024
7b1a104
Create test_ubuntu_latest.yml
bat52 Feb 10, 2024
7f5c2fd
Create test_verilator_dev.yml
bat52 Feb 10, 2024
4237dee
add apt update to test_verilator_dev.yml
bat52 Feb 10, 2024
5607422
comment some prerequisites in test_verilator_dev.yml
bat52 Feb 10, 2024
7cf179e
comment libgoogle in test_verilator_dev.yml
bat52 Feb 10, 2024
5fcd0b6
comment unsetenv in test_verilator_dev.yml
bat52 Feb 10, 2024
92fd227
add back commented libraries in test_verilator_dev.yml
bat52 Feb 10, 2024
343c7cb
Commented zlibc in test_verilator_dev.yml
bat52 Feb 10, 2024
d34e889
replace setenv with export in test_verilator_dev.yml
bat52 Feb 10, 2024
6febbb8
Update pip in test_verilator_dev.yml
bat52 Feb 10, 2024
0799cfa
add gcc-9 and gcc-10 install to test_verilator_dev.yml
bat52 Feb 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/test_ubuntu_20p04.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: TestUbuntu20p04

on: [push]

jobs:
build:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: ["3.8", "3.9"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt install verilator
- name: check verilator version
run: |
verilator --version
- name: install pyverilator
run: |
python -m pip install -e ./
- name: test
run: |
cd ./pyverilator/tests
python ./test_pyverilator.py
29 changes: 29 additions & 0 deletions .github/workflows/test_ubuntu_latest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: TestUbuntuLatest

on: [push]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
sudo apt install verilator
- name: check verilator version
run: |
verilator --version
- name: install pyverilator
run: |
python -m pip install -e ./
- name: test
run: |
cd ./pyverilator/tests
python ./test_pyverilator.py
62 changes: 62 additions & 0 deletions .github/workflows/test_verilator_dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: TestVerilatorDev

on: [push]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install build pre-requisites
run: |
sudo apt update
sudo apt install gcc-9 gcc-10
sudo apt-get install git help2man perl python3 make autoconf g++ flex bison ccache
sudo apt-get install numactl perl-doc # libgoogle-perftools-dev
sudo apt-get install libfl2 # Ubuntu only (ignore if gives error)
sudo apt-get install libfl-dev # Ubuntu only (ignore if gives error)
# sudo apt-get install zlibc zlib1g zlib1g-dev # Ubuntu only (ignore if gives error)
- name: Install verilator from github
run: |
git clone https://github.com/verilator/verilator

# Every time you need to build:
# unsetenv VERILATOR_ROOT # For csh; ignore error if on bash
unset VERILATOR_ROOT # For bash
cd verilator
git pull # Make sure git repository is up-to-date
git tag # See what versions exist
git checkout master # Use development branch (e.g. recent bug fixes)
#git checkout stable # Use most recent stable release
#git checkout v{version} # Switch to specified release version

autoconf # Create ./configure script
./configure # Configure and create Makefile
make -j `nproc` # Build Verilator itself (if error, try just 'make')
sudo make install

export VERILATOR_ROOT=`pwd`
cd ..
- name: check verilator version
run: |
verilator --version
- name: check gcc version
run: |
gcc --version
- name: update pip
run: |
pip install --upgrade pip
- name: install pyverilator
run: |
python -m pip install -e ./
- name: test
run: |
cd ./pyverilator/tests
python ./test_pyverilator.py
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
__pycache__/
examples/build
.*
*.gz
17 changes: 14 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
PyVerilator-mm
==============

This is a fork of the original pyverilator package, that manages a newer verilator syntax
and works with WSL (by importing tclwraper only if gtkwave is required).
Below the original readme.

PyVerilator
===========

Expand All @@ -14,6 +21,10 @@ using the following command:

$ pip3 install pyverilator

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

pip3 install git+https://github.com/bat52/pyverilator.git@master

Usage
-----
Expand All @@ -36,7 +47,7 @@ Assume you have the following verilog module stored in ``counter.v``.
if (rst == 1) count_reg <= 0;
else count_reg <= next_count_reg;
end
endmodule'''
endmodule

Then you can use ``pyverilator`` to simulate this module using verilator in
python.
Expand All @@ -50,11 +61,11 @@ python.

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

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

# tick the automatically detected clock
sim.clock.tick()
Expand Down
18 changes: 14 additions & 4 deletions examples/simple_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,21 @@
with open('counter.v', 'w') as f:
f.write(test_verilog)

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

dump_fst = True
if dump_fst:
dump_filename = 'dump.fst'
else:
dump_filename = 'dump.vcd'
sim = pyverilator.PyVerilator.build('counter.v',dump_fst=dump_fst,dump_level=1)

# start gtkwave to view the waveforms as they are made
sim.start_gtkwave()
# sim.start_gtkwave() # moved at the bottom... updating gtkwave during simulation is slow
sim.start_vcd_trace(dump_filename)

# add all the io and internal signals to gtkwave
sim.send_to_gtkwave(sim.io)
sim.send_to_gtkwave(sim.internals)
# sim.send_to_gtkwave(sim.io) # this still works
# sim.send_to_gtkwave(sim.internals) # not working anymore

# set the rst input to 1
sim.io.rst = 1
Expand All @@ -57,3 +64,6 @@

curr_out = sim.io.out.value
print('sim.io.out = ' + str(curr_out))

sim.stop_vcd_trace()
sim.start_gtkwave() # moved at the bottom works both with fst and vcd
80 changes: 80 additions & 0 deletions pypi.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/usr/bin/env bash

DIST=dist
PACKAGE=pyverilator-mm
PIP=pip3

function show_usage(){
echo "Usage: $0 [OPTION]"
echo " Available options:"
echo " -h|--help : Show help"
echo " -c|--create : Create local package"
echo " -u : Upload local package on test repository"
echo " --upload : Upload local package on pypi repository"
echo " -i : Install package from test repository"
echo " --install : Install package from pypi repository"
echo " -un|--install : Uninstall package"
}

# if no argument is specified, show usage
if [[ "$#" -lt 1 ]];
then
show_usage
fi

## parse input args
while [[ "$#" -gt 0 ]]; do
case $1 in
-h|--help) HELP=1; shift ;;
-c|--create) CREATE=1; shift ;;
-u) UPLOAD_TEST=1; shift ;;
--upload) UPLOAD=1; shift ;;
-i) INSTALL_TEST=1; shift ;;
--install) INSTALL=1; shift ;;
-un|--uninstall) UNINSTALL=1 ;;
*) echo "Unknown parameter passed: $1"; exit 1 ;;
esac
shift
done

if [[ "$HELP" -gt 0 ]];
then
show_usage
fi

if [[ "$CREATE" -gt 0 || "$UPLOAD" -gt 0 || "$UPLOAD_TEST" -gt 0 ]];
then
echo "Creating new package... "
rm -rf $DIST # remove old package folder
python3 setup.py sdist # create package
fi

if [[ "$UPLOAD_TEST" -gt 0 ]];
then
echo "Uploading package to testpypi... "
twine upload --repository testpypi ${DIST}/* # upload to testpypi
fi

if [[ "$UPLOAD" -gt 0 ]];
then
echo "Uploading package to pypi... "
twine upload ${DIST}/* # upload to pypi
fi

if [[ "$UNINSTALL" -gt 0 || "$INSTALL" -gt 0 || "$INSTALL_TEST" -gt 0 ]];
then
echo "Uninstalling package... "
$PIP uninstall ${PACKAGE}
fi

if [[ "$INSTALL_TEST" -gt 0 ]];
then
echo "Installing package from testpypi... "
$PIP install --index-url https://test.pypi.org/simple/ ${PACKAGE}
fi

if [[ "$INSTALL" -gt 0 ]];
then
echo "Installing package from pypi... "
$PIP install ${PACKAGE}
fi
Loading