Skip to content

Test chipflow-test-socs as well as chipflow-examples #91

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
15 changes: 15 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,21 @@ jobs:
- name: Set up PDM
uses: pdm-project/setup-pdm@v4

- name: Generate overrides to use current branch if PR
if: github.event_name == 'pull_request'
run: |
pdm run tools/gen_overrides.py ${{github.head_ref}} > overrides.txt
echo "Generated overrides:"
cat overrides.txt

- name: Relock PDM
if: github.event_name != 'pull_request'
run: pdm lock -d

- name: Relock PDM (PR)
if: github.event_name == 'pull_request'
run: pdm lock -d --override overrides.txt

- name: Install dependencies
run: |
pdm install
Expand Down
123 changes: 73 additions & 50 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,25 @@ jobs:
steps:
- name: Check out source code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up PDM
uses: pdm-project/setup-pdm@v4

- name: Generate overrides to use current branch if PR
if: github.event_name == 'pull_request'
run: |
pdm run tools/gen_overrides.py ${{github.head_ref}} > overrides.txt
echo "Generated overrides:"
cat overrides.txt

- name: Relock PDM
if: github.event_name != 'pull_request'
run: pdm lock -d

- name: Relock PDM (PR)
if: github.event_name == 'pull_request'
run: pdm lock -d --override overrides.txt

- name: Install dependencies
run: |
pdm install
Expand All @@ -39,75 +54,83 @@ jobs:
with:
fetch-depth: 0
- name: Check source code licenses
run: |
docker run --platform=linux/amd64 -v ${PWD}:/src ghcr.io/google/addlicense -v -check -l BSD-2-Clause -c "ChipFlow" -s=only -ignore **/__init__.py **/*.py
run: ./tools/license_check.sh

test-submit:
runs-on: ubuntu-latest
strategy:
matrix:
dry: [true, false]
repo:
- name: "ChipFlow/chipflow-examples"
design: "minimal"
- name: "ChipFlow/chipflow-test-socs"
design: "sram"
env:
DRY: ${{ matrix.dry && '--dry-run' || '' }}
is_dry: ${{ matrix.dry && '(dry run)' || '' }}
our_path: "${{ github.workspace}}/${{ github.repo }}"
test_repo_path: "${{ github.workspace }}/${{ matrix.repo.name }}"

name: ${{ matrix.dry && 'Test Submit - Dry run' || 'Test submit' }}

steps:
- name: Check out source code
uses: actions/checkout@v4
with:
fetch-depth: 0
path: chipflow-lib
- name: Check out chipflow-examples
path: ${{ env.our_path }}

- name: Check out ${{ matrix.repo.name }}
uses: actions/checkout@v4
with:
repository: ChipFlow/chipflow-examples
fetch-depth: 0
path: chipflow-examples
repository: ${{ matrix.repo.name }}
path: ${{ env.test_repo_path }}

- name: Check for branch ${{ github.head_ref }}
working-directory: ${{ env.test_repo_path }}
if: github.event_name == 'pull_request'
run: |
git checkout ${{ github.head_ref }} || echo "Falling back to main"

- name: Set up PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: "3.10"
python-version: '3.10'
cache: true
cache-dependency-path: "./**/pyproject.toml"
- name: Install dependencies
working-directory: ./chipflow-examples
run: |
pdm install
pdm run python -m ensurepip
pdm run python -m pip install -e ../chipflow-lib
- name: Run tests
working-directory: ./chipflow-examples
cache-dependency-path: './**/pyproject.toml'

- name: Generate overrides to use current branch if PR
working-directory: ${{ env.test_repo_path }}
if: github.event_name == 'pull_request'
run: |
pdm test
pdm run chipflow pin lock
pdm run chipflow silicon submit --wait
env:
CHIPFLOW_API_KEY: ${{ secrets.CHIPFLOW_API_KEY}}
pdm run ${{env.our_path}}/tools/gen_overrides.py ${{github.head_ref}} > overrides.txt
echo "Generated overrides:"
cat overrides.txt

test-submit-dry:
runs-on: ubuntu-latest
steps:
- name: Check out source code
uses: actions/checkout@v4
with:
fetch-depth: 0
path: chipflow-lib
- name: Check out chipflow-examples
uses: actions/checkout@v4
with:
repository: ChipFlow/chipflow-examples
fetch-depth: 0
path: chipflow-examples
- name: Relock PDM
working-directory: ${{ env.test_repo_path }}
if: github.event_name != 'pull_request'
run: pdm lock -d

