Skip to content

Commit 1b3b3da

Browse files
robtaylorclaude
andcommitted
Phase 6 (Part 2): Update imports in remaining platform modules
Updated imports in all platform modules to use new structure: - sim.py: Updated to import from .io.signatures and ..packaging - sim_step.py: Updated to import from .base, .utils, .sim - software.py: Updated to import from .io.signatures, .io.annotate - software_step.py: Updated to import from .base, .software, .utils - board_step.py: Updated to import from .base - platform/__init__.py: Added exports for sim, software, board modules All platform modules now use correct internal imports. Ready for backward compatibility shims. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 2c8c9df commit 1b3b3da

File tree

6 files changed

+40
-30
lines changed

6 files changed

+40
-30
lines changed

chipflow_lib/platform/__init__.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010
from .silicon import SiliconPlatformPort, SiliconPlatform
1111
from .silicon_step import SiliconStep, SiliconTop
1212

13-
# Simulation platform (will be added)
14-
# from .sim import SimPlatform
15-
# from .sim_step import SimStep
13+
# Simulation platform
14+
from .sim import SimPlatform, BasicCxxBuilder
15+
from .sim_step import SimStep
1616

17-
# Software platform (will be added)
18-
# from .software import SoftwarePlatform
19-
# from .software_step import SoftwareStep
17+
# Software platform
18+
from .software import SoftwarePlatform
19+
from .software_step import SoftwareStep
2020

21-
# Board step (will be added)
22-
# from .board_step import BoardStep
21+
# Board step
22+
from .board_step import BoardStep
2323

2424
# IO signatures and utilities
2525
from .io import (
@@ -40,6 +40,15 @@
4040
'SiliconPlatform',
4141
'SiliconStep',
4242
'SiliconTop',
43+
# Simulation
44+
'SimPlatform',
45+
'BasicCxxBuilder',
46+
'SimStep',
47+
# Software
48+
'SoftwarePlatform',
49+
'SoftwareStep',
50+
# Board
51+
'BoardStep',
4352
# IO
4453
'IO_ANNOTATION_SCHEMA',
4554
'IOSignature',

chipflow_lib/platform/board_step.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# SPDX-License-Identifier: BSD-2-Clause
2-
from . import StepBase, setup_amaranth_tools
2+
from .base import StepBase, setup_amaranth_tools
33

44
class BoardStep(StepBase):
55
"""Build the design for a board."""

chipflow_lib/platform/sim.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
from jinja2 import Environment, PackageLoader, select_autoescape
1919
from pydantic import BaseModel, TypeAdapter
2020

21-
from .. import ChipFlowError, _ensure_chipflow_root
22-
from ._signatures import (
21+
from ..utils import ChipFlowError, ensure_chipflow_root
22+
from .io.signatures import (
2323
I2CSignature, GPIOSignature, UARTSignature, SPISignature, QSPIFlashSignature,
2424
SIM_ANNOTATION_SCHEMA, DATA_SCHEMA, SimInterface, SoftwareBuild
2525
)
26-
from ._utils import load_pinlock, Interface
26+
from ..packaging import load_pinlock, Interface
2727

2828

2929
logger = logging.getLogger(__name__)
@@ -153,7 +153,7 @@ def find_builder(builders: List[BasicCxxBuilder], sim_interface: SimInterface):
153153

154154
class SimPlatform:
155155
def __init__(self, config):
156-
self.build_dir = _ensure_chipflow_root() / 'build' / 'sim'
156+
self.build_dir = ensure_chipflow_root() / 'build' / 'sim'
157157
self.extra_files = dict()
158158
self.sim_boxes = dict()
159159
self._ports: Dict[str, io.SimulationPort] = {}
@@ -225,7 +225,7 @@ def build(self, e, top):
225225
args = [f"0x{d.offset:X}U"]
226226
p = d.filename
227227
if not p.is_absolute():
228-
p = _ensure_chipflow_root() / p
228+
p = ensure_chipflow_root() / p
229229
data_load.append({'model_name': i, 'file_name': p, 'args': args})
230230

231231

chipflow_lib/platform/sim_step.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,13 @@
1212

1313
from amaranth import Module
1414

15-
from . import StepBase, _wire_up_ports
16-
from ._json_compare import compare_events
17-
from .. import ChipFlowError, _ensure_chipflow_root
15+
from .base import StepBase, _wire_up_ports
16+
from .utils import top_components
17+
from .sim import VARIABLES, TASKS, DOIT_CONFIG, SimPlatform
18+
from ..steps._json_compare import compare_events
19+
from ..utils import ChipFlowError, ensure_chipflow_root
1820
from ..cli import run
19-
from ..platforms._utils import top_components, load_pinlock
20-
from ..platforms.sim import VARIABLES, TASKS, DOIT_CONFIG, SimPlatform
21+
from ..packaging import load_pinlock
2122

2223

2324
EXE = ".exe" if os.name == "nt" else ""
@@ -92,7 +93,7 @@ def run_cli(self, args):
9293

9394
@property
9495
def sim_dir(self):
95-
return _ensure_chipflow_root() / 'build' / 'sim'
96+
return ensure_chipflow_root() / 'build' / 'sim'
9697

9798
def build(self, *args):
9899
"""
@@ -120,8 +121,8 @@ def build(self, *args):
120121
context = {
121122
"COMMON_DIR": common_dir,
122123
"RUNTIME_DIR": runtime_dir,
123-
"PROJECT_ROOT": _ensure_chipflow_root(),
124-
"BUILD_DIR": _ensure_chipflow_root() / 'build',
124+
"PROJECT_ROOT": ensure_chipflow_root(),
125+
"BUILD_DIR": ensure_chipflow_root() / 'build',
125126
"EXE": EXE,
126127
}
127128
for k,v in VARIABLES.items():

chipflow_lib/platform/software.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
from amaranth_soc.wishbone.sram import WishboneSRAM
1212
from pydantic import TypeAdapter
1313

14-
from .. import ChipFlowError
15-
from ._signatures import DRIVER_MODEL_SCHEMA, DriverModel, DATA_SCHEMA, SoftwareBuild
16-
from ._annotate import submodule_metadata
14+
from ..utils import ChipFlowError
15+
from .io.signatures import DRIVER_MODEL_SCHEMA, DriverModel, DATA_SCHEMA, SoftwareBuild
16+
from .io.annotate import submodule_metadata
1717
from ..software.soft_gen import SoftwareGenerator
1818

1919

chipflow_lib/platform/software_step.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
from doit.doit_cmd import DoitMain
77
from amaranth import Module
88

9-
from . import StepBase
10-
from .. import ChipFlowError
11-
from ..platforms._software import SoftwarePlatform
12-
from ..platforms._utils import top_components
9+
from .base import StepBase
10+
from .software import SoftwarePlatform
11+
from .utils import top_components
12+
from ..utils import ChipFlowError
1313

1414
logger = logging.getLogger(__name__)
1515

@@ -42,7 +42,7 @@ def build(self, *args):
4242

4343
generators = self._platform.build(m, top)
4444

45-
from ..platforms import software_build
45+
from . import software_build
4646
for name, gen in generators.items():
4747
loader = ModuleTaskLoader(software_build)
4848
loader.task_opts = {"build_software": {"generator": gen}, "build_software_elf": {'generator': gen}} #type: ignore

0 commit comments

Comments
 (0)