Skip to content
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

PyMTL4.0 Release #264

Open
wants to merge 89 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
488093e
Rename basic_rtl to primitive
ptpan Aug 26, 2022
6584709
[WIP] Stream and dstruct
ptpan Aug 28, 2022
60d73b5
[WIP] StreamSrc/Sink test passing
ptpan Aug 28, 2022
5778a40
[WIP] example and stdlib unit tests passing
ptpan Aug 29, 2022
686db8c
[WIP] Remove out dated tests
ptpan Aug 29, 2022
6f12baf
Remove TestMasterCL
ptpan Aug 29, 2022
406ff8c
Add back the RTL-FL adapters
ptpan Aug 31, 2022
bed393f
Split adapter implementation into single files
ptpan Aug 31, 2022
519c711
Hold stream source when current message is None
ptpan Sep 8, 2022
25c3751
Add line_trace to I/OStreamIfc
ptpan Sep 8, 2022
b72cdea
[ProcFL] Add back ProcFL with adapters
ptpan Sep 10, 2022
3a6a375
get tests running on ProcFL
cbatten Sep 12, 2022
9834cc8
forgot to commit this update
cbatten Sep 12, 2022
4f5a8b1
add random delays to src/sink
cbatten Sep 22, 2022
a70db04
[dev] Add py module to dependency
ptpan Oct 26, 2022
6db6cee
add ordered option to stream sink
cbatten Nov 27, 2022
326559e
temporary fix to change mem msg type field to 3bits
cbatten Dec 1, 2022
37882bc
Fixing double/single underscore issue in translation
ptpan Feb 27, 2023
0e81097
Add non-blocking stream FL adapters
ptpan Mar 1, 2023
0eab5e3
Exposing stream-to-FL adapters in stdlib.stream
ptpan Mar 2, 2023
85300ff
Add line trace to stream-to-FL adapters
ptpan Mar 2, 2023
661c0bd
[mem] Add INV and FLUSH support to MemoryFL
ptpan Oct 26, 2022
86500e9
[mem] Add error message to out-of-bound accesses
ptpan Oct 27, 2022
8c961c7
[verilator] Force signals to toggle on posedge CLK
ptpan Oct 27, 2022
a27b176
[verilator] Add support for verilator 4.228
ptpan Oct 27, 2022
77e708d
[verilator] Update use of verilator variable name in C wrapper
ptpan Oct 27, 2022
cf51f50
[test] Fix segfault due to same toplevel name
ptpan Oct 27, 2022
d628f6a
[test] Temporarily disable tests in yosys backend
ptpan Nov 1, 2022
151edf5
[mem] Improve error messages for behavioral mem
ptpan Nov 22, 2022
fdaaad2
[error msg] Add error messages for double configuring a model
ptpan Nov 22, 2022
fbaa10c
src_file: defaults to filename where class is defined
ptpan Dec 8, 2022
fbb982c
[verilator] Use Verilator context in C/Python wrapper
ptpan Oct 23, 2023
6f0f52f
[import] Release line trace string at final
ptpan Oct 23, 2023
44002c1
[import] Use linker version script to avoid UNIQUE symbols
ptpan Oct 25, 2023
b034129
[import] Fix segfault on exit in import line trace test
ptpan Oct 26, 2023
e837b43
[gitignore] Ignore dist directory
ptpan Nov 2, 2023
e619c4a
[verilog] Refactor translation pass
ptpan Oct 12, 2023
e6fcf7d
[verilog] Use tempfile library to create tmp files
ptpan Oct 12, 2023
27e36b4
[verilog] Initial xdist support in translation/import
ptpan Oct 12, 2023
d4d0d6a
[xdist] Support parallel Verilog co-sim
ptpan Nov 2, 2023
777ea4d
[import] Set Verilog import to verbose
ptpan Nov 2, 2023
d9b4efa
[import] Remove optimization flags from g++ command
ptpan Nov 23, 2023
06174c3
[import] Update C++/Python wrapper to avoid unloading the shared lib
ptpan Nov 23, 2023
2ccab35
[unit-test] Use unique DUT class name to facilitate import
ptpan Nov 23, 2023
77ae1e1
[import] Fix variable reference in C++ wrapper
ptpan Nov 23, 2023
8647882
[dependency] Add fasteners to dependency
ptpan Nov 23, 2023
6b3997c
[ci] Upgrade to Verilator 5.016 in CI
ptpan Nov 23, 2023
609e454
[ci] Remove VERILATOR_ROOT var in CI script
ptpan Nov 23, 2023
2f023d5
[ci] Create symlink to Verilator include directory
ptpan Nov 23, 2023
a317ae8
[ci] Split Verilog and Yosys backend runs
ptpan Nov 23, 2023
c1e2dfb
[ci] Fix Yosys test path
ptpan Nov 23, 2023
1e97cfd
[stdlib] Set mem msg field type_ to its correct width
ptpan Nov 23, 2023
9e365e4
[ci] Fix Yosys test path
ptpan Nov 23, 2023
d573db8
[ci] Merge coverage reports between pytest runs
ptpan Dec 6, 2023
9ee08a5
[yosys] Deprecate use of yosys backend in examples/
ptpan Dec 6, 2023
0edc9a7
[err_msg] Use better message when slicing on Bitstruct signals
ptpan Dec 6, 2023
14d2282
Merge pull request #259 from pymtl/pp482-error-msg-slicing-non-bits
ptpan Dec 6, 2023
c23a673
[README] Point users to compile Verilator v5.016
ptpan Dec 6, 2023
8e546d8
[dsl] Add support for non-s args to refer to self
ptpan Dec 7, 2023
02b17d7
[dsl] Fix typo
ptpan Dec 7, 2023
0738bb7
Merge pull request #260 from pymtl/pp482-construct-self
ptpan Dec 7, 2023
0be16f7
[yosys] Deprecate yosys backend
ptpan Dec 7, 2023
512557d
[coverage] Disable couldnt-parse coverage warning
ptpan Dec 7, 2023
58ea59a
[test] Remove return values from mamba unit tests
ptpan Dec 7, 2023
7e55309
[import] Fix data type declaration for signals of different widths
ptpan Dec 7, 2023
7ce58d5
[setup] Add fasteners to dependency
ptpan Dec 7, 2023
c8e2ab5
[import] Use explicitly sized uint types for signal declaration
ptpan Dec 7, 2023
aa19bfb
[rtlir] Add visit_Constant to behavioral visitor
ptpan Dec 7, 2023
824ee65
[test] Use variable instead of int in extslice test case
ptpan Dec 7, 2023
6da7397
[test] Fix visit_Str test
ptpan Dec 7, 2023
1bf1b7d
[import] Add an import test that uses assertion
ptpan Dec 7, 2023
25c0752
[import] Implement Verilator assertion failure without aborting process
ptpan Dec 7, 2023
adc9056
[import] Fix a bug in Verilog trace of generators
ptpan Jan 29, 2024
8c04957
[test] Fix bitstruct hypothesis test
ptpan Feb 6, 2024
84621d2
[pytest] Skip yosys tests by default
ptpan Feb 6, 2024
86952f5
[ci] Add new Python versions and remove 3.6
ptpan Feb 12, 2024
6cfd5b3
[ci] Update to checkout@v4 and setup-python@v5
ptpan Feb 12, 2024
b8c71b8
Adding __len__ interface and formatting to black
KelvinChung2000 Apr 2, 2024
6cf12f8
Undo formatting
KelvinChung2000 Apr 2, 2024
22230dd
add test
KelvinChung2000 Apr 4, 2024
49bfcb1
Add new line at end of file
yo96 Apr 4, 2024
d5bf3ba
Remove trailing white spaces.
yo96 Apr 4, 2024
198430b
Merge pull request #272 from KelvinChung2000/len-interface
yo96 Apr 4, 2024
2eb57d3
Fix issue with pytest_cmdline_preparse
cbatten Apr 22, 2024
b39d505
Improve index handling in Bits and Signal classes
KelvinChung2000 Apr 30, 2024
d0bc16e
Adding test
KelvinChung2000 Apr 30, 2024
05d82ac
update ast helper
KelvinChung2000 May 1, 2024
07b3bbb
Merge pull request #275 from KelvinChung2000/improve-indexing
yo96 Jun 3, 2024
ea01547
Verilator now requires C++14
cbatten Aug 17, 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
4 changes: 4 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Disable warnings about could not parsing files because PyMTL generates
# code (especially for update blocks) on the fly.
[run]
disable_warnings = couldnt-parse
36 changes: 29 additions & 7 deletions .github/workflows/python-package-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,39 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: [ 3.6, 3.7, 3.8, 3.9 ] # FIXME github recognizes 3.10 as 3.1 lol
python-version: [ "3.7", "3.8", "3.9", "3.10", "3.11", "3.12" ]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install Verilator
run: |
wget https://github.com/cornell-brg/verilator-travisci-cache/raw/master/verilator-travis-4.036.tar.gz
tar -C ${HOME} -xzf verilator-travis-4.036.tar.gz
wget https://github.com/cornell-brg/verilator-travisci-cache/raw/master/verilator-github-actions-5.016.tar.gz
tar -C ${HOME} -xzf verilator-github-actions-5.016.tar.gz
# We need to create a symlink to verilator/share/verilator/include.
# This is because the Verilator binaries are compiled on an EC2
# instance, and that the executable contains hard-coded paths which can
# only be bypassed by defining $VERILATOR_ROOT. See a similar issue at:
# https://github.com/verilator/verilator/issues/4035
# But when $VERILATOR_ROOT is present, Verilator assumes a different
# directory hierarchy by looking into $VERILATOR_ROOT/include, which is
# different from verilator/share/verilator/include. Verilator devs have
# mentioned this will be annoying to fix and I don't quite understand
# why; my current workaround is to symlink the correct include
# directory into the place Verilator is looking at.
ln -s ${HOME}/verilator/share/verilator/include ${HOME}/verilator/include
echo "VERILATOR_ROOT=${HOME}/verilator" >> $GITHUB_ENV
echo "PYMTL_VERILATOR_INCLUDE_DIR=${HOME}/verilator/share/verilator/include" >> $GITHUB_ENV
echo "${HOME}/verilator/bin" >> $GITHUB_PATH

