chipflow.utils¶
Core utility functions for ChipFlow
This module provides core utilities used throughout the chipflow library.
Exceptions¶
Base exception for ChipFlow errors |
Functions¶
|
Dynamically import and return a class by its module:class reference string. |
Ensure CHIPFLOW_ROOT environment variable is set and return its path. |
|
|
Get the source location (filename, line number) of the caller. |
|
Compute a bit mask for signal inversion from a list of boolean invert flags. |
|
Return the top level components for the design, as configured in |
|
Extract software build information from a component's interfaces. |
Module Contents¶
- chipflow.utils.get_cls_by_reference(reference, context)¶
Dynamically import and return a class by its module:class reference string.
- Parameters:
- Returns:
The class object
- Raises:
ChipFlowError – If module or class cannot be found
- chipflow.utils.ensure_chipflow_root()¶
Ensure CHIPFLOW_ROOT environment variable is set and return its path.
If CHIPFLOW_ROOT is not set, sets it to the current working directory. Also ensures the root is in sys.path.
- Returns:
Path to the chipflow root directory
- Return type:
- chipflow.utils.get_src_loc(src_loc_at=0)¶
Get the source location (filename, line number) of the caller.
- Parameters:
src_loc_at (int) – Number of frames to go back (0 = immediate caller)
- Returns:
Tuple of (filename, line_number)
- chipflow.utils.compute_invert_mask(invert_list)¶
Compute a bit mask for signal inversion from a list of boolean invert flags.
- Parameters:
invert_list – List of booleans indicating which bits should be inverted
- Returns:
Integer mask where set bits indicate positions to invert
- chipflow.utils.top_components(config)¶
Return the top level components for the design, as configured in
chipflow.toml.- Parameters:
config (chipflow.config.models.Config) – The parsed chipflow configuration
- Returns:
Dictionary mapping component names to instantiated Component objects
- Raises:
ChipFlowError – If component references are invalid or instantiation fails
- Return type:
Dict[str, amaranth.lib.wiring.Component]