b_asic.schedule¶
B-ASIC Schedule Module.
Contains the schedule class for scheduling operations in an SFG.
- class b_asic.schedule.Schedule(sfg: SFG, scheduler: Scheduler | None = None, schedule_time: int | None = None, cyclic: bool = False, start_times: dict[GraphID, int] | None = None, laps: dict[GraphID, int] | None = None)¶
Bases:
objectSchedule of an SFG with scheduled Operations.
- Parameters:
- sfg
SFG The signal flow graph to schedule.
- scheduler
Scheduler, optional The automatic scheduler to be used.
- schedule_timeint, optional
The schedule time. If not provided, it will be determined by the scheduling algorithm.
- cyclicbool, default: False
If the schedule is cyclic.
- start_timesdict, optional
Dictionary with GraphIDs as keys and start times as values. Used when algorithm is ‘provided’.
- lapsdict, optional
Dictionary with GraphIDs as keys and laps as values. Used when algorithm is ‘provided’.
- sfg
- backward_slack(graph_id: GraphID) int¶
Return how much an operation can be moved backward in time.
- Parameters:
- graph_id
GraphID The graph id of the operation.
- graph_id
- Returns:
- int
The number of time steps the operation with graph_id can be moved backward in time.
Note
The backward slack is positive, but a call to
move_operation()should be negative to move the operation backward.
See also
forward_slackslacks
- decrease_time_resolution(factor: int) Schedule¶
Decrease time resolution for a schedule.
- Parameters:
- factorint
The time resolution decrement.
- edit(inplace=False) Schedule¶
Edit schedule in GUI and return new schedule.
- Parameters:
- inplacebool, default: False
If True, replace the current schedule.
- forward_slack(graph_id: GraphID) int¶
Return how much an operation can be moved forward in time.
- Parameters:
- graph_id
GraphID The graph id of the operation.
- graph_id
- Returns:
- int
The number of time steps the operation with graph_id can be moved forward in time.
See also
backward_slackslacks
- get_io_latency() dict[GraphID, dict[GraphID, int]]¶
Return the latency between each Input/Output pair.
The latency is the minimum number of
Delayelements on any path from aInputto aOutput, multiplied by the schedule time, plus the difference in their start times within the schedule.
- get_memory_variables() ProcessCollection¶
Return a ProcessCollection containing all memory variables.
- Returns:
ProcessCollectionMemory variables derived from the scheduled signal transfers, with the same schedule time as this schedule. Transfers from DontCare or to Sink placeholders are excluded.
- get_operations() ProcessCollection¶
Return a ProcessCollection containing all operations.
- Returns:
ProcessCollectionScheduled operations as operator processes, excluding DontCare and Sink operations, with the same schedule time and cyclic setting as this schedule.
- get_possible_time_resolution_decrements() list[int]¶
Return a list with possible factors to reduce time resolution.
- get_y_location(graph_id: GraphID) int¶
Get the y-location of the Operation with GraphID graph_id.
- Parameters:
- graph_id
GraphID The GraphID of the operation.
- graph_id
- Returns:
- int
The y-location of the operation.
- increase_time_resolution(factor: int) Schedule¶
Increase time resolution for a schedule.
- Parameters:
- factorint
The time resolution increment.
- property laps: dict[GraphID, int]¶
The number of laps for the start times of the operations in the schedule.
- move_operation(graph_id: GraphID, time: int) Schedule¶
Move an operation in the schedule.
- Parameters:
- graph_id
GraphID The graph id of the operation to move.
- timeint
The time to move. If positive move forward, if negative move backward.
- graph_id
- move_operation_alap(graph_id: GraphID) Schedule¶
Move an operation as late as possible in the schedule.
This is basically the same as:
schedule.move_operation(graph_id, schedule.forward_slack(graph_id))
but operations with no real succeeding operation will only move as late as their latency allows within the schedule.
- Parameters:
- graph_id
GraphID The graph id of the operation to move.
- graph_id
- move_operation_asap(graph_id: GraphID) Schedule¶
Move an operation as soon as possible in the schedule.
This is basically the same as:
schedule.move_operation(graph_id, -schedule.backward_slack(graph_id))
but operations that do not have a preceding operation (Inputs and Constants) will only move to the start of the schedule.
- Parameters:
- graph_id
GraphID The graph id of the operation to move.
- graph_id
- move_y_location(graph_id: GraphID, new_y: int, insert: bool = False) None¶
Move operation in y-direction and remove any empty rows.
- Parameters:
- graph_id
GraphID The GraphID of the operation to move.
- new_yint
The new y-location of the operation.
- insertbool, optional
If True, all operations on that y-location will be moved one position. The default is False.
- graph_id
- plot(ax: Axes, operation_gap: float = 0.5) None¶
Plot the schedule in a
matplotlib.axes.Axesor subclass.- Parameters:
- ax
Axes The
matplotlib.axes.Axesto plot in.- operation_gapfloat, optional
The vertical distance between operations in the schedule. The height of the operation is always 1.
- ax
- print_slacks(order: int = 0, type_name: TypeName | None = None) None¶
Print the slack times for all operations in the schedule.
- Parameters:
- orderint, default: 0
Sorting order.
0: alphabetical on Graph ID
1: backward slack
2: forward slack
- type_name
TypeName, optional If given, only the slack times for operations of this type will be printed.
- set_execution_time_of_type(operation_type: type[Operation], execution_time: int) None¶
Set the execution time of all operations of the given type.
- Parameters:
- operation_typetype of
Operation The operation type. For example,
Addition.- execution_timeint
The execution time of the operation.
- operation_typetype of
- set_execution_time_of_type_name(type_name: TypeName, execution_time: int) None¶
Set the execution time of all operations with the given type name.
- Parameters:
- type_name
TypeName The type name of the operation. For example, obtained as
Addition.type_name().- execution_timeint
The execution time of the operation.
- type_name
- set_latency_of_type(operation_type: type[Operation], latency: int) None¶
Set the latency of all operations of the given type.
- Parameters:
- operation_typetype of
Operation The operation type. For example,
Addition.- latencyint
The latency of the operation.
- operation_typetype of
- set_latency_of_type_name(type_name: TypeName | GraphID, latency: int) None¶
Set the latency of all operations with the given type name.
- set_schedule_time(time: int, *, allow_cyclic_wrap: bool = False) Schedule¶
Set a new schedule time.
- Parameters:
- timeint
The new schedule time. For cyclic schedules, a shorter time is allowed when allow_cyclic_wrap is True and all operations wrapping around the schedule edge have non-negative forward slack.
- allow_cyclic_wrapbool, default: False
Whether to allow a shorter cyclic schedule time when edge operations have non-negative forward slack. Operations starting at the new boundary are moved to time zero, except for Output and Sink operations.
See also
get_max_time
- set_y_location(graph_id: GraphID, y_location: int) None¶
Set the y-location of the Operation with GraphID graph_id to y_location.
- Parameters:
- graph_id
GraphID The GraphID of the operation to move.
- y_locationint
The new y-location of the operation.
- graph_id
- show(fmt: str = 'pdf', operation_gap: float = 0.5, title: str | None = None, fontname: str | None = 'DejaVu Serif', fontsize: int | None = None, figsize: tuple[float, float] | None = None) None¶
Show the schedule in the default system viewer.
- Parameters:
- fmtstr, default: “pdf”
File format to render (e.g.
"pdf","png","svg").- operation_gapfloat, optional
The vertical distance between operations in the schedule. The height of the operation is always 1.
- titlestr, optional
Figure title.
- fontnamestr, optional
Font to use for all text in the figure. Defaults to
b_asic._preferences.DEFAULT_FONT_FAMILY, None uses Matplotlib’s default.- fontsizeint, optional
Base font size for all text in the figure.
- figsize(float, float), optional
Figure size in inches as
(width, height). Overrides the automatically computed height.
- slacks(graph_id: GraphID) tuple[int, int]¶
Return the backward and forward slacks of operation graph_id.
That is, how much the operation can be moved backward and forward in time.
- Parameters:
- graph_id
GraphID The graph id of the operation.
- graph_id
- Returns:
- tuple(int, int)
The backward and forward slacks, respectively.
Note
The backward slack is positive, but a call to
move_operation()should be negative to move the operation backward.
See also
- sort_y_locations_on_start_times() None¶
Sort the y-locations of the schedule based on start times of the operations.
Inputs, outputs, dontcares, and sinks are located adjacent to the operations that they are connected to.
See also