@@ -40,52 +40,17 @@ def lock_pins() -> None:
4040 print (f"Locking pins: { 'using pins.lock' if lockfile .exists () else '' } " )
4141
4242 process = config_model .chipflow .silicon .process
43- package_name = config_model .chipflow .silicon .package
43+ package = config_model .chipflow .silicon .package
4444
45- if package_name not in PACKAGE_DEFINITIONS :
46- logger .debug (f"Package '{ package_name } is unknown" )
47-
48- # TODO, ugh, clean this up.
49- package = Package (package_type = PACKAGE_DEFINITIONS [package_name ])
50-
51- # Initialize standard pins from package type
52- package .initialize_from_package_type ()
53-
54- # Process user-defined pads
55- logger .debug (f"Checking [chipflow.silicon.pads]:" ) if hasattr (config_model .chipflow .silicon , "pads" ) else ...
56- silicon_config = getattr (config_model .chipflow .silicon , "pads" , {})
57- for k , v in silicon_config .items ():
58- pin = str (v .loc )
59-
60- # Convert Pydantic model to dict for backward compatibility
61- v_dict = {"type" : v .type , "loc" : v .loc }
62- port = oldlock .package .check_pad (k , v_dict ) if oldlock else None
63-
64- if port and port .pins != [pin ]:
65- raise ChipFlowError (
66- f"chipflow.toml conflicts with pins.lock: "
67- f"{ k } had pin { port .pins } , now { [pin ]} ."
68- )
69-
70- # Add pad to package
71- package .add_pad (k , v_dict )
72-
73- # TODO: power pins
74- #
75- logger .debug (f'Pins in use: { package_type .sortpins (used_pins )} ' )
76-
77- unallocated = package_type .pins - used_pins
78-
79- logger .debug (f"unallocated pins = { package_type .sortpins (unallocated )} " )
45+ package_def = config_model .chipflow .silicon .package .package_type
8046
8147 top = top_components (config_dict )
8248
8349 # Use the PackageDef to allocate the pins:
84- for component , iface in interfaces .items ():
85- newlock = LockFile (process = process ,
86- package = package ,
87- port_map = port_map ,
88- metadata = interfaces )
50+ for name , component in top .items ():
51+ package_def .register_component (name , component )
52+
53+ newlock = package_def .allocate_pins ()
8954
9055 with open (lockfile , 'w' ) as f :
9156 f .write (newlock .model_dump_json (indent = 2 , serialize_as_any = True ))
0 commit comments