Skip to content

Commit 97182a6

Browse files
committed
wip
1 parent bcb1bfc commit 97182a6

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

chipflow_lib/platforms/_signatures.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from amaranth.lib import wiring
77
from amaranth.lib.wiring import Out
88

9+
from .. import ChipFlowError
910
from ._utils import InputIOSignature, OutputIOSignature, BidirIOSignature, IOModelOptions, _chipflow_schema_uri, amaranth_annotate
1011

1112
SIM_ANNOTATION_SCHEMA = str(_chipflow_schema_uri("sim-interface", 0))
@@ -101,3 +102,17 @@ def __chipflow_parameters__(self):
101102

102103
def __repr__(self) -> str:
103104
return f"GPIOSignature(pin_count={self._pin_count}, {dict(self.members.items())})"
105+
106+
107+
class SimulationCanLoadData:
108+
"""
109+
Inherit from this in your object's Signature if you want a simulation model
110+
to be able to load data from your object
111+
"""
112+
@classmethod
113+
def __init_submodule__(cls, /, *args, **kwargs):
114+
if wiring.Signature not in cls.mro():
115+
raise ChipFlowError("SimulationCanLoadData can only be used with ``wiring.Signature`` classes")
116+
original_annotations = getattr(cls, 'annotations')
117+
#def annotations(self, obj, /):
118+
#cls.annotate

chipflow_lib/platforms/_utils.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,13 @@ def origin(self): # type: ignore
156156
def as_json(self): # type: ignore
157157
return PydanticModel.dump_python(self.__chipflow_annotation__)
158158

159-
def annotations(self, *args): # type: ignore
160-
annotations = wiring.Signature.annotations(self, *args) # type: ignore
161-
annotation = Annotation(self.__chipflow_annotation__)
162-
return annotations + (annotation,) # type: ignore
163-
164159
def decorator(klass):
160+
def annotations(self, *args): # type: ignore
161+
annotations = super(klass, self).annotations(*args) # type: ignore
162+
annotation = Annotation(self.__chipflow_annotation__)
163+
return annotations + (annotation,) # type: ignore
164+
165+
165166
klass.annotations = annotations
166167
return klass
167168
return decorator

0 commit comments

Comments
 (0)