Skip to content

Commit aa467e8

Browse files
committed
feat: Interface for determining power, clock, reset, jtag and heartbeat pins
1 parent 6649ec7 commit aa467e8

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

chipflow_lib/platforms/utils.py

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,16 @@ def BidirPinSignature(width, **kwargs):
125125
PinList = List[Pin]
126126
Pins = Union[PinSet, PinList]
127127

128+
class PowerPins(enum.Enum):
129+
POWER = "power"
130+
GROUND = "ground"
131+
132+
class JTAGPins(enum.Enum):
133+
TRST = "trst"
134+
TCK = "tck"
135+
TMS = "tms"
136+
TDI = "tdi"
137+
TDO = "tdo"
128138

129139
class _Side(enum.IntEnum):
130140
N = 1
@@ -217,18 +227,70 @@ class _BasePackageDef(pydantic.BaseModel, abc.ABC):
217227
@property
218228
@abc.abstractmethod
219229
def pins(self) -> PinSet:
230+
"Returns the full set of pins for the package"
220231
...
221232

222233
@abc.abstractmethod
223234
def allocate(self, available: PinSet, width: int) -> PinList:
235+
"""
236+
Allocates pins as close to each other as possible from available pins.
237+
238+
Args:
239+
available: set of available pins
240+
width: number of pins to allocate
241+
242+
Returns:
243+
An ordered list of pins
244+
"""
245+
...
246+
247+
@property
248+
@abc.abstractmethod
249+
def power(self) -> Dict[PowerType, Pin]:
250+
"""
251+
The set of power pins for the package
252+
"""
253+
...
254+
255+
@property
256+
@abc.abstractmethod
257+
def resets(self) -> Dict[int, Pin]:
258+
"""
259+
Numbered set of reset pins for the package
260+
"""
224261
...
225262

263+
@property
264+
@abc.abstractmethod
265+
def clocks(self) -> Dict[int, Pin]:
266+
"""
267+
Numbered set of clock pins for the package
268+
"""
269+
...
270+
271+
@property
272+
@abc.abstractmethod
273+
def jtag(self) -> Dict[JTAGPin, Pin]:
274+
"""
275+
Map of JTAG pins for the package
276+
"""
277+
...
278+
279+
@property
280+
@abc.abstractmethod
281+
def heartbeat(self) -> Dict(int, Pin):
282+
"""
283+
Numbered set of heartbeat pins for the package
284+
"""
285+
226286
def to_string(pins: Pins):
227287
return [''.join(map(str, t)) for t in pins]
228288

229289
def sortpins(self, pins: Pins) -> PinList:
230290
return list(pins).sort()
231291

292+
293+
232294

233295
class _BareDiePackageDef(_BasePackageDef):
234296
"""Definition of a package with pins on four sides, labelled north, south, east, west

0 commit comments

Comments
 (0)