Skip to content

Commit f1d3933

Browse files
authored
Merge pull request #9 from PyFPGA/0.2.0
0.2.0
2 parents 9960df4 + 2e7f045 commit f1d3933

File tree

10 files changed

+68
-28
lines changed

10 files changed

+68
-28
lines changed

.github/workflows/pypi.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Checkout code
13-
uses: actions/checkout@v2
13+
uses: actions/checkout@v4
1414
- name: Set up Python
15-
uses: actions/setup-python@v2
15+
uses: actions/setup-python@v5
1616
with:
1717
python-version: '3.12'
1818
- name: Install dependencies

.github/workflows/test.yml

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,25 @@ on:
55

66
jobs:
77
test:
8+
strategy:
9+
matrix:
10+
pyver: ['3.8', '3.9', '3.10', '3.11', '3.12']
811
runs-on: ubuntu-latest
12+
name: ${{ matrix.pyver }}
913
steps:
1014
- name: Checkout repository
1115
uses: actions/checkout@v4
12-
- name: Check Install
13-
run: make venv
16+
- name: Set up Python ${{ matrix.pyver }}
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: ${{ matrix.pyver }}
20+
- name: Install
21+
run: pip install .
1422
- name: Run tests
1523
run: make test
24+
- name: Upload results on failure
25+
if: failure()
26+
uses: actions/upload-artifact@v4
27+
with:
28+
name: results
29+
path: tests/results

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@ __pycache__
22
build
33
ignore
44
results
5-
venv
65
*.egg-info

Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ lint:
1515
test:
1616
cd tests && bash run.sh
1717

