b_asic.architecture
¶

B-ASIC architecture classes.
- class b_asic.architecture.Architecture(processing_elements: ProcessingElement | Iterable[ProcessingElement], memories: Memory | Iterable[Memory], entity_name: str = 'arch', direct_interconnects: ProcessCollection | None = None)¶
Class representing an architecture.
- Parameters:
- processing_elements
ProcessingElement
or iterable ofProcessingElement
The processing elements in the architecture.
- memories
Memory
or iterable ofMemory
The memories in the architecture.
- entity_namestr, default: “arch”
Name for the top-level entity.
- direct_interconnects
ProcessCollection
, optional Process collection of zero-time memory variables used for direct interconnects.
- processing_elements
- assign_resources(strategy: Literal['left_edge'] = 'left_edge') None ¶
Convenience method to assign all resources in the architecture.
- Parameters:
- strategystr, default: “left_edge”
The heurstic to use.
See also
- property direct_interconnects: ProcessCollection | None¶
- get_interconnects_for_memory(mem: Memory | str) tuple[dict[Resource, int], dict[Resource, int]] ¶
Return a dictionary with interconnect information for a Memory.
- Parameters:
- mem
Memory
or str The memory or entity name to obtain information about.
- mem
- Returns:
- (dict, dict)
A dictionary with the ProcessingElements that are connected to the read and write ports, respectively, with counts of the number of accesses.
- get_interconnects_for_pe(pe: str | ProcessingElement) tuple[list[dict[tuple[Resource, int], int]], list[dict[tuple[Resource, int], int]]] ¶
Return with interconnect information for a ProcessingElement.
The information is tuple, where each element is a lists of dictionaries.
- Parameters:
- pe
ProcessingElement
or str The processing element or entity name to get information for.
- pe
- Returns:
- list
List of dictionaries indicating the sources for each input port and the frequency of accesses.
- list
List of dictionaries indicating the destinations for each output port and the frequency of accesses.
- move_process(proc: str | Process, source: str | Resource, destination: str | Resource, assign: bool = False) None ¶
Move a
Process
from oneResource
to another.Both the resource moved from and will become unassigned after a process has been moved, unless assign is True.
- Parameters:
- proc
Process
or str The process (or its name) to move.
- source
Resource
or str The resource (or its entity name) to move the process from.
- destination
Resource
or str The resource (or its entity name) to move the process to.
- assignbool, default=False
Whether to perform assignment of the resources after moving.
- proc
- Raises:
KeyError
If proc is not present in resource source.
- property processing_elements: list[ProcessingElement]¶
- remove_resource(resource: str | Resource) None ¶
Remove an empty
Resource
from the architecture.- Parameters:
- resource
Resource
or str The resource or the resource name to remove.
- resource
- resource_from_name(name: str) Resource ¶
Get
Resource
based on name.- Parameters:
- namestr
Name of the resource.
- Returns:
- set_entity_name(entity_name: str) None ¶
Set entity name of hardware block.
- Parameters:
- entity_namestr
The entity name.
- show(fmt: str | None = None, branch_node: bool = True, cluster: bool = True, splines: Literal['spline', 'line', 'ortho', 'polyline', 'curved'] = 'spline', io_cluster: bool = True, multiplexers: bool = True, colored: bool = True) None ¶
Display a visual representation of the Architecture using the default system viewer.
- Parameters:
- fmtstr, optional
File format of the generated graph. Output formats can be found at https://www.graphviz.org/doc/info/output.html Most common are “pdf”, “eps”, “png”, and “svg”. Default is None which leads to PDF.
- branch_nodebool, default: True
Whether to create a branch node for outputs with fan-out of two or higher.
- clusterbool, default: True
Whether to draw memories and PEs in separate clusters.
- splines{“spline”, “line”, “ortho”, “polyline”, “curved”}, default: “spline”
Spline style, see https://graphviz.org/docs/attrs/splines/ for more info.
- io_clusterbool, default: True
Whether Inputs and Outputs are drawn inside an IO cluster. Only relevant if cluster is True.
- multiplexersbool, default: True
Whether input multiplexers are included.
- coloredbool, default: True
Whether to color the nodes.
- write_code(path: str) None ¶
Write VHDL code for hardware block.
- Parameters:
- pathstr
Directory to write code in.
- class b_asic.architecture.HardwareBlock(entity_name: str | None = None)¶
Base class for architectures and resources.
- Parameters:
- entity_namestr, optional
The name of the resulting entity.
- set_entity_name(entity_name: str) None ¶
Set entity name of hardware block.
- Parameters:
- entity_namestr
The entity name.
- write_code(path: str) None ¶
Write VHDL code for hardware block.
- Parameters:
- pathstr
Directory to write code in.
- class b_asic.architecture.Memory(process_collection: ProcessCollection, memory_type: Literal['RAM', 'register'] = 'RAM', entity_name: str | None = None, read_ports: int | None = None, write_ports: int | None = None, total_ports: int | None = None, assign: bool = False)¶
Create a memory from a ProcessCollection with memory variables.
- Parameters:
- process_collection
ProcessCollection
The ProcessCollection to create a Memory for.
- memory_type{‘RAM’, ‘register’}
The type of memory.
- entity_namestr, optional
Name of memory entity.
- read_portsint, optional
Number of read ports for memory.
- write_portsint, optional
Number of write ports for memory.
- total_portsint, optional
Total number of read and write ports for memory.
- assignbool, default False
Perform assignment when creating the Memory (using the default properties).
- process_collection
- assign(strategy: Literal['left_edge', 'greedy_graph_color', 'ilp_graph_color'] = 'left_edge') None ¶
Perform assignment of the memory variables.
- Parameters:
- strategystr, default: ‘left_edge’
The assignment algorithm. Depending on memory type the following are available:
- ‘RAM’
‘left_edge’: Left-edge algorithm.
‘greedy_graph_color’: Greedy graph-coloring based on exclusion graph.
‘ilp_graph_color’: Optimal graph-coloring based on exclusion graph.
- ‘register’
…
- property collection: ProcessCollection¶
- property content: Figure¶
Return a graphical representation of the content.
This is visible in enriched shells, but the object itself has no further meaning (it is a Matplotlib Figure).
- property operation_type: type[MemoryProcess]¶
- plot_content(ax: Axes, **kwargs) None ¶
Plot the content of the resource.
This plots the assigned processes executed on this resource.
- Parameters:
- axAxes
Matplotlib Axes to plot in.
- **kwargs
Passed to
plot()
.
- remove_process(proc: Process, assign: bool = False)¶
Remove a
Process
from thisResource
.Raises
KeyError
if the process being added is not of the same type as the other processes.
- set_entity_name(entity_name: str) None ¶
Set entity name of hardware block.
- Parameters:
- entity_namestr
The entity name.
- show_content(title=None, **kwargs) None ¶
Display the content of the resource.
This displays the assigned processes executed on this resource.
- Parameters:
- titlestr, optional
Figure title.
- **kwargs
Passed to
plot()
.
- write_code(path: str) None ¶
Write VHDL code for hardware block.
- Parameters:
- pathstr
Directory to write code in.
- class b_asic.architecture.ProcessingElement(process_collection: ProcessCollection, entity_name: str | None = None, assign: bool = True)¶
Create a processing element for a ProcessCollection with OperatorProcesses.
- Parameters:
- process_collection
ProcessCollection
Process collection containing operations to map to processing element.
- entity_namestr, optional
Name of processing element entity.
- assignbool, default True
Perform assignment when creating the ProcessingElement.
- process_collection
- assign(strategy: Literal['left_edge', 'graph_color'] = 'left_edge') None ¶
Perform assignment of the processes.
- Parameters:
- strategy{‘left_edge’, ‘graph_color’}, default: ‘left_edge’
The assignment algorithm.
‘left_edge’: Left-edge algorithm.
‘graph_color’: Graph-coloring based on exclusion graph.
- property collection: ProcessCollection¶
- property content: Figure¶
Return a graphical representation of the content.
This is visible in enriched shells, but the object itself has no further meaning (it is a Matplotlib Figure).
- plot_content(ax: Axes, **kwargs) None ¶
Plot the content of the resource.
This plots the assigned processes executed on this resource.
- Parameters:
- axAxes
Matplotlib Axes to plot in.
- **kwargs
Passed to
plot()
.
- property processes: list[OperatorProcess]¶
- remove_process(proc: Process, assign: bool = False)¶
Remove a
Process
from thisResource
.Raises
KeyError
if the process being added is not of the same type as the other processes.
- set_entity_name(entity_name: str) None ¶
Set entity name of hardware block.
- Parameters:
- entity_namestr
The entity name.
- show_content(title=None, **kwargs) None ¶
Display the content of the resource.
This displays the assigned processes executed on this resource.
- Parameters:
- titlestr, optional
Figure title.
- **kwargs
Passed to
plot()
.
- write_code(path: str) None ¶
Write VHDL code for hardware block.
- Parameters:
- pathstr
Directory to write code in.
- class b_asic.architecture.Resource(process_collection: ProcessCollection, entity_name: str | None = None)¶
Base class for resource.
- Parameters:
- process_collection
ProcessCollection
The process collection containing processes to be mapped to resource.
- entity_namestr, optional
The name of the resulting entity.
- process_collection
- assign(strategy: Literal['left_edge'] = 'left_edge')¶
Perform assignment of processes to resource.
- Parameters:
- strategystr
See the specific resource types for more information.
See also
- property collection: ProcessCollection¶
- property content: Figure¶
Return a graphical representation of the content.
This is visible in enriched shells, but the object itself has no further meaning (it is a Matplotlib Figure).
- property operation_type: type[MemoryProcess] | type[Operation]¶
- plot_content(ax: Axes, **kwargs) None ¶
Plot the content of the resource.
This plots the assigned processes executed on this resource.
- Parameters:
- axAxes
Matplotlib Axes to plot in.
- **kwargs
Passed to
plot()
.
- remove_process(proc: Process, assign: bool = False)¶
Remove a
Process
from thisResource
.Raises
KeyError
if the process being added is not of the same type as the other processes.
- set_entity_name(entity_name: str) None ¶
Set entity name of hardware block.
- Parameters:
- entity_namestr
The entity name.
- show_content(title=None, **kwargs) None ¶
Display the content of the resource.
This displays the assigned processes executed on this resource.
- Parameters:
- titlestr, optional
Figure title.
- **kwargs
Passed to
plot()
.
- write_code(path: str) None ¶
Write VHDL code for hardware block.
- Parameters:
- pathstr
Directory to write code in.