- name: Check Verilator
run: |
echo ${VERILATOR_ROOT}
ls ${VERILATOR_ROOT}/include
echo ${PYMTL_VERILATOR_INCLUDE_DIR}
verilator --version

Expand All @@ -55,8 +68,17 @@ jobs:

- name: Test with pytest
run: |
mkdir build && cd build
pytest --cov-report xml --cov=pymtl3 .. --tb=short --hypothesis-profile CI
mkdir -p build && cd build
# Run all unit tests under pymtl3 directory except for those in the
# yosys backend (we run yosys tests in the second run). This is
# necessary to avoid using the same component name for different
# shared libraries (Verilog and Yosys backend translation result).
pytest --cov-config=../.coveragerc --cov-report xml --cov=pymtl3 \
../pymtl3 --ignore=../pymtl3/passes/backends/yosys --tb=short \
--hypothesis-profile CI
pytest --cov-config=../.coveragerc --cov-report xml --cov=pymtl3 --cov-append \
../pymtl3/passes/backends/yosys --tb=short \
--hypothesis-profile CI

- name: Upload code coverage report
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# still have it appear clean to git.

build*/
dist/
autom4te.cache/
.pytest_cache/
*__pycache__
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ install Verilator from source using the following commands:
$ sudo apt-get install git make autoconf g++ libfl-dev bison
$ mkdir -p ${HOME}/src
$ cd ${HOME}/src
$ wget http://www.veripool.org/ftp/verilator-4.036.tgz
$ tar -xzvf verilator-4.036.tgz
$ cd verilator-4.036
$ git clone https://github.com/verilator/verilator.git
$ cd verilator
$ git checkout v5.016
$ ./configure
$ make
$ sudo make install
Expand Down
70 changes: 0 additions & 70 deletions examples/ex02_cksum/ChecksumCL.py

