From ea2452747676e702618041d5f1385b7cb95ceb9d Mon Sep 17 00:00:00 2001 From: Lekcyjna <309016@uwr.edu.pl> Date: Sun, 8 Oct 2023 15:30:40 +0200 Subject: [PATCH 01/16] Make TransactionBase a Protocol. --- transactron/core.py | 27 +++++++++++++++++++++------ transactron/graph.py | 5 ++--- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/transactron/core.py b/transactron/core.py index c4c34f8cc..e9ab302da 100644 --- a/transactron/core.py +++ b/transactron/core.py @@ -2,7 +2,18 @@ from collections.abc import Sequence, Iterable, Callable, Mapping, Iterator from contextlib import contextmanager from enum import Enum, auto -from typing import ClassVar, NoReturn, TypeAlias, TypedDict, Union, Optional, Tuple +from typing import ( + ClassVar, + NoReturn, + TypeAlias, + TypedDict, + Union, + Optional, + Tuple, + TypeVar, + Protocol, + runtime_checkable, +) from graphlib import TopologicalSorter from typing_extensions import Self from amaranth import * @@ -38,6 +49,7 @@ TransactionScheduler: TypeAlias = Callable[["MethodMap", TransactionGraph, TransactionGraphCC, PriorityOrder], Module] RecordDict: TypeAlias = ValueLike | Mapping[str, "RecordDict"] TransactionOrMethod: TypeAlias = Union["Transaction", "Method"] +TransactionOrMethodBound = TypeVar("TransactionOrMethodBound", bound=Union["Transaction", "Method"]) class Priority(Enum): @@ -670,15 +682,20 @@ def elaborate(self, platform): return self.main_module -class TransactionBase(Owned): +@runtime_checkable +class TransactionBase(Owned, Protocol): stack: ClassVar[list[Union["Transaction", "Method"]]] = [] def_counter: ClassVar[count] = count() def_order: int defined: bool = False name: str + method_uses: dict["Method", Tuple[ValueLike, ValueLike]] + relations: list[RelationBase] + simultaneous_list: list[TransactionOrMethod] + independent_list: list[TransactionOrMethod] def __init__(self): - self.method_uses: dict[Method, Tuple[ValueLike, ValueLike]] = dict() + self.method_uses: dict["Method", Tuple[ValueLike, ValueLike]] = dict() self.relations: list[RelationBase] = [] self.simultaneous_list: list[TransactionOrMethod] = [] self.independent_list: list[TransactionOrMethod] = [] @@ -769,9 +786,7 @@ def _independent(self, *others: TransactionOrMethod) -> None: self.independent_list += others @contextmanager - def context(self, m: TModule) -> Iterator[Self]: - assert isinstance(self, Transaction) or isinstance(self, Method) # for typing - + def context(self: TransactionOrMethodBound, m: TModule) -> Iterator[TransactionOrMethodBound]: parent = TransactionBase.peek() if parent is not None: parent.schedule_before(self) diff --git a/transactron/graph.py b/transactron/graph.py index 2deaf24a0..4cd51d067 100644 --- a/transactron/graph.py +++ b/transactron/graph.py @@ -3,15 +3,14 @@ """ from enum import IntFlag -from abc import ABC from collections import defaultdict -from typing import Literal, Optional +from typing import Literal, Optional, Protocol from amaranth.hdl.ir import Elaboratable, Fragment from .tracing import TracingFragment -class Owned(ABC): +class Owned(Protocol): name: str owner: Optional[Elaboratable] From c60fa7c6e462ce6aca4b5ab3cbe2bc93f05309c5 Mon Sep 17 00:00:00 2001 From: Lekcyjna <309016@uwr.edu.pl> Date: Sun, 8 Oct 2023 15:48:36 +0200 Subject: [PATCH 02/16] Bump python --- .github/workflows/main.yml | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4d70ae121..348f04058 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -41,6 +41,15 @@ jobs: - name: Checkout uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + cache: 'pip' + cache-dependency-path: | + requirements.txt + requirements-dev.txt + - name: Install dependencies run: | python3 -m pip install --upgrade pip @@ -76,7 +85,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: '3.10' + python-version: '3.11' cache: 'pip' cache-dependency-path: | requirements.txt @@ -105,7 +114,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: '3.10' + python-version: '3.11' cache: 'pip' cache-dependency-path: | requirements.txt From f62e0c5eada42f22b7184ab4433caf7e965702b9 Mon Sep 17 00:00:00 2001 From: Lekcyjna <309016@uwr.edu.pl> Date: Sun, 8 Oct 2023 15:54:59 +0200 Subject: [PATCH 03/16] Bump python version for docs --- .github/workflows/benchmark.yml | 18 ++++++++++++++++++ .github/workflows/deploy_gh_pages.yml | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index e7a72d1af..b3548dea8 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -23,6 +23,15 @@ jobs: # https://github.com/actions/runner/issues/2033 chown -R $(id -u):$(id -g) $PWD + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.11" + cache: "pip" + cache-dependency-path: | + requirements.txt + requirements-dev.txt + - name: Install dependencies run: | python3 -m pip install --upgrade pip @@ -84,6 +93,15 @@ jobs: # https://github.com/actions/runner/issues/2033 chown -R $(id -u):$(id -g) $PWD + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: "3.11" + cache: "pip" + cache-dependency-path: | + requirements.txt + requirements-dev.txt + - name: Install dependencies run: | python3 -m pip install --upgrade pip diff --git a/.github/workflows/deploy_gh_pages.yml b/.github/workflows/deploy_gh_pages.yml index 210752f06..753d80ae1 100644 --- a/.github/workflows/deploy_gh_pages.yml +++ b/.github/workflows/deploy_gh_pages.yml @@ -26,7 +26,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v4 with: - python-version: "3.10" + python-version: "3.11" cache: "pip" cache-dependency-path: | requirements.txt From a236098647cd2f07f1c2f7ba9ec0175e03701bc1 Mon Sep 17 00:00:00 2001 From: Lekcyjna <309016@uwr.edu.pl> Date: Mon, 9 Oct 2023 19:26:42 +0200 Subject: [PATCH 04/16] Update dockerfiles. --- .github/workflows/benchmark.yml | 4 ++-- .github/workflows/main.yml | 2 +- docker/AmaranthSynthECP5.Dockerfile | 4 ++-- docker/Verilator.Dockerfile | 4 ++-- docker/riscv-toolchain.Dockerfile | 4 ++-- transactron/core.py | 2 +- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index b3548dea8..f5a34e06e 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -14,7 +14,7 @@ jobs: name: Synthesis benchmarks runs-on: ubuntu-latest timeout-minutes: 40 - container: ghcr.io/kuznia-rdzeni/amaranth-synth:ecp5 + container: ghcr.io/kuznia-rdzeni/amaranth-synth-ecp5:2023.10.08_v steps: - uses: actions/checkout@v3 @@ -82,7 +82,7 @@ jobs: name: Run performance benchmarks runs-on: ubuntu-latest timeout-minutes: 60 - container: ghcr.io/kuznia-rdzeni/verilator:v5.008 + container: ghcr.io/kuznia-rdzeni/verilator:v5.008-3.11 needs: build-perf-benchmarks steps: - name: Checkout diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 348f04058..16779db24 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -35,7 +35,7 @@ jobs: name: Run regression tests runs-on: ubuntu-latest timeout-minutes: 10 - container: ghcr.io/kuznia-rdzeni/verilator:v5.008 + container: ghcr.io/kuznia-rdzeni/verilator:v5.008-3.11 needs: build-regression-tests steps: - name: Checkout diff --git a/docker/AmaranthSynthECP5.Dockerfile b/docker/AmaranthSynthECP5.Dockerfile index 0e9809b8c..3b9326ccf 100644 --- a/docker/AmaranthSynthECP5.Dockerfile +++ b/docker/AmaranthSynthECP5.Dockerfile @@ -1,9 +1,9 @@ -FROM ubuntu:22.10 +FROM ubuntu:23.04 RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive \ apt-get install -y --no-install-recommends \ - python3.10 python3-pip git yosys \ + python3.11 python3-pip git yosys lsb-release \ build-essential cmake python3-dev libboost-all-dev libeigen3-dev && \ rm -rf /var/lib/apt/lists/* diff --git a/docker/Verilator.Dockerfile b/docker/Verilator.Dockerfile index ddb5925f7..64c60c5e4 100644 --- a/docker/Verilator.Dockerfile +++ b/docker/Verilator.Dockerfile @@ -1,9 +1,9 @@ -FROM ubuntu:22.10 +FROM ubuntu:23.04 RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive \ apt-get install -y --no-install-recommends \ - python3.10 libpython3.10 python3-pip git \ + python3.11 libpython3.11 python3-pip git lsb-release \ perl perl-doc help2man make autoconf g++ flex bison ccache numactl \ libgoogle-perftools-dev libfl-dev zlib1g-dev && \ rm -rf /var/lib/apt/lists/* diff --git a/docker/riscv-toolchain.Dockerfile b/docker/riscv-toolchain.Dockerfile index ec33ce01b..d35c604b9 100644 --- a/docker/riscv-toolchain.Dockerfile +++ b/docker/riscv-toolchain.Dockerfile @@ -1,9 +1,9 @@ -FROM ubuntu:22.10 +FROM ubuntu:23.04 RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive \ apt-get install -y --no-install-recommends \ - autoconf automake autotools-dev curl python3 bc \ + autoconf automake autotools-dev curl python3 bc lsb-release \ libmpc-dev libmpfr-dev libgmp-dev gawk build-essential \ bison flex texinfo gperf libtool patchutils zlib1g-dev \ libexpat-dev ninja-build git ca-certificates python-is-python3 && \ diff --git a/transactron/core.py b/transactron/core.py index e9ab302da..745b98b4d 100644 --- a/transactron/core.py +++ b/transactron/core.py @@ -49,7 +49,7 @@ TransactionScheduler: TypeAlias = Callable[["MethodMap", TransactionGraph, TransactionGraphCC, PriorityOrder], Module] RecordDict: TypeAlias = ValueLike | Mapping[str, "RecordDict"] TransactionOrMethod: TypeAlias = Union["Transaction", "Method"] -TransactionOrMethodBound = TypeVar("TransactionOrMethodBound", bound=Union["Transaction", "Method"]) +TransactionOrMethodBound = TypeVar("TransactionOrMethodBound", "Transaction", "Method") class Priority(Enum): From 82150d1e7aa46e04e5a2cefafce03aab338026bf Mon Sep 17 00:00:00 2001 From: Lekcyjna <309016@uwr.edu.pl> Date: Mon, 9 Oct 2023 19:56:50 +0200 Subject: [PATCH 05/16] Update riscv-toolchain. --- .github/workflows/benchmark.yml | 20 +------------------- .github/workflows/main.yml | 11 +---------- 2 files changed, 2 insertions(+), 29 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index f5a34e06e..65338208d 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -23,15 +23,6 @@ jobs: # https://github.com/actions/runner/issues/2033 chown -R $(id -u):$(id -g) $PWD - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: "3.11" - cache: "pip" - cache-dependency-path: | - requirements.txt - requirements-dev.txt - - name: Install dependencies run: | python3 -m pip install --upgrade pip @@ -62,7 +53,7 @@ jobs: build-perf-benchmarks: name: Build performance benchmarks runs-on: ubuntu-latest - container: ghcr.io/kuznia-rdzeni/riscv-toolchain:2023.05.14 + container: ghcr.io/lekcyjna123/riscv-toolchain:2023.10.08_v steps: - name: Checkout uses: actions/checkout@v3 @@ -93,15 +84,6 @@ jobs: # https://github.com/actions/runner/issues/2033 chown -R $(id -u):$(id -g) $PWD - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: "3.11" - cache: "pip" - cache-dependency-path: | - requirements.txt - requirements-dev.txt - - name: Install dependencies run: | python3 -m pip install --upgrade pip diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 16779db24..53ac38bea 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,7 +15,7 @@ jobs: build-regression-tests: name: Build regression tests runs-on: ubuntu-latest - container: ghcr.io/kuznia-rdzeni/riscv-toolchain:2023.05.14 + container: ghcr.io/lekcyjna123/riscv-toolchain:2023.10.08_v steps: - name: Checkout uses: actions/checkout@v3 @@ -41,15 +41,6 @@ jobs: - name: Checkout uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v4 - with: - python-version: '3.11' - cache: 'pip' - cache-dependency-path: | - requirements.txt - requirements-dev.txt - - name: Install dependencies run: | python3 -m pip install --upgrade pip From be694e73f9066391d0fa86fda4d14e84f94ca7c7 Mon Sep 17 00:00:00 2001 From: Lekcyjna <309016@uwr.edu.pl> Date: Mon, 9 Oct 2023 20:02:25 +0200 Subject: [PATCH 06/16] Break system packages. --- .github/workflows/benchmark.yml | 8 ++++---- .github/workflows/deploy_gh_pages.yml | 2 +- .github/workflows/main.yml | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 65338208d..5c23b6873 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -25,8 +25,8 @@ jobs: - name: Install dependencies run: | - python3 -m pip install --upgrade pip - pip3 install -r requirements-dev.txt + python3 -m pip install --break-system-packages --upgrade pip + pip3 install --break-system-packages -r requirements-dev.txt - name: Synthesize run: PYTHONHASHSEED=0 ./scripts/synthesize.py --verbose --config ${{ matrix.config }} @@ -86,8 +86,8 @@ jobs: - name: Install dependencies run: | - python3 -m pip install --upgrade pip - pip3 install -r requirements-dev.txt + python3 -m pip install --break-system-packages --upgrade pip + pip3 install --break-system-packages -r requirements-dev.txt - name: Generate Verilog run: PYTHONHASHSEED=0 ./scripts/gen_verilog.py --verbose --config full diff --git a/.github/workflows/deploy_gh_pages.yml b/.github/workflows/deploy_gh_pages.yml index 753d80ae1..d4207509f 100644 --- a/.github/workflows/deploy_gh_pages.yml +++ b/.github/workflows/deploy_gh_pages.yml @@ -34,7 +34,7 @@ jobs: - name: Install dependencies run: | - python -m pip install --upgrade pip + python -m pip install --break-system-packages --upgrade pip pip3 install -r requirements-dev.txt - name: Build documentation diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 53ac38bea..4a5124871 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -43,8 +43,8 @@ jobs: - name: Install dependencies run: | - python3 -m pip install --upgrade pip - pip3 install -r requirements-dev.txt + python3 -m pip install --break-system-packages --upgrade pip + pip3 install --break-system-packages -r requirements-dev.txt - name: Generate Verilog run: PYTHONHASHSEED=0 ./scripts/gen_verilog.py --verbose --config full From 8ca2be3c085c3f356cc9e0e12ca7a548ec4ed54d Mon Sep 17 00:00:00 2001 From: Lekcyjna <309016@uwr.edu.pl> Date: Sat, 14 Oct 2023 13:10:13 +0200 Subject: [PATCH 07/16] Add back setup python step. --- .github/workflows/benchmark.yml | 18 ++++++++++++++++++ .github/workflows/main.yml | 9 +++++++++ docker/riscv-toolchain.Dockerfile | 4 ++-- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 5c23b6873..31207d033 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -23,6 +23,15 @@ jobs: # https://github.com/actions/runner/issues/2033 chown -R $(id -u):$(id -g) $PWD + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + cache: 'pip' + cache-dependency-path: | + requirements.txt + requirements-dev.txt + - name: Install dependencies run: | python3 -m pip install --break-system-packages --upgrade pip @@ -84,6 +93,15 @@ jobs: # https://github.com/actions/runner/issues/2033 chown -R $(id -u):$(id -g) $PWD + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + cache: 'pip' + cache-dependency-path: | + requirements.txt + requirements-dev.txt + - name: Install dependencies run: | python3 -m pip install --break-system-packages --upgrade pip diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4a5124871..7cc22e5a4 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -41,6 +41,15 @@ jobs: - name: Checkout uses: actions/checkout@v3 + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.11' + cache: 'pip' + cache-dependency-path: | + requirements.txt + requirements-dev.txt + - name: Install dependencies run: | python3 -m pip install --break-system-packages --upgrade pip diff --git a/docker/riscv-toolchain.Dockerfile b/docker/riscv-toolchain.Dockerfile index d35c604b9..e64e2bce1 100644 --- a/docker/riscv-toolchain.Dockerfile +++ b/docker/riscv-toolchain.Dockerfile @@ -1,9 +1,9 @@ -FROM ubuntu:23.04 +FROM ubuntu:23.10 RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive \ apt-get install -y --no-install-recommends \ - autoconf automake autotools-dev curl python3 bc lsb-release \ + autoconf automake autotools-dev curl python3 python3-pip bc lsb-release \ libmpc-dev libmpfr-dev libgmp-dev gawk build-essential \ bison flex texinfo gperf libtool patchutils zlib1g-dev \ libexpat-dev ninja-build git ca-certificates python-is-python3 && \ From f0068bfc7056fd347d8a44590227c7d032db6a30 Mon Sep 17 00:00:00 2001 From: Lekcyjna <309016@uwr.edu.pl> Date: Sat, 14 Oct 2023 13:38:10 +0200 Subject: [PATCH 08/16] Check if setup python without cache works. --- .github/workflows/main.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7cc22e5a4..6e33361af 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -45,10 +45,6 @@ jobs: uses: actions/setup-python@v4 with: python-version: '3.11' - cache: 'pip' - cache-dependency-path: | - requirements.txt - requirements-dev.txt - name: Install dependencies run: | From 283724f21182acc96c827d1a55a465f6587d139b Mon Sep 17 00:00:00 2001 From: Lekcyjna <309016@uwr.edu.pl> Date: Sat, 14 Oct 2023 14:10:31 +0200 Subject: [PATCH 09/16] Change command to install requirements. --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 6e33361af..7bf7bfd7c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -49,7 +49,7 @@ jobs: - name: Install dependencies run: | python3 -m pip install --break-system-packages --upgrade pip - pip3 install --break-system-packages -r requirements-dev.txt + python3 -m pip install --break-system-packages -r requirements-dev.txt - name: Generate Verilog run: PYTHONHASHSEED=0 ./scripts/gen_verilog.py --verbose --config full From 662322cf255ae7593c4ebcc247cb339d76accb7b Mon Sep 17 00:00:00 2001 From: Lekcyjna <309016@uwr.edu.pl> Date: Sat, 14 Oct 2023 14:27:01 +0200 Subject: [PATCH 10/16] Try to use venv instead of break-system-packages --- .github/workflows/main.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7bf7bfd7c..994bd01d9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -48,8 +48,10 @@ jobs: - name: Install dependencies run: | - python3 -m pip install --break-system-packages --upgrade pip - python3 -m pip install --break-system-packages -r requirements-dev.txt + python3 -m venv venv + source venv/bin/activate + python3 -m pip install --upgrade pip + python3 -m pip install -r requirements-dev.txt - name: Generate Verilog run: PYTHONHASHSEED=0 ./scripts/gen_verilog.py --verbose --config full From d3dc874678573d1ab9814aa8f4f53372dbaca18d Mon Sep 17 00:00:00 2001 From: Lekcyjna <309016@uwr.edu.pl> Date: Sat, 14 Oct 2023 14:54:02 +0200 Subject: [PATCH 11/16] Yet another way to initialise python env --- .github/workflows/main.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 994bd01d9..9ba7073ec 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -49,12 +49,14 @@ jobs: - name: Install dependencies run: | python3 -m venv venv - source venv/bin/activate + . venv/bin/activate python3 -m pip install --upgrade pip python3 -m pip install -r requirements-dev.txt - name: Generate Verilog - run: PYTHONHASHSEED=0 ./scripts/gen_verilog.py --verbose --config full + run: | + . venv/bin/activate + PYTHONHASHSEED=0 ./scripts/gen_verilog.py --verbose --config full - uses: actions/download-artifact@v3 with: @@ -63,6 +65,7 @@ jobs: - name: Run tests run: | + . venv/bin/activate scripts/run_tests.py -a regression - name: Test Report From a14349042acf12ea0764465e827f1920d8e5f794 Mon Sep 17 00:00:00 2001 From: Lekcyjna <309016@uwr.edu.pl> Date: Sat, 14 Oct 2023 15:07:25 +0200 Subject: [PATCH 12/16] Python3 update --- docker/riscv-toolchain.Dockerfile | 4 ++-- transactron/core.py | 27 ++++++--------------------- transactron/graph.py | 5 +++-- 3 files changed, 11 insertions(+), 25 deletions(-) diff --git a/docker/riscv-toolchain.Dockerfile b/docker/riscv-toolchain.Dockerfile index e64e2bce1..d35c604b9 100644 --- a/docker/riscv-toolchain.Dockerfile +++ b/docker/riscv-toolchain.Dockerfile @@ -1,9 +1,9 @@ -FROM ubuntu:23.10 +FROM ubuntu:23.04 RUN apt-get update && \ DEBIAN_FRONTEND=noninteractive \ apt-get install -y --no-install-recommends \ - autoconf automake autotools-dev curl python3 python3-pip bc lsb-release \ + autoconf automake autotools-dev curl python3 bc lsb-release \ libmpc-dev libmpfr-dev libgmp-dev gawk build-essential \ bison flex texinfo gperf libtool patchutils zlib1g-dev \ libexpat-dev ninja-build git ca-certificates python-is-python3 && \ diff --git a/transactron/core.py b/transactron/core.py index 745b98b4d..c4c34f8cc 100644 --- a/transactron/core.py +++ b/transactron/core.py @@ -2,18 +2,7 @@ from collections.abc import Sequence, Iterable, Callable, Mapping, Iterator from contextlib import contextmanager from enum import Enum, auto -from typing import ( - ClassVar, - NoReturn, - TypeAlias, - TypedDict, - Union, - Optional, - Tuple, - TypeVar, - Protocol, - runtime_checkable, -) +from typing import ClassVar, NoReturn, TypeAlias, TypedDict, Union, Optional, Tuple from graphlib import TopologicalSorter from typing_extensions import Self from amaranth import * @@ -49,7 +38,6 @@ TransactionScheduler: TypeAlias = Callable[["MethodMap", TransactionGraph, TransactionGraphCC, PriorityOrder], Module] RecordDict: TypeAlias = ValueLike | Mapping[str, "RecordDict"] TransactionOrMethod: TypeAlias = Union["Transaction", "Method"] -TransactionOrMethodBound = TypeVar("TransactionOrMethodBound", "Transaction", "Method") class Priority(Enum): @@ -682,20 +670,15 @@ def elaborate(self, platform): return self.main_module -@runtime_checkable -class TransactionBase(Owned, Protocol): +class TransactionBase(Owned): stack: ClassVar[list[Union["Transaction", "Method"]]] = [] def_counter: ClassVar[count] = count() def_order: int defined: bool = False name: str - method_uses: dict["Method", Tuple[ValueLike, ValueLike]] - relations: list[RelationBase] - simultaneous_list: list[TransactionOrMethod] - independent_list: list[TransactionOrMethod] def __init__(self): - self.method_uses: dict["Method", Tuple[ValueLike, ValueLike]] = dict() + self.method_uses: dict[Method, Tuple[ValueLike, ValueLike]] = dict() self.relations: list[RelationBase] = [] self.simultaneous_list: list[TransactionOrMethod] = [] self.independent_list: list[TransactionOrMethod] = [] @@ -786,7 +769,9 @@ def _independent(self, *others: TransactionOrMethod) -> None: self.independent_list += others @contextmanager - def context(self: TransactionOrMethodBound, m: TModule) -> Iterator[TransactionOrMethodBound]: + def context(self, m: TModule) -> Iterator[Self]: + assert isinstance(self, Transaction) or isinstance(self, Method) # for typing + parent = TransactionBase.peek() if parent is not None: parent.schedule_before(self) diff --git a/transactron/graph.py b/transactron/graph.py index 4cd51d067..2deaf24a0 100644 --- a/transactron/graph.py +++ b/transactron/graph.py @@ -3,14 +3,15 @@ """ from enum import IntFlag +from abc import ABC from collections import defaultdict -from typing import Literal, Optional, Protocol +from typing import Literal, Optional from amaranth.hdl.ir import Elaboratable, Fragment from .tracing import TracingFragment -class Owned(Protocol): +class Owned(ABC): name: str owner: Optional[Elaboratable] From 72e0384b23b8c68b44db292f209da43b38cc6d03 Mon Sep 17 00:00:00 2001 From: Lekcyjna <309016@uwr.edu.pl> Date: Sat, 14 Oct 2023 15:10:54 +0200 Subject: [PATCH 13/16] Docs update. --- docs/Development_environment.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Development_environment.md b/docs/Development_environment.md index 8f471cefa..cfdb58cad 100644 --- a/docs/Development_environment.md +++ b/docs/Development_environment.md @@ -4,7 +4,7 @@ In order to prepare the development environment, please follow the steps below: -1. Install the Python 3.10 interpreter and pip package manager. +1. Install the Python 3.11 interpreter and pip package manager. * Optionally create a Python virtual environment with `python3 -m venv venv` in the project directory and activate it using generated script: `. venv/bin/activate`. 2. Install all required libraries with `pip3 install -r requirements-dev.txt`. 3. Install `riscv64-unknown-elf` binutils using your favourite package manager. On Debian-based distros the package is called `binutils-riscv64-unknown-elf`, on Arch-based - `riscv64-unknown-elf-binutils`. From f47956c65861339015517e3723d7114bf1e0ca22 Mon Sep 17 00:00:00 2001 From: Lekcyjna <309016@uwr.edu.pl> Date: Sat, 14 Oct 2023 15:22:31 +0200 Subject: [PATCH 14/16] Update dockerfiles. --- .github/workflows/benchmark.yml | 30 ++++++++++++++------------- .github/workflows/deploy_gh_pages.yml | 18 +++++++++------- 2 files changed, 26 insertions(+), 22 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 31207d033..4dcc1ed0b 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -27,24 +27,25 @@ jobs: uses: actions/setup-python@v4 with: python-version: '3.11' - cache: 'pip' - cache-dependency-path: | - requirements.txt - requirements-dev.txt - name: Install dependencies run: | - python3 -m pip install --break-system-packages --upgrade pip - pip3 install --break-system-packages -r requirements-dev.txt + python3 -m venv venv + . venv/bin/activate + python3 -m pip install --upgrade pip + python3 -m pip install -r requirements-dev.txt - name: Synthesize - run: PYTHONHASHSEED=0 ./scripts/synthesize.py --verbose --config ${{ matrix.config }} + run: | + . venv/bin/activate + PYTHONHASHSEED=0 ./scripts/synthesize.py --verbose --config ${{ matrix.config }} - name: Print synthesis information run: cat ./build/top.tim - name: Collect Benchmark information run: | + . venv/bin/activate ./scripts/parse_benchmark_info.py cat ./benchmark.json @@ -97,18 +98,18 @@ jobs: uses: actions/setup-python@v4 with: python-version: '3.11' - cache: 'pip' - cache-dependency-path: | - requirements.txt - requirements-dev.txt - name: Install dependencies run: | - python3 -m pip install --break-system-packages --upgrade pip - pip3 install --break-system-packages -r requirements-dev.txt + python3 -m venv venv + . venv/bin/activate + python3 -m pip install --upgrade pip + python3 -m pip install -r requirements-dev.txt - name: Generate Verilog - run: PYTHONHASHSEED=0 ./scripts/gen_verilog.py --verbose --config full + run: | + . venv/bin/activate + PYTHONHASHSEED=0 ./scripts/gen_verilog.py --verbose --config full - uses: actions/download-artifact@v3 with: @@ -117,6 +118,7 @@ jobs: - name: Run benchmarks run: | + . venv/bin/activate scripts/run_benchmarks.py - name: Store benchmark result (IPC) diff --git a/.github/workflows/deploy_gh_pages.yml b/.github/workflows/deploy_gh_pages.yml index d4207509f..89fdeea7d 100644 --- a/.github/workflows/deploy_gh_pages.yml +++ b/.github/workflows/deploy_gh_pages.yml @@ -27,20 +27,22 @@ jobs: uses: actions/setup-python@v4 with: python-version: "3.11" - cache: "pip" - cache-dependency-path: | - requirements.txt - requirements-dev.txt - name: Install dependencies run: | - python -m pip install --break-system-packages --upgrade pip - pip3 install -r requirements-dev.txt + python3 -m venv venv + . venv/bin/activate + python -m pip install --upgrade pip + python -m pip install -r requirements-dev.txt - name: Build documentation - run: ./ci/build_docs.sh + run: | + . venv/bin/activate + ./ci/build_docs.sh - name: Push documentation # Deploy documentation only when on master if: github.ref == 'refs/heads/master' - run: ./ci/push_gh_pages.sh + run: | + . venv/bin/activate + ./ci/push_gh_pages.sh From d2e58b5d46237c5cbe12891b12ad0071f8a17f6e Mon Sep 17 00:00:00 2001 From: Lekcyjna <309016@uwr.edu.pl> Date: Sat, 14 Oct 2023 15:25:57 +0200 Subject: [PATCH 15/16] Update container path --- .github/workflows/benchmark.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 4dcc1ed0b..e4eafb402 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -14,7 +14,7 @@ jobs: name: Synthesis benchmarks runs-on: ubuntu-latest timeout-minutes: 40 - container: ghcr.io/kuznia-rdzeni/amaranth-synth-ecp5:2023.10.08_v + container: ghcr.io/kuznia-rdzeni/amaranth-synth:ecp5-3.11 steps: - uses: actions/checkout@v3 From 47df59f0f35be4c9ce1e51c27ef22cc6e1f7ae08 Mon Sep 17 00:00:00 2001 From: Lekcyjna <309016@uwr.edu.pl> Date: Sun, 15 Oct 2023 14:26:12 +0200 Subject: [PATCH 16/16] Change repository. --- .github/workflows/benchmark.yml | 2 +- .github/workflows/main.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index e4eafb402..c515414c2 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -63,7 +63,7 @@ jobs: build-perf-benchmarks: name: Build performance benchmarks runs-on: ubuntu-latest - container: ghcr.io/lekcyjna123/riscv-toolchain:2023.10.08_v + container: ghcr.io/kuznia-rdzeni/riscv-toolchain:2023.10.08_v steps: - name: Checkout uses: actions/checkout@v3 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9ba7073ec..957e2b1c5 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,7 +15,7 @@ jobs: build-regression-tests: name: Build regression tests runs-on: ubuntu-latest - container: ghcr.io/lekcyjna123/riscv-toolchain:2023.10.08_v + container: ghcr.io/kuznia-rdzeni/riscv-toolchain:2023.10.08_v steps: - name: Checkout uses: actions/checkout@v3