Skip to content

Commit 7d71c83

Browse files
committed
Fix up packagepins on top of sim-common
1 parent 8eed660 commit 7d71c83

File tree

3 files changed

+27
-14
lines changed

3 files changed

+27
-14
lines changed

chipflow_lib/platforms/silicon.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,12 +278,14 @@ def instantiate_ports(self, m: Module):
278278
self._ports[port.port_name] = SiliconPlatformPort(component, name, port)
279279

280280
for clock in pinlock.port_map.get_clocks():
281-
setattr(m.domains, clock.port_name, ClockDomain(name=clock.port_name))
281+
domain = name=clock.iomodel['clock_domain_o']
282+
setattr(m.domains, domain, ClockDomain(name=domain))
282283
clk_buffer = io.Buffer("i", self._ports[clock.port_name])
283-
setattr(m.submodules, "clk_buffer_" + clock.port_name, clk_buffer)
284+
setattr(m.submodules, "clk_buffer_" + domain, clk_buffer)
284285
m.d.comb += ClockSignal().eq(clk_buffer.i) #type: ignore[reportAttributeAccessIssue]
285286

286287
for reset in pinlock.port_map.get_resets():
288+
domain = name=clock.iomodel['clock_domain_o']
287289
rst_buffer = io.Buffer("i", self._ports[reset.port_name])
288290
setattr(m.submodules, reset.port_name, rst_buffer)
289291
setattr(m.submodules, reset.port_name + "_sync", FFSynchronizer(rst_buffer.i, ResetSignal())) #type: ignore[reportAttributeAccessIssue]
@@ -326,7 +328,7 @@ def _check_clock_domains(self, fragment, sync_domain=None):
326328
for clock_domain in fragment.domains.values():
327329
if clock_domain.name != "sync" or (sync_domain is not None and
328330
clock_domain is not sync_domain):
329-
raise ChipFlowError("Only a single clock domain, called 'sync', may be used")
331+
raise ChipFlowError(f"Only a single clock domain, called 'sync', may be used: {clock_domain.name}")
330332
sync_domain = clock_domain
331333

332334
for subfragment, subfragment_name, src_loc in fragment.subfragments:

chipflow_lib/platforms/utils.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ def get_clocks(self) -> List[Port]:
502502
for cn, i in c.items():
503503
for ni, p in i.items():
504504
if p.type == "clock":
505-
ret.append(i)
505+
ret.append(p)
506506
return ret
507507

508508
def get_resets(self) -> List[Port]:
@@ -511,7 +511,7 @@ def get_resets(self) -> List[Port]:
511511
for cn, i in c.items():
512512
for ni, p in i.items():
513513
if p.type == "reset":
514-
ret.append(i)
514+
ret.append(p)
515515
return ret
516516

517517

@@ -616,12 +616,12 @@ def _allocate_bringup(self, config: 'Config') -> Component:
616616
d: Interface = { 'sync-clk': Port(type='clock',
617617
pins=[self.bringup_pins.core_clock],
618618
port_name='sync-clk',
619-
iomodel=IOModel(width=1, direction=io.Direction.Input)
619+
iomodel=IOModel(width=1, direction=io.Direction.Input, clock_domain_o="sync")
620620
),
621621
'sync-rst': Port(type='reset',
622622
pins=[self.bringup_pins.core_reset],
623623
port_name='sync-rst',
624-
iomodel=IOModel(width=1, direction=io.Direction.Input)
624+
iomodel=IOModel(width=1, direction=io.Direction.Input, clock_domain_o="sync")
625625
)
626626
}
627627
assert config.chipflow.silicon
@@ -630,7 +630,7 @@ def _allocate_bringup(self, config: 'Config') -> Component:
630630
d['heartbeat'] = Port(type='heartbeat',
631631
pins=[self.bringup_pins.core_heartbeat],
632632
port_name='heartbeat',
633-
iomodel=IOModel(width=1, direction=io.Direction.Output)
633+
iomodel=IOModel(width=1, direction=io.Direction.Output, clock_domain_i="sync")
634634
)
635635
#TODO: JTAG
636636
return {'bringup_pins': d}
@@ -1068,9 +1068,13 @@ def load_pinlock():
10681068
chipflow_root = _ensure_chipflow_root()
10691069
lockfile = pathlib.Path(chipflow_root, 'pins.lock')
10701070
if lockfile.exists():
1071-
json = lockfile.read_text()
1072-
return LockFile.model_validate_json(json)
1073-
raise ChipFlowError("Lockfile pins.lock not found. Run `chipflow pin lock`")
1071+
try:
1072+
json = lockfile.read_text()
1073+
return LockFile.model_validate_json(json)
1074+
except pydantic.ValidationError:
1075+
raise ChipFlowError("Lockfile `pins.lock` is misformed. Please remove and rerun chipflow pin lock`")
1076+
1077+
raise ChipFlowError("Lockfile `pins.lock` not found. Run `chipflow pin lock`")
10741078

10751079

10761080
def top_components(config):
@@ -1084,6 +1088,8 @@ def top_components(config):
10841088
param = name.split('.')[1]
10851089
logger.debug(f"Config {param} = {conf} found for {name}")
10861090
component_configs[param] = conf
1091+
if name.startswith('_'):
1092+
raise ChipFlowError(f"Top components cannot start with '_': {name}")
10871093

10881094
# Second pass: instantiate components
10891095
for name, ref in config.chipflow.top.items():

chipflow_lib/steps/silicon.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import subprocess
1111
import time
1212
import urllib3
13+
from pprint import pformat
1314

1415
import dotenv
1516

@@ -44,11 +45,15 @@ def elaborate(self, platform: SiliconPlatform):
4445

4546
top = top_components(self._config)
4647
logger.debug(f"SiliconTop top = {top}")
48+
logger.debug(f"port map ports =\n{pformat(platform.pinlock.port_map.ports)}")
4749

4850
for n, t in top.items():
4951
setattr(m.submodules, n, t)
5052

5153
for component, iface in platform.pinlock.port_map.ports.items():
54+
if component.startswith('_'):
55+
logger.debug(f"Ignoring special component {component}")
56+
continue
5257
for iface_name, member, in iface.items():
5358
for name, port in member.items():
5459
iface = getattr(top[component], iface_name)
@@ -121,14 +126,12 @@ def submit(self, rtlil_path, args):
121126
)
122127
self._chipflow_api_origin = os.environ.get("CHIPFLOW_API_ORIGIN", "https://build.chipflow.org")
123128

124-
assert self._chipflow_api_key
125-
assert self._chipflow_api_origin
126129

127130
with Halo(text="Submitting...", spinner="dots") as sp:
128131
fh = None
129132
submission_name = self.determine_submission_name()
130133
data = {
131-
"projectId": self.config.project_name,
134+
"projectId": self.config.chipflow.project_name,
132135
"name": submission_name,
133136
}
134137

@@ -178,6 +181,8 @@ def network_err(e):
178181

179182
build_submit_url = f"{self._chipflow_api_origin}/build/submit"
180183

184+
assert self._chipflow_api_key
185+
assert self._chipflow_api_origin
181186
try:
182187
resp = requests.post(
183188
build_submit_url,

0 commit comments

Comments
 (0)