Skip to content

Commit d72a217

Browse files
committed
Consolidate all utility functions into chipflow_lib/utils.py
- Move compute_invert_mask() from platform/utils.py to main utils.py - Delete chipflow_lib/platform/utils.py (now empty) - Update imports in silicon.py and base.py to use main utils module - All utility functions now in single location for better maintainability
1 parent 17af6ad commit d72a217

File tree

4 files changed

+15
-27
lines changed

4 files changed

+15
-27
lines changed

chipflow_lib/platform/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from amaranth import Module
1111

1212
from .io import IOSignature
13-
from .utils import compute_invert_mask
13+
from ..utils import compute_invert_mask
1414

1515
logger = logging.getLogger(__name__)
1616

chipflow_lib/platform/silicon.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,9 @@
2020
from amaranth.hdl import Fragment
2121
from amaranth.hdl._ir import PortDirection
2222

23-
from ..utils import ChipFlowError
23+
from ..utils import ChipFlowError, compute_invert_mask
2424
from ..config import Process
2525
from .io import IOModel, IOTripPoint, Sky130DriveMode
26-
from .utils import compute_invert_mask
2726

2827
if TYPE_CHECKING:
2928
from ..config import Config

chipflow_lib/platform/utils.py

Lines changed: 0 additions & 24 deletions
This file was deleted.

chipflow_lib/utils.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,19 @@ def get_src_loc(src_loc_at: int = 0):
104104
return (frame.f_code.co_filename, frame.f_lineno)
105105

106106

107+
def compute_invert_mask(invert_list):
108+
"""
109+
Compute a bit mask for signal inversion from a list of boolean invert flags.
110+
111+
Args:
112+
invert_list: List of booleans indicating which bits should be inverted
113+
114+
Returns:
115+
Integer mask where set bits indicate positions to invert
116+
"""
117+
return sum(inv << bit for bit, inv in enumerate(invert_list))
118+
119+
107120
def top_components(config: 'Config') -> Dict[str, 'wiring.Component']:
108121
"""
109122
Return the top level components for the design, as configured in ``chipflow.toml``.

0 commit comments

Comments
 (0)