- name: Relock PDM (PR)
working-directory: ${{ env.test_repo_path }}
if: github.event_name == 'pull_request'
run: pdm lock -d --override overrides.txt

- name: Set up PDM
uses: pdm-project/setup-pdm@v4
with:
python-version: "3.10"
cache: true
cache-dependency-path: "./**/pyproject.toml"
- name: Install dependencies
working-directory: ./chipflow-examples
working-directory: ${{ env.test_repo_path }}
run: |
pdm install
pdm run python -m ensurepip
pdm run python -m pip install -e ../chipflow-lib

- name: Run tests
working-directory: ./chipflow-examples
working-directory: ${{ env.test_repo_path }}
run: |
pdm test

- name: Submit build ${{ env.is_dry }}
working-directory: ${{ env.test_repo_path }}/${{ matrix.repo.design }}
run: |
pdm run chipflow pin lock
pdm run chipflow silicon submit --dry-run
pdm run chipflow silicon submit --wait $DRY
env:
CHIPFLOW_API_KEY: ${{ secrets.CHIPFLOW_API_KEY}}
15 changes: 15 additions & 0 deletions .github/workflows/preview-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@ jobs:
python-version: 3.12
cache: true

- name: Generate overrides to use current branch if PR
if: github.event_name == 'pull_request'
run: |
pdm run tools/gen_overrides.py ${{github.head_ref}} > overrides.txt
echo "Generated overrides:"
cat overrides.txt

- name: Relock PDM
if: github.event_name != 'pull_request'
run: pdm lock -d

- name: Relock PDM (PR)
if: github.event_name == 'pull_request'
run: pdm lock -d --override overrides.txt

- name: Install dependencies
run: pdm install

