@@ -16,61 +16,77 @@ Each package type (PGA, bare die, etc.) defines its own implementation of these
1616
1717# Using the Package Pin Interface in Code
1818
19- ### Getting Default Pins
19+ ### Available Package Definitions
2020
2121``` python
22- from chipflow_lib.platforms.utils import PACKAGE_DEFINITIONS , PowerType, JTAGWireName
22+ from chipflow_lib.platforms import PACKAGE_DEFINITIONS
23+
24+ # Available package types
25+ print (list (PACKAGE_DEFINITIONS .keys())) # ['pga144', 'cf20', 'openframe']
2326
2427# Get a package definition
2528package_def = PACKAGE_DEFINITIONS [" pga144" ]
29+ print (package_def.name) # "pga144"
30+ print (package_def.package_type) # "QuadPackageDef"
31+ ```
2632
27- # Get power pins
28- power_pins = package_def.power
29- vdd_pin = power_pins[PowerType.POWER ] # Get the default power pin
30- gnd_pin = power_pins[PowerType.GROUND ] # Get the default ground pin
33+ ### Core Package Methods
3134
32- # Get clock pins
33- clock_pins = package_def.clocks
34- default_clock = clock_pins[0 ] # Get the first clock pin
35+ ``` python
36+ from chipflow_lib.platforms import PACKAGE_DEFINITIONS
37+
38+ package_def = PACKAGE_DEFINITIONS [" pga144" ]
3539
36- # Get JTAG pins
37- jtag_pins = package_def.jtag
38- tck_pin = jtag_pins[JTAGWireName.TCK ] # Get the TCK pin
39- tms_pin = jtag_pins[JTAGWireName.TMS ] # Get the TMS pin
40+ # Allocate pins for components
41+ # This method handles pin allocation logic for the package
42+ pins = package_def.allocate_pins(component_requirements)
43+
44+ # Get bringup pins for testing/debugging
45+ bringup_pins = package_def.bringup_pins()
46+
47+ # Register a component with the package
48+ package_def.register_component(component)
4049```
4150
42- ### Creating a Package with Default Pins
51+ ### Working with Different Package Types
4352
4453``` python
45- from chipflow_lib.platforms.utils import PACKAGE_DEFINITIONS
54+ from chipflow_lib.platforms import PACKAGE_DEFINITIONS
4655
47- # Create a package with a specific package definition
48- package = Package(package_type = PACKAGE_DEFINITIONS [" pga144" ])
56+ # Work with different package types
57+ pga_package = PACKAGE_DEFINITIONS [" pga144" ] # QuadPackageDef
58+ cf_package = PACKAGE_DEFINITIONS [" cf20" ] # BareDiePackageDef
59+ openframe_package = PACKAGE_DEFINITIONS [" openframe" ] # OpenframePackageDef
4960
50- # Initialize default pins from the package definition
51- package.initialize_from_package_type()
61+ # Each package type has the same core interface
62+ for name, package in PACKAGE_DEFINITIONS .items():
63+ print (f " { name} : { package.package_type} " )
5264```
5365
54- ## Extending for New Package Types
66+ ## Package Types
5567
56- To create a new package type, you need to :
68+ Currently available package types :
5769
58- 1 . Subclass ` _BasePackageDef ` and implement all the required properties and methods
59- 2 . Add your new package type to the ` PackageDef ` union and ` PACKAGE_DEFINITIONS ` dictionary
70+ - ** QuadPackageDef** : Used by ` pga144 ` package
71+ - ** BareDiePackageDef** : Used by ` cf20 ` package
72+ - ** OpenframePackageDef** : Used by ` openframe ` package
6073
61- Example:
74+ All package definitions implement the same core interface:
75+ - ` allocate_pins() ` : Handle pin allocation logic
76+ - ` bringup_pins() ` : Get pins for testing/debugging
77+ - ` register_component() ` : Register components with the package
6278
63- ``` python
64- class MyNewPackageDef (_BasePackageDef ):
65- type : Literal[" MyNewPackageDef" ] = " MyNewPackageDef"
66- # ... implement all required methods ...
79+ ## Extending for New Package Types
6780
68- # Add to the union
69- PackageDef = Union[_QuadPackageDef, _BareDiePackageDef, MyNewPackageDef, _BasePackageDef]
81+ To create a new package type, you need to:
7082
71- # Add to the dictionary of available packages
72- PACKAGE_DEFINITIONS [" my_new_package" ] = MyNewPackageDef(name = " my_new_package" , ... )
73- ```
83+ 1 . Implement a new package definition class that provides the core methods
84+ 2 . Add your new package type to the ` PACKAGE_DEFINITIONS ` dictionary
85+
86+ The new package definition should implement:
87+ - ` allocate_pins() ` method for pin allocation
88+ - ` bringup_pins() ` method for test pins
89+ - ` register_component() ` method for component registration
7490
7591## Running Tests
7692
@@ -79,3 +95,11 @@ Tests for the package pin interface can be run using:
7995``` bash
8096pdm run pytest tests/test_package_pins.py
8197```
98+
99+ ## Available Packages
100+
101+ The current public API provides access to these packages through ` PACKAGE_DEFINITIONS ` :
102+
103+ - ` pga144 ` : PGA-144 package (QuadPackageDef)
104+ - ` cf20 ` : CF-20 package (BareDiePackageDef)
105+ - ` openframe ` : OpenFrame package (OpenframePackageDef)
0 commit comments