Skip to content

Commit 5280d73

Browse files
committed
Changes to support picosoc with custom Verilog
Signed-off-by: gatecat <gatecat@ds0.me>
1 parent 1f43de9 commit 5280d73

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

chipflow_lib/platforms/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
from ._sky130 import Sky130DriveMode
1818
from ._signatures import (
1919
JTAGSignature, SPISignature, I2CSignature, UARTSignature, GPIOSignature, QSPIFlashSignature,
20-
attach_data, SoftwareDriverSignature, SoftwareBuild
20+
attach_data, SoftwareDriverSignature, SoftwareBuild, BinaryData
2121
)
2222

23-
__all__ = ['IO_ANNOTATION_SCHEMA', 'IOSignature',
23+
__all__ = ['BinaryData', 'IO_ANNOTATION_SCHEMA', 'IOSignature',
2424
'IOModel', 'IOModelOptions', 'IOTripPoint',
2525
'OutputIOSignature', 'InputIOSignature', 'BidirIOSignature',
2626
'SiliconPlatformPort', 'SiliconPlatform',

chipflow_lib/platforms/_signatures.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,23 @@ def __init__(self, *, sources: list[Path], includes: list[Path] = [], include_di
5656
self.include_dirs = list(include_dirs)
5757
self.offset = offset
5858

59+
@dataclass
60+
class BinaryData:
61+
"""
62+
This holds the information needed for building software and providing the built outcome
63+
"""
64+
offset: int
65+
filename: Path
66+
build_dir: Path
67+
type: Literal["BinaryData"] = "BinaryData"
68+
69+
def __init__(self, *, filename: Path, offset=0):
70+
self.build_dir = _ensure_chipflow_root() / 'build' / 'software'
71+
if Path(filename).is_absolute():
72+
self.filename = filename
73+
else:
74+
self.filename = self.build_dir / filename
75+
self.offset = offset
5976

6077
_T_DataClass = TypeVar('_T_DataClass', bound=DataclassProtocol)
6178
class Data(TypedDict, Generic[_T_DataClass]):
@@ -204,8 +221,9 @@ def __chipflow_parameters__(self):
204221

205222
def attach_data(external_interface: wiring.PureInterface, component: wiring.Component, data: DataclassProtocol):
206223
data_dict: Data = {'data':data}
207-
setattr(component.signature, '__chipflow_data__', data_dict)
208-
amaranth_annotate(Data, DATA_SCHEMA, '__chipflow_data__', decorate_object=True)(component.signature)
224+
if component is not None:
225+
setattr(component.signature, '__chipflow_data__', data_dict)
226+
amaranth_annotate(Data, DATA_SCHEMA, '__chipflow_data__', decorate_object=True)(component.signature)
209227
setattr(external_interface.signature, '__chipflow_data__', data_dict)
210228
amaranth_annotate(Data, DATA_SCHEMA, '__chipflow_data__', decorate_object=True)(external_interface.signature)
211229

chipflow_lib/platforms/sim.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
from .. import ChipFlowError, _ensure_chipflow_root
2222
from ._signatures import (
2323
I2CSignature, GPIOSignature, UARTSignature, SPISignature, QSPIFlashSignature,
24-
SIM_ANNOTATION_SCHEMA, DATA_SCHEMA, SimInterface, SoftwareBuild
24+
SIM_ANNOTATION_SCHEMA, DATA_SCHEMA, SimInterface, SoftwareBuild, BinaryData
2525
)
2626
from ._utils import load_pinlock, Interface
2727

@@ -220,6 +220,10 @@ def build(self, e, top):
220220
and annotations[DATA_SCHEMA]['data']['type'] == "SoftwareBuild":
221221
sim_data[interface] = TypeAdapter(SoftwareBuild).validate_python(annotations[DATA_SCHEMA]['data'])
222222

223+
if DATA_SCHEMA in annotations \
224+
and annotations[DATA_SCHEMA]['data']['type'] == "BinaryData":
225+
sim_data[interface] = TypeAdapter(BinaryData).validate_python(annotations[DATA_SCHEMA]['data'])
226+
223227
data_load = []
224228
for i,d in sim_data.items():
225229
args = [f"0x{d.offset:X}U"]

0 commit comments

Comments
 (0)