Skip to content

Commit 059ce9b

Browse files
committed
Sky130: Split dm into dm0,dm1,dm2
1 parent 0542dd1 commit 059ce9b

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

chipflow_lib/platforms/silicon.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from pprint import pformat
1111
from typing import TYPE_CHECKING, List
1212

13-
from amaranth import Module, Signal, ClockDomain, ClockSignal, ResetSignal, unsigned
13+
from amaranth import Module, Signal, ClockDomain, ClockSignal, ResetSignal, Value, unsigned
1414
from amaranth.lib import wiring, io, data
1515
from amaranth.lib.cdc import FFSynchronizer
1616
from amaranth.lib.wiring import Component, In, PureInterface
@@ -282,10 +282,16 @@ def __init__(self,
282282
dm = Sky130DriveMode(port_desc.iomodel['drive_mode'])
283283
else:
284284
dm = Sky130DriveMode.STRONG_UP_STRONG_DOWN
285-
dm_init = __class__._DriveMode_map[dm]
285+
dm_init = Value.cast(__class__._DriveMode_map[dm])
286286
dms_shape = data.ArrayLayout(unsigned(3), self._o.shape().width)
287-
self._dms = Signal(dms_shape, name=f"{self._name}$dm", init=[dm_init]*self._o.shape().width)
288-
self._signals.append((self._dms.as_value(), PortDirection.Output)) #type: ignore
287+
self._dms = Signal(dms_shape, name=f"{self._name}$dms", init=[dm_init]*self._o.shape().width)
288+
289+
self._dm0 = Signal(self._o.shape(), name=f"{self._name}$dm0", init=dm_init[0])
290+
self._dm1 = Signal(self._o.shape(), name=f"{self._name}$dm1", init=dm_init[1])
291+
self._dm2 = Signal(self._o.shape(), name=f"{self._name}$dm2", init=dm_init[2])
292+
self._signals.append((self._dm0, PortDirection.Output)) #type: ignore
293+
self._signals.append((self._dm1, PortDirection.Output)) #type: ignore
294+
self._signals.append((self._dm2, PortDirection.Output)) #type: ignore
289295
# Not enabled yet:
290296
self._gpio_slow_sel = None # Select slew rate
291297
self._gpio_holdover = None # Hold mode
@@ -304,6 +310,12 @@ def wire(self, m: Module, interface: PureInterface):
304310
if self._oe is not None:
305311
assert self._oe_n is not None
306312
m.d.comb += self._oe_n.eq(~self._oe)
313+
# wire up drive mode bits
314+
bit = 0
315+
for i in self._dms:
316+
m.d.comb += self._dm0[bit].eq(i[0]) # type: ignore
317+
m.d.comb += self._dm1[bit].eq(i[1]) # type: ignore
318+
m.d.comb += self._dm2[bit].eq(i[2]) # type: ignore
307319

308320
def instantiate_toplevel(self):
309321
ports = super().instantiate_toplevel()

0 commit comments

Comments
 (0)