Skip to content

Commit d3f0399

Browse files
committed
Make DriveMode sky130 specific for now
1 parent d114d4b commit d3f0399

File tree

4 files changed

+41
-34
lines changed

4 files changed

+41
-34
lines changed

chipflow_lib/platforms/__init__.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,16 @@
99
from .silicon import SiliconPlatformPort, SiliconPlatform
1010
from .sim import SimPlatform
1111
from ._utils import (
12-
IO_ANNOTATION_SCHEMA, IOSignature, IOModel, IODriveMode, IOTripPoint, IOModelOptions,
12+
IO_ANNOTATION_SCHEMA, IOSignature, IOModel, IOTripPoint, IOModelOptions,
1313
OutputIOSignature, InputIOSignature, BidirIOSignature,
1414
)
1515
from ._packages import PACKAGE_DEFINITIONS
16+
from ._sky130 import Sky130DriveMode
1617

1718
__all__ = ['IO_ANNOTATION_SCHEMA', 'IOSignature',
18-
'IOModel', 'IOModelOptions', 'IODriveMode', 'IOTripPoint',
19+
'IOModel', 'IOModelOptions', 'IOTripPoint',
1920
'OutputIOSignature', 'InputIOSignature', 'BidirIOSignature',
2021
'SiliconPlatformPort', 'SiliconPlatform',
2122
'SimPlatform',
23+
'Sky130DriveMode',
2224
'PACKAGE_DEFINITIONS']

chipflow_lib/platforms/_sky130.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from enum import StrEnum, auto
2+
3+
class Sky130DriveMode(StrEnum):
4+
"""
5+
Models the potential drive modes of an IO pad.
6+
Depending on process and cell library, these may be statically or dynamically configurable.
7+
8+
You will get an error if the option is not available with the chosen process and cell library
9+
"""
10+
# Strong pull-up, weak pull-down
11+
STRONG_UP_WEAK_DOWN = auto()
12+
# Weak pull-up, Strong pull-down
13+
WEAK_UP_STRONG_DOWN = auto()
14+
# Open drain with strong pull-down
15+
OPEN_DRAIN_STRONG_DOWN = auto()
16+
# Open drain-with strong pull-up
17+
OPEN_DRAIN_STRONG_UP= auto()
18+
# Strong pull-up, weak pull-down
19+
STRONG_UP_STRONG_DOWN = auto()
20+
# Weak pull-up, weak pull-down
21+
WEAK_UP_WEAK_DOWN = auto()

chipflow_lib/platforms/_utils.py

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
from .. import ChipFlowError, _ensure_chipflow_root, _get_cls_by_reference
3333
from .._appresponse import AppResponseModel, OmitIfNone
34+
from ._sky130 import Sky130DriveMode
3435

3536
if TYPE_CHECKING:
3637
from ..config_models import Config
@@ -58,6 +59,7 @@ class VoltageRange(AppResponseModel):
5859
max: Annotated[Optional[Voltage], OmitIfNone()] = None
5960
typical: Annotated[Optional[Voltage], OmitIfNone()] = None
6061