Expand Down
4 changes: 2 additions & 2 deletions chipflow_lib/pin_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def allocate_pins(name: str, member: Dict[str, Any], pins: List[str], port_name:

if member['type'] == 'interface' and 'annotations' in member \
and PIN_ANNOTATION_SCHEMA in member['annotations']:
logger.debug("matched PinSignature {sig}")
logger.debug("matched IOSignature {sig}")
sig = member['annotations'][PIN_ANNOTATION_SCHEMA]
width = sig['width']
options = sig['options']
Expand All @@ -62,7 +62,7 @@ def allocate_pins(name: str, member: Dict[str, Any], pins: List[str], port_name:
logger.debug(f"{pin_map},{_map}")
return pin_map, pins
elif member['type'] == 'port':
logger.warning(f"Port '{name}' has no PinSignature, pin allocation likely to be wrong")
logger.warning(f"Port '{name}' has no IOSignature, pin allocation likely to be wrong")
width = member['width']
pin_map[name] = {'pins': pins[0:width],
'direction': member['dir'],
Expand Down
20 changes: 10 additions & 10 deletions chipflow_lib/platforms/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
from .. import ChipFlowError, _ensure_chipflow_root, _get_cls_by_reference


__all__ = ['PIN_ANNOTATION_SCHEMA', 'PinSignature',
'OutputPinSignature', 'InputPinSignature', 'BidirPinSignature',
__all__ = ['PIN_ANNOTATION_SCHEMA', 'IOSignature',
'OutputIOSignature', 'InputIOSignature', 'BidirIOSignature',
'load_pinlock', "PACKAGE_DEFINITIONS", 'top_interfaces']


Expand Down Expand Up @@ -64,7 +64,7 @@ def as_json(self): # type: ignore
PIN_ANNOTATION_SCHEMA = str(_chipflow_schema_uri("pin-annotation", 0))


class PinSignature(wiring.Signature):
class IOSignature(wiring.Signature):
"""Amaranth Signtaure used to decorate wires that would
usually be brought out onto a port on the package.

Expand Down Expand Up @@ -115,19 +115,19 @@ def annotations(self, *args):

def __repr__(self):
opts = ', '.join(f"{k}={v}" for k, v in self._options.items())
return f"PinSignature({self._direction}, {self._width}, {opts})"
return f"IOSignature({self._direction}, {self._width}, {opts})"


def OutputPinSignature(width, **kwargs):
return PinSignature(io.Direction.Output, width=width, **kwargs)
def OutputIOSignature(width, **kwargs):
return IOSignature(io.Direction.Output, width=width, **kwargs)


def InputPinSignature(width, **kwargs):
return PinSignature(io.Direction.Input, width=width, **kwargs)
def InputIOSignature(width, **kwargs):
return IOSignature(io.Direction.Input, width=width, **kwargs)


def BidirPinSignature(width, **kwargs):
return PinSignature(io.Direction.Bidir, width=width, **kwargs)
def BidirIOSignature(width, **kwargs):
return IOSignature(io.Direction.Bidir, width=width, **kwargs)


Pin = Union[tuple, str]
Expand Down
26 changes: 13 additions & 13 deletions tests/fixtures/mock_top.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@
from amaranth.lib import wiring
from amaranth.lib.wiring import In, Out

from chipflow_lib.platforms import InputPinSignature, OutputPinSignature, BidirPinSignature
from chipflow_lib.platforms import InputIOSignature, OutputIOSignature, BidirIOSignature

__all__ = ["MockTop"]

TestSignature1 = wiring.Signature({
"a": In(InputPinSignature(1)),
"b": In(InputPinSignature(5)),
"c": Out(OutputPinSignature(1)),
"d": Out(OutputPinSignature(10)),
"e": In(BidirPinSignature(1)),
"f": In(BidirPinSignature(7)),
"a": In(InputIOSignature(1)),
"b": In(InputIOSignature(5)),
"c": Out(OutputIOSignature(1)),
"d": Out(OutputIOSignature(10)),
"e": In(BidirIOSignature(1)),
"f": In(BidirIOSignature(7)),
})

TestSignature2 = wiring.Signature({
"a": Out(OutputPinSignature(1)),
"b": Out(OutputPinSignature(5)),
"c": In(InputPinSignature(1)),
"d": In(InputPinSignature(10)),
"e": Out(BidirPinSignature(1)),
"f": Out(BidirPinSignature(7)),
"a": Out(OutputIOSignature(1)),
"b": Out(OutputIOSignature(5)),
"c": In(InputIOSignature(1)),
"d": In(InputIOSignature(10)),
"e": Out(BidirIOSignature(1)),
"f": Out(BidirIOSignature(7)),
})


Expand Down
18 changes: 9 additions & 9 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from amaranth.lib import io

from chipflow_lib.platforms.utils import PinSignature, OutputPinSignature, InputPinSignature, BidirPinSignature, _PinAnnotation, _PinAnnotationModel
from chipflow_lib.platforms.utils import IOSignature, OutputIOSignature, InputIOSignature, BidirIOSignature, _PinAnnotation, _PinAnnotationModel
from chipflow_lib.platforms.utils import PinList, _group_consecutive_items,_find_contiguous_sequence, _Side


Expand Down Expand Up @@ -53,32 +53,32 @@ def test_find_contiguous_sequence():


def test_pin_signature():
sig_bidir = PinSignature(io.Direction.Bidir, width=8)
assert isinstance(sig_bidir, PinSignature)
sig_bidir = IOSignature(io.Direction.Bidir, width=8)
assert isinstance(sig_bidir, IOSignature)
assert sig_bidir._direction == io.Direction.Bidir
assert sig_bidir._width == 8
assert "o" in sig_bidir.members
assert "oe" in sig_bidir.members
assert "i" in sig_bidir.members

sig_output = OutputPinSignature(width=4)
assert isinstance(sig_output, PinSignature)
sig_output = OutputIOSignature(width=4)
assert isinstance(sig_output, IOSignature)
assert sig_output._direction == io.Direction.Output
assert sig_output._width == 4
assert "o" in sig_output.members
assert "oe" not in sig_output.members
assert "i" not in sig_output.members

sig_input = InputPinSignature(width=2)
assert isinstance(sig_input, PinSignature)
sig_input = InputIOSignature(width=2)
assert isinstance(sig_input, IOSignature)
assert sig_input._direction == io.Direction.Input
assert sig_input._width == 2
assert "o" not in sig_input.members
assert "oe" not in sig_output.members
assert "i" in sig_input.members

sig_bidir_fn = BidirPinSignature(width=1)
assert isinstance(sig_bidir_fn, PinSignature)
sig_bidir_fn = BidirIOSignature(width=1)
assert isinstance(sig_bidir_fn, IOSignature)
assert sig_bidir_fn._direction == io.Direction.Bidir
assert sig_bidir_fn._width == 1
assert "o" in sig_bidir_fn.members
Expand Down
Loading
Loading