18-
venv:
19-
bash venv.sh
20-
2118
clean:
2219
py3clean .
2320
rm -fr .pytest_cache

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ It relies on [Docker](https://docs.docker.com/get-docker) and [PyFPGA containers
1212
# Documentation
1313

1414
```
15-
usage: vhdl2vhdl [-h] [-v] [-g GENERIC VALUE] [-a ARCH] [-f FILENAME]
16-
[-o PATH] -t TOPNAME
15+
usage: vhdl2vhdl [-h] [-v] [--no-docker] [-g GENERIC VALUE] [-a ARCH]
16+
[-f FILENAME] [-o PATH] -t TOPNAME
1717
FILE[,LIBRARY] [FILE[,LIBRARY] ...]
1818
1919
VHDL to VHDL
@@ -24,6 +24,7 @@ positional arguments:
2424
optional arguments:
2525
-h, --help show this help message and exit
2626
-v, --version show program's version number and exit
27+
--no-docker do not use Docker (use system tools instead)
2728
-g GENERIC VALUE, --generic GENERIC VALUE
2829
specify a top-level Generic (can be specified multiple
2930
times)
@@ -36,8 +37,8 @@ optional arguments:
3637
```
3738

3839
```
39-
usage: vhdl2vlog [-h] [-v] [--backend TOOL] [-g GENERIC VALUE] [-a ARCH]
40-
[-f FILENAME] [-o PATH] -t TOPNAME
40+
usage: vhdl2vlog [-h] [-v] [--no-docker] [--backend TOOL] [-g GENERIC VALUE]
41+
[-a ARCH] [-f FILENAME] [-o PATH] -t TOPNAME
4142
FILE[,LIBRARY] [FILE[,LIBRARY] ...]
4243
4344
VHDL to Verilog
@@ -48,6 +49,7 @@ positional arguments:
4849
optional arguments:
4950
-h, --help show this help message and exit
5051
-v, --version show program's version number and exit
52+
--no-docker do not use Docker (use system tools instead)
5153
--backend TOOL backend tool [ghdl]
5254
-g GENERIC VALUE, --generic GENERIC VALUE
5355
specify a top-level Generic (can be specified multiple
@@ -61,7 +63,7 @@ optional arguments:
6163
```
6264

6365
```
64-
usage: slog2vlog [-h] [-v] [--frontend TOOL] [-p PARAM VALUE]
66+
usage: slog2vlog [-h] [-v] [--no-docker] [--frontend TOOL] [-p PARAM VALUE]
6567
[-d DEFINE VALUE] [-i PATH] [-f FILENAME] [-o PATH] -t
6668
TOPNAME
6769
FILE [FILE ...]
@@ -74,6 +76,7 @@ positional arguments:
7476
optional arguments:
7577
-h, --help show this help message and exit
7678
-v, --version show program's version number and exit
79+
--no-docker do not use Docker (use system tools instead)
7780
--frontend TOOL frontend tool [slang]
7881
-p PARAM VALUE, --param PARAM VALUE
7982
specify a top-level Parameter (can be specified

hdlconv/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""hdlconv version"""
22

3-
__version__ = '0.1.1'
3+
__version__ = '0.2.0'

hdlconv/core.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ def get_args(src, dst):
5555
action='version',
5656
version=f'HDLconv {prog} - v{version}'
5757
)
58+
parser.add_argument(
59+
'--no-docker',
60+
action='store_true',
61+
help='do not use Docker (use system tools instead)'
62+
)
5863
if src == 'slog':
5964
parser.add_argument(
6065
'--frontend',
@@ -172,6 +177,9 @@ def get_data(src, dst, args):
172177
if not file.exists():
173178
raise FileNotFoundError(file)
174179
data.setdefault('files', []).append(file)
180+
data.setdefault('volumes', set()).add(Path('/') / file.parts[1])
181+
data['volumes'] = list(data['volumes'])
182+
data['docker'] = not args.no_docker
175183
return data
176184

177185

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

229237
def hdlconv(src, dst):
230238
"""HDL conversion entry-point"""
231-
check_docker()
232239
args = get_args(src, dst)
240+
if not args.no_docker:
241+
check_docker()
233242
if args.filename is None:
234243
args.filename = args.top.lower()
235244
args.filename += '.vhdl' if dst == 'vhdl' else '.v'

hdlconv/templates/docker.jinja

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
1+
{% if docker %}
12
CONTAINER="ghcr.io/pyfpga/synthesis"
2-
DOCKER="docker run --rm -v $HOME:$HOME -v $PWD:$PWD -w $PWD --user $(id -u):$(id -g) $CONTAINER"
3+
DOCKER="docker run --rm{% for volume in volumes %} -v {{ volume }}:{{ volume }}{% endfor %} -w $PWD --user $(id -u):$(id -g) $CONTAINER"
4+
{% endif %}

tests/run.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,31 @@ set -e
44

55
export PYTHONPATH=$(pwd)/..
66

7+
#
8+
# Sanity
9+
#
10+
711
python3 ../hdlconv/vhdl2vhdl.py --top Counter hdl/vhdl/counter.vhdl
812

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

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

17+
#
18+
# vhdl2vhdl
19+
#
20+
1321
python3 ../hdlconv/vhdl2vhdl.py --filename conv1.vhdl \
1422
--top Counter hdl/vhdl/counter.vhdl
1523

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

28+
#
29+
# vhdl2vlog
30+
#
31+
2032
python3 ../hdlconv/vhdl2vlog.py --filename conv3.v --top Counter hdl/vhdl/counter.vhdl
2133

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

45+
#
46+
# slog2vlog
47+
#
48+
3349
python3 ../hdlconv/slog2vlog.py --filename conv7.v \
3450
--top Counter hdl/slog/counter.sv
3551

@@ -56,3 +72,15 @@ python3 ../hdlconv/slog2vlog.py --frontend yosys --filename convC.v \
5672
--define DEFINE1 1 --define DEFINE2 1 \
5773
--param FREQ 10000000 --param SECS 1 \
5874
--top Top hdl/slog/blink.sv hdl/slog/top.sv
75+
76+
#
77+
# Misc
78+
#
79+
80+
# More than one Docker volume
81+
82+
cp hdl/vhdl/top.vhdl /tmp
83+
84+
python3 ../hdlconv/vhdl2vhdl.py --filename convD.vhdl \
85+
--generic FREQ 10000000 --generic SECS 1 --arch Arch --top Top \
86+
hdl/vhdl/blink.vhdl,blink_lib hdl/vhdl/blink_pkg.vhdl,blink_lib /tmp/top.vhdl

venv.sh

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)