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

0.2.0 #9

Merged
merged 6 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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: 2 additions & 2 deletions .github/workflows/pypi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install dependencies
Expand Down
18 changes: 16 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,25 @@ on:

jobs:
test:
strategy:
matrix:
pyver: ['3.8', '3.9', '3.10', '3.11', '3.12']
runs-on: ubuntu-latest
name: ${{ matrix.pyver }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Check Install
run: make venv
- name: Set up Python ${{ matrix.pyver }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.pyver }}
- name: Install
run: pip install .
- name: Run tests
run: make test
- name: Upload results on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: results
path: tests/results
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@ __pycache__
build
ignore
results
venv
*.egg-info
3 changes: 0 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ lint:
test:
cd tests && bash run.sh

venv:
bash venv.sh

clean:
py3clean .
rm -fr .pytest_cache
Expand Down
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ It relies on [Docker](https://docs.docker.com/get-docker) and [PyFPGA containers
# Documentation

```
usage: vhdl2vhdl [-h] [-v] [-g GENERIC VALUE] [-a ARCH] [-f FILENAME]
[-o PATH] -t TOPNAME
usage: vhdl2vhdl [-h] [-v] [--no-docker] [-g GENERIC VALUE] [-a ARCH]
[-f FILENAME] [-o PATH] -t TOPNAME
FILE[,LIBRARY] [FILE[,LIBRARY] ...]

VHDL to VHDL
Expand All @@ -24,6 +24,7 @@ positional arguments:
optional arguments:
-h, --help show this help message and exit
-v, --version show program's version number and exit
--no-docker do not use Docker (use system tools instead)
-g GENERIC VALUE, --generic GENERIC VALUE
specify a top-level Generic (can be specified multiple
times)
Expand All @@ -36,8 +37,8 @@ optional arguments:
```

```
usage: vhdl2vlog [-h] [-v] [--backend TOOL] [-g GENERIC VALUE] [-a ARCH]
[-f FILENAME] [-o PATH] -t TOPNAME
usage: vhdl2vlog [-h] [-v] [--no-docker] [--backend TOOL] [-g GENERIC VALUE]
[-a ARCH] [-f FILENAME] [-o PATH] -t TOPNAME
FILE[,LIBRARY] [FILE[,LIBRARY] ...]

VHDL to Verilog
Expand All @@ -48,6 +49,7 @@ positional arguments:
optional arguments:
-h, --help show this help message and exit
-v, --version show program's version number and exit
--no-docker do not use Docker (use system tools instead)
--backend TOOL backend tool [ghdl]
-g GENERIC VALUE, --generic GENERIC VALUE
specify a top-level Generic (can be specified multiple
Expand All @@ -61,7 +63,7 @@ optional arguments:
```

```
usage: slog2vlog [-h] [-v] [--frontend TOOL] [-p PARAM VALUE]
usage: slog2vlog [-h] [-v] [--no-docker] [--frontend TOOL] [-p PARAM VALUE]
[-d DEFINE VALUE] [-i PATH] [-f FILENAME] [-o PATH] -t
TOPNAME
FILE [FILE ...]
Expand All @@ -74,6 +76,7 @@ positional arguments:
optional arguments:
-h, --help show this help message and exit
-v, --version show program's version number and exit
--no-docker do not use Docker (use system tools instead)
--frontend TOOL frontend tool [slang]
-p PARAM VALUE, --param PARAM VALUE
specify a top-level Parameter (can be specified
Expand Down
2 changes: 1 addition & 1 deletion hdlconv/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""hdlconv version"""

__version__ = '0.1.1'
__version__ = '0.2.0'
11 changes: 10 additions & 1 deletion hdlconv/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ def get_args(src, dst):
action='version',
version=f'HDLconv {prog} - v{version}'
)
parser.add_argument(
'--no-docker',
action='store_true',
help='do not use Docker (use system tools instead)'
)
if src == 'slog':
parser.add_argument(
'--frontend',
Expand Down Expand Up @@ -172,6 +177,9 @@ def get_data(src, dst, args):
if not file.exists():
raise FileNotFoundError(file)
data.setdefault('files', []).append(file)
data.setdefault('volumes', set()).add(Path('/') / file.parts[1])
data['volumes'] = list(data['volumes'])
data['docker'] = not args.no_docker
return data


Expand Down Expand Up @@ -228,8 +236,9 @@ def run_tool(content, odir, filename):

def hdlconv(src, dst):
"""HDL conversion entry-point"""
check_docker()
args = get_args(src, dst)
if not args.no_docker:
check_docker()
if args.filename is None:
args.filename = args.top.lower()
args.filename += '.vhdl' if dst == 'vhdl' else '.v'
Expand Down
4 changes: 3 additions & 1 deletion hdlconv/templates/docker.jinja
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
{% if docker %}
CONTAINER="ghcr.io/pyfpga/synthesis"
DOCKER="docker run --rm -v $HOME:$HOME -v $PWD:$PWD -w $PWD --user $(id -u):$(id -g) $CONTAINER"
DOCKER="docker run --rm{% for volume in volumes %} -v {{ volume }}:{{ volume }}{% endfor %} -w $PWD --user $(id -u):$(id -g) $CONTAINER"
{% endif %}
28 changes: 28 additions & 0 deletions tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,31 @@ set -e

export PYTHONPATH=$(pwd)/..

#
# Sanity
#

python3 ../hdlconv/vhdl2vhdl.py --top Counter hdl/vhdl/counter.vhdl

python3 ../hdlconv/vhdl2vlog.py --top Counter hdl/vhdl/counter.vhdl

python3 ../hdlconv/slog2vlog.py --top Counter hdl/slog/counter.sv

#
# vhdl2vhdl
#

python3 ../hdlconv/vhdl2vhdl.py --filename conv1.vhdl \
--top Counter hdl/vhdl/counter.vhdl

python3 ../hdlconv/vhdl2vhdl.py --filename conv2.vhdl \
--generic FREQ 10000000 --generic SECS 1 --arch Arch --top Top \
hdl/vhdl/blink.vhdl,blink_lib hdl/vhdl/blink_pkg.vhdl,blink_lib hdl/vhdl/top.vhdl

#
# vhdl2vlog
#

python3 ../hdlconv/vhdl2vlog.py --filename conv3.v --top Counter hdl/vhdl/counter.vhdl

python3 ../hdlconv/vhdl2vlog.py --filename conv4.v \
Expand All @@ -30,6 +42,10 @@ python3 ../hdlconv/vhdl2vlog.py --backend yosys --filename conv6.v \
--generic FREQ 10000000 --generic SECS 1 --arch Arch --top Top \
hdl/vhdl/blink.vhdl,blink_lib hdl/vhdl/blink_pkg.vhdl,blink_lib hdl/vhdl/top.vhdl

#
# slog2vlog
#

python3 ../hdlconv/slog2vlog.py --filename conv7.v \
--top Counter hdl/slog/counter.sv

Expand All @@ -56,3 +72,15 @@ python3 ../hdlconv/slog2vlog.py --frontend yosys --filename convC.v \
--define DEFINE1 1 --define DEFINE2 1 \
--param FREQ 10000000 --param SECS 1 \
--top Top hdl/slog/blink.sv hdl/slog/top.sv

#
# Misc
#

# More than one Docker volume

cp hdl/vhdl/top.vhdl /tmp

python3 ../hdlconv/vhdl2vhdl.py --filename convD.vhdl \
--generic FREQ 10000000 --generic SECS 1 --arch Arch --top Top \
hdl/vhdl/blink.vhdl,blink_lib hdl/vhdl/blink_pkg.vhdl,blink_lib /tmp/top.vhdl
12 changes: 0 additions & 12 deletions venv.sh

This file was deleted.