3232 XnorGate ,
3333 XorGate ,
3434)
35- from .circuit_util_elements import ConnectionPointID , FunctionRepresentation
35+ from .circuit_util_elements import ConnectionPointID , FunctionRepresentation , Pin
3636
3737
3838@dataclass
@@ -82,6 +82,8 @@ def __init__(
8282 description : str | None = None ,
8383 pkg : Package | None = None ,
8484 functions : list [ChipFunction ] | None = None ,
85+ vcc : Pin | None = None ,
86+ gnd : Pin | None = None ,
8587 position : ConnectionPointID | None = None ,
8688 model : Chip | None = None ,
8789 ):
@@ -102,6 +104,8 @@ def __init__(
102104 and description is not None
103105 and pkg is not None
104106 and functions is not None
107+ and vcc is not None
108+ and gnd is not None
105109 and model is None
106110 ):
107111 self .chip_type = chip_type
@@ -110,6 +114,8 @@ def __init__(
110114 self .pin_count : int = pkg .pin_count
111115 self .chip_width : float = pkg .chip_width
112116 self .functions : list [ChipFunction ] = functions
117+ self .vcc = vcc
118+ self .gnd = gnd
113119 if position is not None :
114120 for fn in self .functions :
115121 fn .calculate_pin_pos (position , 1 , self .pin_count )
@@ -123,6 +129,8 @@ def __init__(
123129 self .pin_count = model .pin_count
124130 self .chip_width = model .chip_width
125131 self .functions = model .functions
132+ self .vcc = model .vcc
133+ self .gnd = model .gnd
126134 else :
127135 raise ValueError ("Invalid parameters provided." )
128136
@@ -237,6 +245,8 @@ def from_json(json_data: dict, package_dict: dict[str, Package] | None = None):
237245 json_data ["description" ],
238246 package_dict [json_data ["package" ]],
239247 functions ,
248+ Pin (json_data ["vcc_pin" ], None ),
249+ Pin (json_data ["gnd_pin" ], None ),
240250 )
241251
242252 raise ValueError ("The package does not exist in the Components/Packages directory." )
@@ -254,6 +264,7 @@ def to_generic_dict(self) -> dict[str, Any]:
254264 "packageName" : self .package_name ,
255265 "pinCount" : self .pin_count ,
256266 "chipWidth" : self .chip_width ,
267+ "pwr" : [(self .vcc .pin_num , "+" ), (self .gnd .pin_num , "-" )],
257268 }
258269
259270 if self .functions :
0 commit comments