diff --git a/.github/workflows/pypi.yaml b/.github/workflows/pypi.yaml index beecd7e..2137908 100644 --- a/.github/workflows/pypi.yaml +++ b/.github/workflows/pypi.yaml @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f57819c..60ecdb3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/.gitignore b/.gitignore index e32f884..977eda6 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,4 @@ __pycache__ build ignore results -venv *.egg-info diff --git a/Makefile b/Makefile index 9a2ade9..6445d20 100644 --- a/Makefile +++ b/Makefile @@ -15,9 +15,6 @@ lint: test: cd tests && bash run.sh -venv: - bash venv.sh - clean: py3clean . rm -fr .pytest_cache diff --git a/README.md b/README.md index e31a08b..2d36cdc 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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) @@ -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 @@ -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 @@ -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 ...] @@ -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 diff --git a/hdlconv/__init__.py b/hdlconv/__init__.py index e9ed53c..ef224bb 100644 --- a/hdlconv/__init__.py +++ b/hdlconv/__init__.py @@ -1,3 +1,3 @@ """hdlconv version""" -__version__ = '0.1.1' +__version__ = '0.2.0' diff --git a/hdlconv/core.py b/hdlconv/core.py index d9918cd..63262ce 100644 --- a/hdlconv/core.py +++ b/hdlconv/core.py @@ -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', @@ -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 @@ -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' diff --git a/hdlconv/templates/docker.jinja b/hdlconv/templates/docker.jinja index fbfcd27..8c4de64 100644 --- a/hdlconv/templates/docker.jinja +++ b/hdlconv/templates/docker.jinja @@ -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 %} diff --git a/tests/run.sh b/tests/run.sh index a0179e7..c5cd66b 100644 --- a/tests/run.sh +++ b/tests/run.sh @@ -4,12 +4,20 @@ 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 @@ -17,6 +25,10 @@ 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 \ @@ -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 @@ -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 diff --git a/venv.sh b/venv.sh deleted file mode 100644 index b455a7a..0000000 --- a/venv.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -set -e - -python3 -m venv venv -source venv/bin/activate -pip install --upgrade pip setuptools wheel -pip install . -vhdl2vhdl -v -vhdl2vlog -v -slog2vlog -v -deactivate