Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B-ASIC - Better ASIC Toolbox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Computer Engineering
B-ASIC - Better ASIC Toolbox
Commits
5d34f8ab
Commit
5d34f8ab
authored
2 years ago
by
Oscar Gustafsson
Browse files
Options
Downloads
Patches
Plain Diff
Fix documentation formatting
parent
18bd197a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!239
Fix documentation formatting
Pipeline
#91473
passed
2 years ago
Stage: test
Changes
4
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.pre-commit-config.yaml
+1
-1
1 addition, 1 deletion
.pre-commit-config.yaml
b_asic/resources.py
+72
-55
72 additions, 55 deletions
b_asic/resources.py
b_asic/signal_generator.py
+2
-0
2 additions, 0 deletions
b_asic/signal_generator.py
test/test_simulation.py
+1
-0
1 addition, 0 deletions
test/test_simulation.py
with
76 additions
and
56 deletions
.pre-commit-config.yaml
+
1
−
1
View file @
5d34f8ab
...
@@ -19,6 +19,6 @@ repos:
...
@@ -19,6 +19,6 @@ repos:
-
id
:
isort
-
id
:
isort
name
:
isort (python)
name
:
isort (python)
-
repo
:
https://github.com/Carreau/velin
-
repo
:
https://github.com/Carreau/velin
rev
:
0.0.1
2
rev
:
0.0.1
1
hooks
:
hooks
:
-
id
:
velin
-
id
:
velin
This diff is collapsed.
Click to expand it.
b_asic/resources.py
+
72
−
55
View file @
5d34f8ab
...
@@ -34,9 +34,9 @@ def draw_exclusion_graph_coloring(
...
@@ -34,9 +34,9 @@ def draw_exclusion_graph_coloring(
color_dict
:
Dict
[
Process
,
int
],
color_dict
:
Dict
[
Process
,
int
],
ax
:
Optional
[
Axes
]
=
None
,
ax
:
Optional
[
Axes
]
=
None
,
color_list
:
Optional
[
Union
[
List
[
str
],
List
[
Tuple
[
float
,
float
,
float
]]]]
=
None
,
color_list
:
Optional
[
Union
[
List
[
str
],
List
[
Tuple
[
float
,
float
,
float
]]]]
=
None
,
):
)
->
None
:
"""
"""
Use matplotlib.pyplot and networkx to d
raw a colored exclusion graph from the memory assignment
D
raw a colored exclusion graph from the memory assignment
.
.. code-block:: python
.. code-block:: python
...
@@ -51,12 +51,19 @@ def draw_exclusion_graph_coloring(
...
@@ -51,12 +51,19 @@ def draw_exclusion_graph_coloring(
----------
----------
exclusion_graph : nx.Graph
exclusion_graph : nx.Graph
A nx.Graph exclusion graph object that is to be drawn.
A nx.Graph exclusion graph object that is to be drawn.
color_dict : dictionary
color_dict : dict
A color dictionary where keys are Process objects and where values are integers representing colors. These
A dict where keys are :class:`~b_asic.process.Process` objects and values are
dictionaries are automatically generated by :func:`networkx.algorithms.coloring.greedy_color`.
integers representing colors. These dictionaries are automatically generated by
:func:`networkx.algorithms.coloring.greedy_color`.
ax : :class:`matplotlib.axes.Axes`, optional
ax : :class:`matplotlib.axes.Axes`, optional
A Matplotlib Axes object to draw the exclusion graph
A Matplotlib :class:`~matplotlib.axes.Axes` object to draw the exclusion graph.
color_list : Optional[Union[List[str], List[Tuple[float,float,float]]]]
color_list : iterable of color, optional
A list of colors in Matplotlib format.
Returns
-------
None
"""
"""
COLOR_LIST
=
[
COLOR_LIST
=
[
'
#aa0000
'
,
'
#aa0000
'
,
...
@@ -126,7 +133,7 @@ class ProcessCollection:
...
@@ -126,7 +133,7 @@ class ProcessCollection:
Parameters
Parameters
----------
----------
process : Process
process : Process
The process object to be added to the collection
The process object to be added to the collection
.
"""
"""
self
.
_collection
.
add
(
process
)
self
.
_collection
.
add
(
process
)
...
@@ -141,13 +148,14 @@ class ProcessCollection:
...
@@ -141,13 +148,14 @@ class ProcessCollection:
show_markers
:
bool
=
True
,
show_markers
:
bool
=
True
,
):
):
"""
"""
Use matplotlib.pyplot to generate
a process variable lifetime chart
from this process collection
.
Plot
a process variable lifetime chart.
Parameters
Parameters
----------
----------
ax : :class:`matplotlib.axes.Axes`, optional
ax : :class:`matplotlib.axes.Axes`, optional
Matplotlib Axes object to draw this lifetime chart onto. If not provided (i.e., set to None),
Matplotlib :class:`~matplotlib.axes.Axes` object to draw this lifetime chart
this method will return a new axes object on return.
onto. If not provided (i.e., set to None), this method will return a new
Axes object.
show_name : bool, default: True
show_name : bool, default: True
Show name of all processes in the lifetime chart.
Show name of all processes in the lifetime chart.
bar_color : color, optional
bar_color : color, optional
...
@@ -176,7 +184,8 @@ class ProcessCollection:
...
@@ -176,7 +184,8 @@ class ProcessCollection:
PAD_L
,
PAD_R
=
0.05
,
0.05
PAD_L
,
PAD_R
=
0.05
,
0.05
max_execution_time
=
max
(
process
.
execution_time
for
process
in
self
.
_collection
)
max_execution_time
=
max
(
process
.
execution_time
for
process
in
self
.
_collection
)
if
max_execution_time
>
self
.
_schedule_time
:
if
max_execution_time
>
self
.
_schedule_time
:
# Schedule time needs to be greater than or equal to the maximum process lifetime
# Schedule time needs to be greater than or equal to the maximum process
# lifetime
raise
KeyError
(
raise
KeyError
(
f
'
Error: Schedule time:
{
self
.
_schedule_time
}
< Max execution
'
f
'
Error: Schedule time:
{
self
.
_schedule_time
}
< Max execution
'
f
'
time:
{
max_execution_time
}
'
f
'
time:
{
max_execution_time
}
'
...
@@ -247,16 +256,19 @@ class ProcessCollection:
...
@@ -247,16 +256,19 @@ class ProcessCollection:
total_ports
:
Optional
[
int
]
=
None
,
total_ports
:
Optional
[
int
]
=
None
,
)
->
nx
.
Graph
:
)
->
nx
.
Graph
:
"""
"""
Create an exclusion graph
from a ProcessCollection
based on a number of read/write ports
Create an exclusion graph based on a number of read/write ports
.
Parameters
Parameters
----------
----------
read_ports : int
read_ports : int
The number of read ports used when splitting process collection based on memory variable access.
The number of read ports used when splitting process collection based on
memory variable access.
write_ports : int
write_ports : int
The number of write ports used when splitting process collection based on memory variable access.
The number of write ports used when splitting process collection based on
memory variable access.
total_ports : int
total_ports : int
The total number of ports used when splitting process collection based on memory variable access.
The total number of ports used when splitting process collection based on
memory variable access.
Returns
Returns
-------
-------
...
@@ -348,29 +360,28 @@ class ProcessCollection:
...
@@ -348,29 +360,28 @@ class ProcessCollection:
return
exclusion_graph
return
exclusion_graph
def
split_execution_time
(
def
split_execution_time
(
self
,
heuristic
:
str
=
"
graph_color
"
,
coloring_strategy
:
str
=
"
DSATUR
"
self
,
heuristic
:
str
=
"
graph_color
"
,
coloring_strategy
:
str
=
"
saturation_largest_first
"
,
)
->
Set
[
"
ProcessCollection
"
]:
)
->
Set
[
"
ProcessCollection
"
]:
"""
"""
Split a ProcessCollection based on overlapping execution time.
Split a ProcessCollection based on overlapping execution time.
Parameters
Parameters
----------
----------
heuristic :
str
, default:
'
graph_color
'
heuristic :
{
'
graph_color
'
,
'
left_edge
'
}
, default:
'
graph_color
'
The heuristic used when splitting based on execution times.
The heuristic used when splitting based on execution times.
One of:
'
graph_color
'
,
'
left_edge
'
.
coloring_strategy : str, default:
'
saturation_largest_first
'
coloring_strategy : str, default:
'
DSATUR
'
Node ordering strategy passed to :func:`networkx.coloring.greedy_color`.
Node ordering strategy passed to nx.coloring.greedy_color() if the heuristic is set to
'
graph_color
'
. This
This parameter is only considered if *heuristic* is set to
'
graph_color
'
.
parameter is only considered if heuristic is set to graph_color.
One of
One of
* `
'
largest_first
'
`
*
'
largest_first
'
* `
'
random_sequential
'
`
*
'
random_sequential
'
* `
'
smallest_last
'
`
*
'
smallest_last
'
* `
'
independent_set
'
`
*
'
independent_set
'
* `
'
connected_sequential_bfs
'
`
*
'
connected_sequential_bfs
'
* `
'
connected_sequential_dfs
'
`
*
'
connected_sequential_dfs
'
or
'
connected_sequential
'
* `
'
connected_sequential
'
` (alias for the previous strategy)
*
'
saturation_largest_first
'
or
'
DSATUR
'
* `
'
saturation_largest_first
'
`
* `
'
DSATUR
'
` (alias for the saturation_largest_first strategy)
Returns
Returns
-------
-------
...
@@ -402,14 +413,17 @@ class ProcessCollection:
...
@@ -402,14 +413,17 @@ class ProcessCollection:
heuristic : str, default:
"
graph_color
"
heuristic : str, default:
"
graph_color
"
The heuristic used when splitting this ProcessCollection.
The heuristic used when splitting this ProcessCollection.
Valid options are:
Valid options are:
*
"
graph_color
"
*
"
graph_color
"
*
"
...
"
*
"
...
"
read_ports : int, optional
read_ports : int, optional
The number of read ports used when splitting process collection based on memory variable access.
The number of read ports used when splitting process collection based on
memory variable access.
write_ports : int, optional
write_ports : int, optional
The number of write ports used when splitting process collection based on memory variable access.
The number of write ports used when splitting process collection based on
memory variable access.
total_ports : int, optional
total_ports : int, optional
The total number of ports used when splitting process collection based on memory variable access.
The total number of ports used when splitting process collection based on
memory variable access.
Returns
Returns
-------
-------
...
@@ -436,29 +450,30 @@ class ProcessCollection:
...
@@ -436,29 +450,30 @@ class ProcessCollection:
read_ports
:
int
,
read_ports
:
int
,
write_ports
:
int
,
write_ports
:
int
,
total_ports
:
int
,
total_ports
:
int
,
coloring_strategy
:
str
=
"
DSATUR
"
,
coloring_strategy
:
str
=
"
saturation_largest_first
"
,
)
->
Set
[
"
ProcessCollection
"
]:
)
->
Set
[
"
ProcessCollection
"
]:
"""
"""
Parameters
Parameters
----------
----------
read_ports : int
read_ports : int
The number of read ports used when splitting process collection based on memory variable access.
The number of read ports used when splitting process collection based on
memory variable access.
write_ports : int
write_ports : int
The number of write ports used when splitting process collection based on memory variable access.
The number of write ports used when splitting process collection based on
memory variable access.
total_ports : int
total_ports : int
The total number of ports used when splitting process collection based on memory variable access.
The total number of ports used when splitting process collection based on
coloring_strategy : str, default:
'
DSATUR
'
memory variable access.
Node ordering strategy passed to nx.coloring.greedy_color()
coloring_strategy : str, default:
'
saturation_largest_first
'
Node ordering strategy passed to :func:`networkx.coloring.greedy_color`
One of
One of
* `
'
largest_first
'
`
*
'
largest_first
'
* `
'
random_sequential
'
`
*
'
random_sequential
'
* `
'
smallest_last
'
`
*
'
smallest_last
'
* `
'
independent_set
'
`
*
'
independent_set
'
* `
'
connected_sequential_bfs
'
`
*
'
connected_sequential_bfs
'
* `
'
connected_sequential_dfs
'
`
*
'
connected_sequential_dfs
'
or
'
connected_sequential
'
* `
'
connected_sequential
'
` (alias for the previous strategy)
*
'
saturation_largest_first
'
or
'
DSATUR
'
* `
'
saturation_largest_first
'
`
* `
'
DSATUR
'
` (alias for the saturation_largest_first strategy)
"""
"""
# Create new exclusion graph. Nodes are Processes
# Create new exclusion graph. Nodes are Processes
exclusion_graph
=
self
.
create_exclusion_graph_from_ports
(
exclusion_graph
=
self
.
create_exclusion_graph_from_ports
(
...
@@ -475,11 +490,13 @@ class ProcessCollection:
...
@@ -475,11 +490,13 @@ class ProcessCollection:
)
->
Set
[
"
ProcessCollection
"
]:
)
->
Set
[
"
ProcessCollection
"
]:
"""
"""
Split :class:`Process` objects into a set of :class:`ProcessesCollection` objects based on a provided graph coloring.
Split :class:`Process` objects into a set of :class:`ProcessesCollection` objects based on a provided graph coloring.
Resulting :class:`ProcessCollection` will have the same schedule time and cyclic propoery as self.
Resulting :class:`ProcessCollection` will have the same schedule time and cyclic
property as self.
Parameters
Parameters
----------
----------
coloring :
D
ict
[Process, int]
coloring :
d
ict
Process->int (color) mappings
Process->int (color) mappings
Returns
Returns
...
@@ -496,8 +513,8 @@ class ProcessCollection:
...
@@ -496,8 +513,8 @@ class ProcessCollection:
def
_repr_svg_
(
self
)
->
str
:
def
_repr_svg_
(
self
)
->
str
:
"""
"""
Generate an SVG_ of the resource collection. This is automatically displayed in
e.g.
Generate an SVG_ of the resource collection. This is automatically displayed in
Jupyter Qt console.
e.g.
Jupyter Qt console.
"""
"""
fig
,
ax
=
plt
.
subplots
()
fig
,
ax
=
plt
.
subplots
()
self
.
draw_lifetime_chart
(
ax
,
show_markers
=
False
)
self
.
draw_lifetime_chart
(
ax
,
show_markers
=
False
)
...
...
This diff is collapsed.
Click to expand it.
b_asic/signal_generator.py
+
2
−
0
View file @
5d34f8ab
...
@@ -165,7 +165,9 @@ class ZeroPad(SignalGenerator):
...
@@ -165,7 +165,9 @@ class ZeroPad(SignalGenerator):
class
FromFile
(
SignalGenerator
):
class
FromFile
(
SignalGenerator
):
"""
"""
Signal generator that reads from file and pads a sequence with zeros.
Signal generator that reads from file and pads a sequence with zeros.
File should be of type .txt or .csv and contain a single column vector
File should be of type .txt or .csv and contain a single column vector
Parameters
Parameters
----------
----------
path : string
path : string
...
...
This diff is collapsed.
Click to expand it.
test/test_simulation.py
+
1
−
0
View file @
5d34f8ab
...
@@ -2,6 +2,7 @@ import numpy as np
...
@@ -2,6 +2,7 @@ import numpy as np
import
pytest
import
pytest
from
b_asic
import
Simulation
from
b_asic
import
Simulation
from
b_asic._b_asic
import
FastSimulation
as
Simulation
class
TestRunFor
:
class
TestRunFor
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment