Skip to content
Merged
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
93 changes: 50 additions & 43 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@ jobs:
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 +55,66 @@ 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]
env:
DRY: ${{ matrix.dry && '--dry-run' || '' }}
IS_DRY: ${{ matrix.dry && '(dry run)' || '' }}
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
uses: actions/checkout@v4
with:
repository: ChipFlow/chipflow-examples
fetch-depth: 0
path: chipflow-examples
ref: ${{ github.head_ref || 'refs/heads/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
cache-dependency-path: './**/pyproject.toml'

- name: Generate overrides to use current branch if PR
working-directory: ./chipflow-examples
if: github.event_name == 'pull_request'
run: |
pdm install
pdm run python -m ensurepip
pdm run python -m pip install -e ../chipflow-lib
- name: Run tests
pdm run tools/gen_overrides.py ${{github.head_ref}} > overrides.txt
echo "Generated overrides:"
cat overrides.txt

- name: Relock PDM
working-directory: ./chipflow-examples
run: |
pdm test
pdm run chipflow pin lock
pdm run chipflow silicon submit --wait
env:
CHIPFLOW_API_KEY: ${{ secrets.CHIPFLOW_API_KEY}}
if: github.event_name != 'pull_request'
run: pdm lock -d

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 (PR)
working-directory: ./chipflow-examples
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
run: |
pdm install
pdm run python -m ensurepip
pdm run python -m pip install -e ../chipflow-lib

- name: Run tests
working-directory: ./chipflow-examples
run: |
pdm test

- name: Submit build ${{ env.is_dry }}
working-directory: ./chipflow-examples/minimal
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
14 changes: 7 additions & 7 deletions tests/test_utils_additional.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
_PinAnnotationModel,
_PinAnnotation,
PIN_ANNOTATION_SCHEMA,
PinSignature,
IOSignature,
_Side,
_BasePackageDef,
_BareDiePackageDef,
Expand Down Expand Up @@ -69,12 +69,12 @@ def test_pin_annotation(self):
self.assertEqual(json_data["options"], {})


class TestPinSignature(unittest.TestCase):
class TestIOSignature(unittest.TestCase):
def test_pin_signature_properties(self):
"""Test PinSignature properties"""
"""Test IOSignature properties"""
# Create signature with options
options = {"all_have_oe": True, "init": 0}
sig = PinSignature(io.Direction.Bidir, width=4, all_have_oe=True, init=0)
sig = IOSignature(io.Direction.Bidir, width=4, all_have_oe=True, init=0)

# Test properties
self.assertEqual(sig.direction, io.Direction.Bidir)
Expand All @@ -83,15 +83,15 @@ def test_pin_signature_properties(self):

# Test __repr__ - actual representation depends on Direction enum's representation
repr_string = repr(sig)
self.assertIn("PinSignature", repr_string)
self.assertIn("IOSignature", repr_string)
self.assertIn("4", repr_string)
self.assertIn("all_have_oe=True", repr_string)
self.assertIn("init=0", repr_string)

def test_pin_signature_annotations(self):
"""Test PinSignature annotations method"""
"""Test IOSignature annotations method"""
# Create signature
sig = PinSignature(io.Direction.Output, width=8, init=42)
sig = IOSignature(io.Direction.Output, width=8, init=42)

# Create a mock object to pass to annotations
mock_obj = object()
Expand Down
Loading
Loading