This file was deleted.

26 changes: 13 additions & 13 deletions examples/ex02_cksum/ChecksumRTL.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
Date : June 6, 2019
"""
from pymtl3 import *
from pymtl3.stdlib.ifcs import RecvIfcRTL, SendIfcRTL
from pymtl3.stdlib.queues import PipeQueueRTL
from pymtl3.stdlib.stream.ifcs import IStreamIfc, OStreamIfc
from pymtl3.stdlib.stream import StreamPipeQueue

#-------------------------------------------------------------------------
# Step unit
Expand Down Expand Up @@ -55,26 +55,26 @@ def construct( s ):

# Interface

s.recv = RecvIfcRTL( Bits128 )
s.send = SendIfcRTL( Bits32 )
s.istream = IStreamIfc( Bits128 )
s.ostream = OStreamIfc( Bits32 )

# Component

s.words = [ Wire( Bits16 ) for _ in range( 8 ) ]
s.sum1 = Wire( Bits32 )
s.sum2 = Wire( Bits32 )

s.in_q = PipeQueueRTL( Bits128, num_entries=1 )
s.in_q = StreamPipeQueue( Bits128, num_entries=1 )
s.steps = [ StepUnit() for _ in range( 8 ) ]

# Register input

connect( s.recv, s.in_q.enq )
connect( s.istream, s.in_q.istream )

# Decompose input message into 8 words

for i in range( 8 ):
s.words[i] //= s.in_q.deq.ret[i*16:(i+1)*16]
s.words[i] //= s.in_q.ostream.msg[i*16:(i+1)*16]

# Connect step units

Expand All @@ -91,14 +91,14 @@ def construct( s ):
s.sum2 //= s.steps[-1].sum2_out

@update
def up_rtl_send():
go = s.in_q.deq.rdy & s.send.rdy
s.send.en @= go
s.in_q.deq.en @= go
def up_rtl_ostream():
go = s.in_q.ostream.val & s.ostream.rdy
s.ostream.val @= go
s.in_q.ostream.rdy @= go

@update
def up_rtl_sum():
s.send.msg @= ( s.sum2 << 16 ) | s.sum1
s.ostream.msg @= ( s.sum2 << 16 ) | s.sum1

def line_trace( s ):
return "{}(){}".format( s.recv, s.send )
return "{}(){}".format( s.istream, s.ostream )
16 changes: 8 additions & 8 deletions examples/ex02_cksum/cksum-translate
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# cksum-translate [options]
#=========================================================================
# This script imports the RTL checksum unit from ChecksumRTL.py and
# translate it into yosys-compatible SystemVerilog. The generated
# SystemVerilog file will be dumped into the current directory ( if no
# output directory is specified ) or the specified output directory.
# translate it into SystemVerilog. The generated SystemVerilog file will
# be dumped into the current directory ( if no output directory is
# specified ) or the specified output directory.
#
# -h --help Display this message
#
Expand All @@ -18,8 +18,8 @@ import argparse
import os
import sys

# Import the translation pass from yosys backend
from pymtl3.passes.backends.yosys import YosysTranslationPass
# Import the translation pass from verilog backend
from pymtl3.passes.backends.verilog import VerilogTranslationPass

# Hack to add project root to python path
cur_dir = os.path.dirname( os.path.abspath( __file__ ) )
Expand Down Expand Up @@ -82,20 +82,20 @@ def main():

# Tag the checksum unit as to be translated

cksum.set_metadata( YosysTranslationPass.enable, True )
cksum.set_metadata( VerilogTranslationPass.enable, True )

# Perform translation

success = False

try:
cksum.elaborate()
cksum.apply( YosysTranslationPass() )
cksum.apply( VerilogTranslationPass() )
success = True
finally:
if success:
path = os.getcwd() + \
f"/{cksum.get_metadata(YosysTranslationPass.translated_filename)}"
f"/{cksum.get_metadata(VerilogTranslationPass.translated_filename)}"
print("\nTranslation finished successfully!")
print(f"You can find the generated SystemVerilog file at {path}.")
else:
Expand Down
Loading