2626from amaranth .lib .wiring import In , Out
2727from pydantic import (
2828 ConfigDict , TypeAdapter , PlainSerializer ,
29- WithJsonSchema , with_config
29+ WithJsonSchema
3030 )
3131
3232
3535if TYPE_CHECKING :
3636 from ..config_models import Config
3737
38- __all__ = ['IO_ANNOTATION_SCHEMA' , 'IOSignature' ,
38+ __all__ = ['IO_ANNOTATION_SCHEMA' , 'IOSignature' , 'IOModel' ,
3939 'OutputIOSignature' , 'InputIOSignature' , 'BidirIOSignature' ,
4040 'load_pinlock' , "PACKAGE_DEFINITIONS" , 'top_components' , 'LockFile' ,
41- 'Package' , 'PortMap' , 'Port' ,
42- 'GAPackageDef' , 'QuadPackageDef' , 'BareDiePackageDef' , 'BasePackageDef' ]
41+ 'Package' , 'PortMap' , 'Port' , 'Process' ,
42+ 'GAPackageDef' , 'QuadPackageDef' , 'BareDiePackageDef' , 'BasePackageDef' ,
43+ 'BringupPins' , 'JTAGPins' , 'PowerPins' ]
4344
4445
4546logger = logging .getLogger (__name__ )
@@ -73,7 +74,7 @@ class VoltageRange:
7374})
7475
7576
76- @with_config (ConfigDict (arbitrary_types_allowed = True )) # type: ignore[reportCallIssue]
77+ @pydantic . with_config (ConfigDict (arbitrary_types_allowed = True )) # type: ignore[reportCallIssue]
7778class _IOModelOptions (TypedDict ):
7879 all_have_oe : NotRequired [bool ]
7980 allocate_power : NotRequired [bool ]
@@ -83,7 +84,7 @@ class _IOModelOptions(TypedDict):
8384 init : NotRequired [Annotated [Const , ConstSerializer , ConstSchema ]]
8485
8586
86- @with_config (ConfigDict (arbitrary_types_allowed = True )) # type: ignore[reportCallIssue]
87+ @pydantic . with_config (ConfigDict (arbitrary_types_allowed = True )) # type: ignore[reportCallIssue]
8788class IOModel (_IOModelOptions ):
8889 """
8990 Options for IO Ports
@@ -305,6 +306,13 @@ def width(self):
305306 assert len (self .pins ) == self .iomodel ['width' ]
306307 return self .iomodel ['width' ]
307308
309+ @property
310+ def direction (self ):
311+ assert self .pins and 'direction' in self .iomodel
312+ assert len (self .pins ) == self .iomodel ['direction' ]
313+ return self .iomodel ['direction' ]
314+
315+
308316
309317def _group_consecutive_items (ordering : PinList , lst : PinList ) -> OrderedDict [int , List [PinList ]]:
310318 if not lst :
0 commit comments