Skip to content

Commit

Permalink
Merge branch 'master' into piotro888/riscof
Browse files Browse the repository at this point in the history
  • Loading branch information
piotro888 committed Oct 28, 2023
2 parents fdac4fd + fc8c9b9 commit 202512b
Show file tree
Hide file tree
Showing 38 changed files with 1,390 additions and 1,289 deletions.
34 changes: 27 additions & 7 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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-3.11
steps:
- uses: actions/checkout@v3

Expand All @@ -23,19 +23,29 @@ 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'

- name: Install dependencies
run: |
python3 -m venv venv
. venv/bin/activate
python3 -m pip install --upgrade pip
pip3 install -r requirements-dev.txt
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
Expand All @@ -53,7 +63,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/kuznia-rdzeni/riscv-toolchain:2023.10.08_v
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -73,7 +83,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
Expand All @@ -84,13 +94,22 @@ 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'

- name: Install dependencies
run: |
python3 -m venv venv
. venv/bin/activate
python3 -m pip install --upgrade pip
pip3 install -r requirements-dev.txt
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:
Expand All @@ -99,6 +118,7 @@ jobs:

- name: Run benchmarks
run: |
. venv/bin/activate
scripts/run_benchmarks.py
- name: Store benchmark result (IPC)
Expand Down
18 changes: 10 additions & 8 deletions .github/workflows/deploy_gh_pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,23 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: "pip"
cache-dependency-path: |
requirements.txt
requirements-dev.txt
python-version: "3.11"

- name: Install dependencies
run: |
python3 -m venv venv
. venv/bin/activate
python -m pip install --upgrade pip
pip3 install -r requirements-dev.txt
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
22 changes: 16 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/kuznia-rdzeni/riscv-toolchain:2023.10.08_v
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -35,19 +35,28 @@ 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
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install dependencies
run: |
python3 -m venv venv
. venv/bin/activate
python3 -m pip install --upgrade pip
pip3 install -r requirements-dev.txt
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:
Expand All @@ -56,6 +65,7 @@ jobs:

- name: Run tests
run: |
. venv/bin/activate
scripts/run_tests.py -a regression
- name: Test Report
Expand All @@ -76,7 +86,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
Expand Down Expand Up @@ -105,7 +115,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
Expand Down
8 changes: 5 additions & 3 deletions constants/ecp5_platforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from constants.ecp5_pinout import ecp5_bg756_pins, ecp5_bg756_pclk

from coreblocks.peripherals.wishbone import WishboneParameters
from coreblocks.transactions.lib import AdapterBase
from transactron.lib import AdapterBase

__all__ = ["make_ecp5_platform"]

Expand Down Expand Up @@ -55,11 +55,12 @@ def __init__(self, pins: Iterable[str]):
def p(self, count: int = 1):
return " ".join([self.pin_bag.pop() for _ in range(count)])

def named_pin(self, names: list[str]):
def named_pin(self, names: Iterable[str]):
for name in names:
if name in self.pin_bag:
self.pin_bag.remove(name)
return name
raise RuntimeError("Named pins %s not free" % ", ".join(names))


ResourceBuilder: TypeAlias = Callable[[PinManager], list[Resource]]
Expand Down Expand Up @@ -123,9 +124,10 @@ class ECP5BG756Platform(LatticeECP5Platform):
default_clk = "clk"
default_rst = "rst"

clk_pin = pins.named_pin(ecp5_bg756_pclk)
resources = [
Resource("rst", 0, PinsN(pins.p(), dir="i"), Attrs(IO_TYPE="LVCMOS33")),
Resource("clk", 0, Pins(pins.named_pin(ecp5_bg756_pclk), dir="i"), Clock(12e6), Attrs(IO_TYPE="LVCMOS33")),
Resource("clk", 0, Pins(clk_pin, dir="i"), Clock(12e6), Attrs(IO_TYPE="LVCMOS33")),
] + resource_builder(pins)

connectors = []
Expand Down
4 changes: 2 additions & 2 deletions coreblocks/fu/div_unit.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from dataclasses import KW_ONLY, dataclass
from enum import IntFlag, auto
from typing import Sequence, Tuple
from collections.abc import Sequence

from amaranth import *

Expand Down Expand Up @@ -34,7 +34,7 @@ def get_instructions(self) -> Sequence[tuple]:
]


def get_input(arg: Record) -> Tuple[Value, Value]:
def get_input(arg: Record) -> tuple[Value, Value]:
return arg.s1_val, Mux(arg.imm, arg.imm, arg.s2_val)


Expand Down
6 changes: 3 additions & 3 deletions coreblocks/fu/mul_unit.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from enum import IntFlag, IntEnum, auto
from typing import Sequence, Tuple
from collections.abc import Sequence
from dataclasses import KW_ONLY, dataclass

from amaranth import *
Expand Down Expand Up @@ -45,7 +45,7 @@ def get_instructions(self) -> Sequence[tuple]:
]


def get_input(arg: Record) -> Tuple[Value, Value]:
def get_input(arg: Record) -> tuple[Value, Value]:
"""
Operation of getting two input values.
Expand All @@ -56,7 +56,7 @@ def get_input(arg: Record) -> Tuple[Value, Value]:
Returns
-------
return : Tuple[Value, Value]
return : tuple[Value, Value]
Two input values.
"""
return arg.s1_val, Mux(arg.imm, arg.imm, arg.s2_val)
Expand Down
3 changes: 2 additions & 1 deletion coreblocks/params/keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
from typing import TYPE_CHECKING

