@@ -172,14 +172,22 @@ def _to_set(self) -> Set[Pin]:
172172 set ([self .core_clock , self .core_reset , self .core_heartbeat ]) | \
173173 self .core_jtag ._to_set ()
174174
175+ class PadPowerDomain (pydantic .BaseModel ):
176+ io : str
177+ internal : str
175178
176- class Port (AppResponseModel ):
179+ class PadPowerDomains (StrEnum ):
180+ IO = 'io'
181+ INTERNAL = 'internal'
182+
183+ class PortModel (AppResponseModel ):
184+ "Configuration information for a platform port"
177185 type : str
178186 pins : List [Pin ] | None # None implies must be allocated at end
179187 port_name : str
180188 iomodel : IOModel
181189 power_allocation : Dict [InterfacePowerDomainName , PowerDomainName ] = {}
182- power_domain : Annotated [Optional [str ] , OmitIfNone ()] = None
190+ pad_power_domains : Annotated [Optional [PadPowerDomain , OmitIfNone ()] ] = None
183191
184192 def model_post_init (self , __context ):
185193 logger .debug (f"Instantiating port { self .port_name } : { self } " )
@@ -219,7 +227,7 @@ def interface_power_domains(self) -> List[str]:
219227 return []
220228
221229
222- Interface = OrderedDict [str , Port ]
230+ Interface = OrderedDict [str , PortModel ]
223231Component = OrderedDict [str , Interface ]
224232AllocateFunc = Callable [[PinSet , int ], PinList ]
225233
@@ -235,7 +243,7 @@ def create_ports(name: str, member: Dict[str, Any], port_name: str) -> Interface
235243 and IO_ANNOTATION_SCHEMA in member ['annotations' ]:
236244 model :IOModel = member ['annotations' ][IO_ANNOTATION_SCHEMA ]
237245 logger .debug (f"matched IOSignature { model } " )
238- pin_map [name ] = Port (type = 'io' , port_name = port_name , iomodel = model , pins = None )
246+ pin_map [name ] = PortModel (type = 'io' , port_name = port_name , iomodel = model , pins = None )
239247 logger .debug (f"added '{ name } ':{ pin_map [name ]} to pin_map" )
240248 return pin_map
241249 elif member ['type' ] == 'interface' :
@@ -246,10 +254,10 @@ def create_ports(name: str, member: Dict[str, Any], port_name: str) -> Interface
246254 logger .debug (f"{ pin_map } ,{ _map } " )
247255 return pin_map
248256 elif member ['type' ] == 'port' :
249- logger .warning (f"Port '{ name } ' has no IOSignature, pin allocation likely to be wrong" )
257+ logger .warning (f"PortModel '{ name } ' has no IOSignature, pin allocation likely to be wrong" )
250258 width = member ['width' ]
251259 model = IOModel (width = int (width ), direction = io .Direction (member ['dir' ]))
252- pin_map [name ] = Port (type = 'io' , port_name = port_name , iomodel = model , pins = None )
260+ pin_map [name ] = PortModel (type = 'io' , port_name = port_name , iomodel = model , pins = None )
253261 logger .debug (f"added '{ name } ':{ pin_map [name ]} to pin_map" )
254262 return pin_map
255263 else :
@@ -267,7 +275,7 @@ def get_ports(self, component: str, interface: str) -> Interface:
267275 raise KeyError (f"'{ component } ' not found in { self } " )
268276 return self .ports [component ][interface ]
269277
270- def get_clocks (self ) -> List [Port ]:
278+ def get_clocks (self ) -> List [PortModel ]:
271279 ret = []
272280 for n , c in self .ports .items ():
273281 for cn , i in c .items ():
@@ -276,7 +284,7 @@ def get_clocks(self) -> List[Port]:
276284 ret .append (p )
277285 return ret
278286
279- def get_resets (self ) -> List [Port ]:
287+ def get_resets (self ) -> List [PortModel ]:
280288 ret = []
281289 for n , c in self .ports .items ():
282290 for cn , i in c .items ():
@@ -285,7 +293,7 @@ def get_resets(self) -> List[Port]:
285293 ret .append (p )
286294 return ret
287295
288- def add_port (self , component : str , interface : str , port_name : str , port : Port ):
296+ def add_port (self , component : str , interface : str , port_name : str , port : PortModel ):
289297 "Internally used by a `PackageDef`"
290298 if component not in self .ports :
291299 self .ports [component ] = Component ()
@@ -333,15 +341,15 @@ def create_power_ports(self, component, interface):
333341 for ipd , ppd in power_allocation .items ():
334342 prefix = f"_power_{ ipd } _{ ppd } "
335343 power_port = prefix + "_vdd"
336- power_domain = f"{ ppd } "
344+ pad_power_domain = f"{ ppd } "
337345 if power_port not in self .ports [component ][interface ]:
338- self .ports [component ][interface ][power_port ] = Port (type = 'power' , pins = None , port_name = power_port ,
339- power_domain = power_domain , iomodel = IOModel (width = 1 , direction = io .Direction .Input ))
346+ self .ports [component ][interface ][power_port ] = PortModel (type = 'power' , pins = None , port_name = power_port ,
347+ pad_power_domain = pad_power_domain , iomodel = IOModel (width = 1 , direction = io .Direction .Input ))
340348
341349 power_port = prefix + "_vss"
342350 if power_port not in self .ports [component ][interface ]:
343- self .ports [component ][interface ][power_port ] = Port (type = 'power' , pins = None , port_name = power_port ,
344- power_domain = power_domain , iomodel = IOModel (width = 1 , direction = io .Direction .Input ))
351+ self .ports [component ][interface ][power_port ] = PortModel (type = 'power' , pins = None , port_name = power_port ,
352+ pad_power_domain = pad_power_domain , iomodel = IOModel (width = 1 , direction = io .Direction .Input ))
345353
346354 def check_core_power (self , core_domain , _type , voltage ):
347355 if core_domain not in self .pad_power_domains :
@@ -811,13 +819,13 @@ def _allocate_bringup(self, config: 'Config') -> Component:
811819 cds = set (config .chipflow .clock_domains ) if config .chipflow .clock_domains else set ()
812820 cds .discard ('sync' )
813821
814- d : Interface = { 'sync-clk' : Port (type = 'clock' ,
822+ d : Interface = { 'sync-clk' : PortModel (type = 'clock' ,
815823 pins = [self .bringup_pins .core_clock ],
816824 port_name = 'sync-clk' ,
817825 iomodel = IOModel (width = 1 , direction = io .Direction .Input ,
818826 clock_domain = "sync" )
819827 ),
820- 'sync-rst_n' : Port (type = 'reset' ,
828+ 'sync-rst_n' : PortModel (type = 'reset' ,
821829 pins = [self .bringup_pins .core_reset ],
822830 port_name = 'sync-rst_n' ,
823831 iomodel = IOModel (width = 1 , direction = io .Direction .Input , clock_domain = "sync" ,
@@ -830,23 +838,23 @@ def _allocate_bringup(self, config: 'Config') -> Component:
830838 vdd_pins .append (pp .ground )
831839 vss_pins .append (pp .power )
832840
833- d |= {'vdd' : Port (type = 'power ' ,
841+ d |= {'vdd' : PortModel (type = 'vdd ' ,
834842 pins = vdd_pins ,
835843 port_name = "vdd-core" ,
836- power_domain = "_core" ,
844+ pad_power_domains = "_core" ,
837845 iomodel = IOModel (width = len (vdd_pins ), direction = io .Direction .Input )),
838- 'vss' : Port (type = 'power ' ,
846+ 'vss' : PortModel (type = 'vss ' ,
839847 pins = vss_pins ,
840848 port_name = "vss-core" ,
841- power_domain = "_core" ,
849+ pad_power_domains = "_core" ,
842850 iomodel = IOModel (width = len (vss_pins ), direction = io .Direction .Input ))
843851 }
844852
845853
846854 assert config .chipflow .silicon
847855 if config .chipflow .silicon .debug and \
848856 config .chipflow .silicon .debug ['heartbeat' ]:
849- d ['heartbeat' ] = Port (type = 'heartbeat' ,
857+ d ['heartbeat' ] = PortModel (type = 'heartbeat' ,
850858 pins = [self .bringup_pins .core_heartbeat ],
851859 port_name = 'heartbeat' ,
852860 iomodel = IOModel (width = 1 , direction = io .Direction .Output , clock_domain = "sync" )
0 commit comments