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.
- Args:
reference: String in format “module.path:ClassName” context: Description of where this reference came from (for error messages)
- 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.
- Args:
src_loc_at: Number of frames to go back (0 = immediate caller)
- Returns:
Tuple of (filename, line_number)
- Parameters:
src_loc_at (int)
- chipflow.utils.compute_invert_mask(invert_list)
Compute a bit mask for signal inversion from a list of boolean invert flags.
- Args:
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.- Args:
config: The parsed chipflow configuration
- Returns:
Dictionary mapping component names to instantiated Component objects
- Raises:
ChipFlowError: If component references are invalid or instantiation fails
- Parameters:
config (chipflow.config.models.Config)
- Return type:
Dict[str, amaranth.lib.wiring.Component]