62+
6163
class IOTripPoint(StrEnum):
6264
"""
6365
Models various options for trip points for inputs.
@@ -74,27 +76,8 @@ class IOTripPoint(StrEnum):
7476
VCORE = auto()
7577
# CMOS level switching referenced to external reference voltage (e.g. low power mode)
7678
VREF = auto()
77-
78-
79-
class IODriveMode(StrEnum):
80-
"""
81-
Models the potential drive modes of an IO pad.
82-
Depending on process and cell library, these may be statically or dynamically configurable.
83-
84-
You will get an error if the option is not available with the chosen process and cell library
85-
"""
86-
# Strong pull-up, weak pull-down
87-
STRONG_UP_WEAK_DOWN = auto()
88-
# Weak pull-up, Strong pull-down
89-
WEAK_UP_STRONG_DOWN = auto()
90-
# Open drain with strong pull-down
91-
OPEN_DRAIN_STRONG_DOWN = auto()
92-
# Open drain-with strong pull-up
93-
OPEN_DRAIN_STRONG_UP= auto()
94-
# Strong pull-up, weak pull-down
95-
STRONG_UP_STRONG_DOWN = auto()
96-
# Weak pull-up, weak pull-down
97-
WEAK_UP_WEAK_DOWN = auto()
79+
# Schmitt trigger
80+
SCHMITT_TRIGGER = auto()
9881

9982

10083
IO_ANNOTATION_SCHEMA = str(_chipflow_schema_uri("pin-annotation", 0))
@@ -117,7 +100,7 @@ class IOModelOptions(TypedDict):
117100
clock_domain: the name of the I/O's clock domain (see `Amaranth.ClockDomain`). NB there is only one of these, so IO with multiple clocks must be split up.
118101
buffer_in: Should the IO pad have an input buffer?
119102
buffer_out: Should the IO pad have an output buffer?
120-
drive_mode: Drive mode for output
103+
sky130_drive_mode: Drive mode for output buffer on sky130
121104
trip_point: Trip Point configutation for input buffer
122105
init: The value for the initial values of the port
123106
init_oe: The value for the initial values of the output enable(s) of the port
@@ -128,7 +111,7 @@ class IOModelOptions(TypedDict):
128111
clock_domain: NotRequired[str]
129112
buffer_in: NotRequired[bool]
130113
buffer_out: NotRequired[bool]
131-
drive_mode: NotRequired[IODriveMode]
114+
sky130_drive_mode: NotRequired[Sky130DriveMode]
132115
trip_point: NotRequired[IOTripPoint]
133116
init: NotRequired[int | bool]
134117
init_oe: NotRequired[int | bool]

chipflow_lib/platforms/silicon.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
from amaranth.hdl._ir import PortDirection
2222

2323
from .. import ChipFlowError
24-
from ._utils import load_pinlock, PortDesc, Pin, IOModel, IODriveMode, IOTripPoint, Process
24+
from ._utils import load_pinlock, PortDesc, Pin, IOModel, IOTripPoint, Process
25+
from ._sky130 import Sky130DriveMode
2526

2627
if TYPE_CHECKING:
2728
from ..config_models import Config
@@ -198,17 +199,17 @@ class Sky130Port(SiliconPlatformPort):
198199

199200
_DriveMode_map = {
200201
# Strong pull-up, weak pull-down
201-
IODriveMode.STRONG_UP_WEAK_DOWN: 0b011,
202+
Sky130DriveMode.STRONG_UP_WEAK_DOWN: 0b011,
202203
# Weak pull-up, Strong pull-down
203-
IODriveMode.WEAK_UP_STRONG_DOWN: 0b010,
204+
Sky130DriveMode.WEAK_UP_STRONG_DOWN: 0b010,
204205
# Open drain with strong pull-down
205-
IODriveMode.OPEN_DRAIN_STRONG_DOWN: 0b100,
206+
Sky130DriveMode.OPEN_DRAIN_STRONG_DOWN: 0b100,
206207
# Open drain-with strong pull-up
207-
IODriveMode.OPEN_DRAIN_STRONG_UP: 0b101,
208+
Sky130DriveMode.OPEN_DRAIN_STRONG_UP: 0b101,
208209
# Strong pull-up, weak pull-down
209-
IODriveMode.STRONG_UP_STRONG_DOWN: 0b110,
210+
Sky130DriveMode.STRONG_UP_STRONG_DOWN: 0b110,
210211
# Weak pull-up, weak pull-down
211-
IODriveMode.WEAK_UP_WEAK_DOWN: 0b111
212+
Sky130DriveMode.WEAK_UP_WEAK_DOWN: 0b111
212213
}
213214

214215
_VTrip_map = {
@@ -265,9 +266,9 @@ def __init__(self,
265266
# Drive mode
266267
if self.direction in (io.Direction.Output, io.Direction.Bidir):
267268
if 'drive_mode' in port_desc.iomodel:
268-
dm = port_desc.iomodel['drive_mode']
269+
dm = Sky130DriveMode(port_desc.iomodel['drive_mode'])
269270
else:
270-
dm = IODriveMode.STRONG_UP_STRONG_DOWN
271+
dm = Sky130DriveMode.STRONG_UP_STRONG_DOWN
271272
dm_init = __class__._DriveMode_map[dm]
272273
self._gpio_dm = Signal(3, name=f"{self._name}$dm", init=dm_init)
273274
self._signals.append((self._gpio_dm, PortDirection.Output))

0 commit comments

Comments
 (0)