from coreblocks.params.dependencies import SimpleKey, UnifierKey
from transactron.lib import MethodTryProduct, Collector, Method
from transactron import Method
from transactron.lib import MethodTryProduct, Collector
from coreblocks.peripherals.wishbone import WishboneMaster

if TYPE_CHECKING:
Expand Down
2 changes: 1 addition & 1 deletion coreblocks/scheduler/scheduler.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Sequence
from collections.abc import Sequence

from amaranth import *

Expand Down
2 changes: 1 addition & 1 deletion coreblocks/stages/func_blocks_unifier.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Iterable
from collections.abc import Iterable

from amaranth import *

Expand Down
3 changes: 2 additions & 1 deletion coreblocks/structs_common/rs.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Iterable, Optional
from collections.abc import Iterable
from typing import Optional
from amaranth import *
from amaranth.lib.coding import PriorityEncoder
from transactron import Method, def_method, TModule
Expand Down
38 changes: 19 additions & 19 deletions coreblocks/utils/_typing.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
from typing import (
ContextManager,
Generic,
NoReturn,
Optional,
Protocol,
Sequence,
Tuple,
Type,
TypeAlias,
Iterable,
Mapping,
TypeVar,
runtime_checkable,
)
from collections.abc import Iterable, Mapping, Sequence
from contextlib import AbstractContextManager
from enum import Enum
from amaranth import *
from amaranth.lib.data import View
Expand All @@ -21,16 +17,18 @@
from amaranth.hdl.rec import Direction, Layout

# Types representing Amaranth concepts
FragmentLike = Fragment | Elaboratable
ValueLike = Value | int | Enum | ValueCastable
ShapeLike = Shape | ShapeCastable | int | range | Type[Enum]
FragmentLike: TypeAlias = Fragment | Elaboratable
ValueLike: TypeAlias = Value | int | Enum | ValueCastable
ShapeLike: TypeAlias = Shape | ShapeCastable | int | range | type[Enum]
StatementLike: TypeAlias = Statement | Iterable["StatementLike"]
LayoutLike = Layout | Sequence[Tuple[str, ShapeLike | "LayoutLike"] | Tuple[str, ShapeLike | "LayoutLike", Direction]]
LayoutLike: TypeAlias = (
Layout | Sequence[tuple[str, "ShapeLike | LayoutLike"] | tuple[str, "ShapeLike | LayoutLike", Direction]]
)
SwitchKey: TypeAlias = str | int | Enum

# Internal Coreblocks types
SignalBundle: TypeAlias = Signal | Record | View | Iterable["SignalBundle"] | Mapping[str, "SignalBundle"]
LayoutList = list[Tuple[str, ShapeLike | "LayoutList"]]
LayoutList: TypeAlias = list[tuple[str, "ShapeLike | LayoutList"]]


class _ModuleBuilderDomainsLike(Protocol):
Expand All @@ -55,28 +53,30 @@ class ModuleLike(Protocol, Generic[_T_ModuleBuilderDomains]):
domains: _ModuleBuilderDomainSet
d: _T_ModuleBuilderDomains

def If(self, cond: ValueLike) -> ContextManager[None]: # noqa: N802
def If(self, cond: ValueLike) -> AbstractContextManager[None]: # noqa: N802
...

def Elif(self, cond: ValueLike) -> ContextManager[None]: # noqa: N802
def Elif(self, cond: ValueLike) -> AbstractContextManager[None]: # noqa: N802
...

def Else(self) -> ContextManager[None]: # noqa: N802
def Else(self) -> AbstractContextManager[None]: # noqa: N802
...

def Switch(self, test: ValueLike) -> ContextManager[None]: # noqa: N802
def Switch(self, test: ValueLike) -> AbstractContextManager[None]: # noqa: N802
...

def Case(self, *patterns: SwitchKey) -> ContextManager[None]: # noqa: N802
def Case(self, *patterns: SwitchKey) -> AbstractContextManager[None]: # noqa: N802
...

def Default(self) -> ContextManager[None]: # noqa: N802
def Default(self) -> AbstractContextManager[None]: # noqa: N802
...

def FSM(self, reset: Optional[str] = ..., domain: str = ..., name: str = ...) -> ContextManager[FSM]: # noqa: N802
def FSM( # noqa: N802
self, reset: Optional[str] = ..., domain: str = ..., name: str = ...
) -> AbstractContextManager[FSM]:
...

def State(self, name: str) -> ContextManager[None]: # noqa: N802
def State(self, name: str) -> AbstractContextManager[None]: # noqa: N802
...

@property
Expand Down
3 changes: 2 additions & 1 deletion coreblocks/utils/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from contextlib import contextmanager
from enum import Enum
from typing import Iterable, Literal, Mapping, Optional, TypeAlias, cast, overload
from typing import Literal, Optional, TypeAlias, cast, overload
from collections.abc import Iterable, Mapping
from amaranth import *
from amaranth.hdl.ast import Assign, ArrayProxy
from amaranth.lib import data
Expand Down
Loading

0 comments on commit 202512b

Please sign in to comment.