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
078ac59c
Commit
078ac59c
authored
2 years ago
by
Mikael Henriksson
Browse files
Options
Downloads
Patches
Plain Diff
Add left_edge_cell_assignment method to ProcessCollection
parent
a56cb4e2
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!244
WIP: VHDL code generation for register and memory based storages
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
b_asic/resources.py
+108
-22
108 additions, 22 deletions
b_asic/resources.py
test/baseline/test_left_edge_cell_assignment.png
+0
-0
0 additions, 0 deletions
test/baseline/test_left_edge_cell_assignment.png
test/test_resources.py
+9
-0
9 additions, 0 deletions
test/test_resources.py
with
117 additions
and
22 deletions
b_asic/resources.py
+
108
−
22
View file @
078ac59c
...
@@ -68,7 +68,6 @@ def draw_exclusion_graph_coloring(
...
@@ -68,7 +68,6 @@ def draw_exclusion_graph_coloring(
Returns
Returns
-------
-------
None
None
"""
"""
COLOR_LIST
=
[
COLOR_LIST
=
[
'
#aa0000
'
,
'
#aa0000
'
,
...
@@ -151,6 +150,7 @@ class ProcessCollection:
...
@@ -151,6 +150,7 @@ class ProcessCollection:
marker_read
:
str
=
"
X
"
,
marker_read
:
str
=
"
X
"
,
marker_write
:
str
=
"
o
"
,
marker_write
:
str
=
"
o
"
,
show_markers
:
bool
=
True
,
show_markers
:
bool
=
True
,
row
:
Optional
[
int
]
=
None
,
):
):
"""
"""
Plot a process variable lifetime chart.
Plot a process variable lifetime chart.
...
@@ -173,6 +173,10 @@ class ProcessCollection:
...
@@ -173,6 +173,10 @@ class ProcessCollection:
Marker at read time in the lifetime chart.
Marker at read time in the lifetime chart.
show_markers : bool, default True
show_markers : bool, default True
Show markers at read and write times.
Show markers at read and write times.
row : int, optional
Render all processes in this collection on a specified row in the matplotlib axes object.
Defaults to None, which renders all processes on separate rows. This option is useful when
drawing cell assignments.
Returns
Returns
-------
-------
...
@@ -198,6 +202,7 @@ class ProcessCollection:
...
@@ -198,6 +202,7 @@ class ProcessCollection:
# Generate the life-time chart
# Generate the life-time chart
for
i
,
process
in
enumerate
(
_sorted_nicely
(
self
.
_collection
)):
for
i
,
process
in
enumerate
(
_sorted_nicely
(
self
.
_collection
)):
bar_row
=
i
if
row
==
None
else
row
bar_start
=
process
.
start_time
%
self
.
_schedule_time
bar_start
=
process
.
start_time
%
self
.
_schedule_time
bar_end
=
process
.
start_time
+
process
.
execution_time
bar_end
=
process
.
start_time
+
process
.
execution_time
bar_end
=
(
bar_end
=
(
...
@@ -206,52 +211,55 @@ class ProcessCollection:
...
@@ -206,52 +211,55 @@ class ProcessCollection:
else
bar_end
%
self
.
_schedule_time
else
bar_end
%
self
.
_schedule_time
)
)
if
show_markers
:
if
show_markers
:
_ax
.
scatter
(
_ax
.
scatter
(
# type: ignore
x
=
bar_start
,
x
=
bar_start
,
y
=
i
+
1
,
y
=
bar_row
+
1
,
marker
=
marker_write
,
marker
=
marker_write
,
color
=
marker_color
,
color
=
marker_color
,
zorder
=
10
,
zorder
=
10
,
)
)
_ax
.
scatter
(
_ax
.
scatter
(
# type: ignore
x
=
bar_end
,
x
=
bar_end
,
y
=
i
+
1
,
y
=
bar_row
+
1
,
marker
=
marker_read
,
marker
=
marker_read
,
color
=
marker_color
,
color
=
marker_color
,
zorder
=
10
,
zorder
=
10
,
)
)
if
bar_end
>=
bar_start
:
if
bar_end
>=
bar_start
:
_ax
.
broken_barh
(
_ax
.
broken_barh
(
# type: ignore
[(
PAD_L
+
bar_start
,
bar_end
-
bar_start
-
PAD_L
-
PAD_R
)],
[(
PAD_L
+
bar_start
,
bar_end
-
bar_start
-
PAD_L
-
PAD_R
)],
(
i
+
0.55
,
0.9
),
(
bar_row
+
0.55
,
0.9
),
color
=
bar_color
,
color
=
bar_color
,
)
)
else
:
# bar_end < bar_start
else
:
# bar_end < bar_start
_ax
.
broken_barh
(
_ax
.
broken_barh
(
# type: ignore
[
[
(
(
PAD_L
+
bar_start
,
PAD_L
+
bar_start
,
self
.
_schedule_time
-
bar_start
-
PAD_L
,
self
.
_schedule_time
-
bar_start
-
PAD_L
,
)
)
],
],
(
i
+
0.55
,
0.9
),
(
bar_row
+
0.55
,
0.9
),
color
=
bar_color
,
color
=
bar_color
,
)
)
_ax
.
broken_barh
(
_ax
.
broken_barh
(
# type: ignore
[(
0
,
bar_end
-
PAD_R
)],
(
i
+
0.55
,
0.9
),
color
=
bar_color
[(
0
,
bar_end
-
PAD_R
)],
(
bar_row
+
0.55
,
0.9
),
color
=
bar_color
)
)
if
show_name
:
if
show_name
:
_ax
.
annotate
(
_ax
.
annotate
(
# type: ignore
str
(
process
),
str
(
process
),
(
bar_start
+
PAD_L
+
0.025
,
i
+
1.00
),
(
bar_start
+
PAD_L
+
0.025
,
bar_row
+
1.00
),
va
=
"
center
"
,
va
=
"
center
"
,
)
)
_ax
.
grid
(
True
)
_ax
.
grid
(
True
)
# type: ignore
_ax
.
xaxis
.
set_major_locator
(
MaxNLocator
(
integer
=
True
))
_ax
.
xaxis
.
set_major_locator
(
MaxNLocator
(
integer
=
True
))
# type: ignore
_ax
.
yaxis
.
set_major_locator
(
MaxNLocator
(
integer
=
True
))
_ax
.
yaxis
.
set_major_locator
(
MaxNLocator
(
integer
=
True
))
# type: ignore
_ax
.
set_xlim
(
0
,
self
.
_schedule_time
)
_ax
.
set_xlim
(
0
,
self
.
_schedule_time
)
# type: ignore
_ax
.
set_ylim
(
0.25
,
len
(
self
.
_collection
)
+
0.75
)
if
row
==
None
:
_ax
.
set_ylim
(
0.25
,
len
(
self
.
_collection
)
+
0.75
)
# type: ignore
else
:
pass
return
_ax
return
_ax
def
create_exclusion_graph_from_ports
(
def
create_exclusion_graph_from_ports
(
...
@@ -413,7 +421,7 @@ class ProcessCollection:
...
@@ -413,7 +421,7 @@ class ProcessCollection:
total_ports
:
Optional
[
int
]
=
None
,
total_ports
:
Optional
[
int
]
=
None
,
)
->
Set
[
"
ProcessCollection
"
]:
)
->
Set
[
"
ProcessCollection
"
]:
"""
"""
Split this process storage based on some heuristic.
Split this process storage based on
concurrent read/write times according to
some heuristic.
Parameters
Parameters
----------
----------
...
@@ -528,10 +536,9 @@ class ProcessCollection:
...
@@ -528,10 +536,9 @@ class ProcessCollection:
e.g. Jupyter Qt console.
e.g. Jupyter Qt console.
"""
"""
fig
,
ax
=
plt
.
subplots
()
fig
,
ax
=
plt
.
subplots
()
self
.
plot
(
ax
,
show_markers
=
False
)
self
.
plot
(
ax
=
ax
,
show_markers
=
False
)
f
=
io
.
StringIO
()
f
=
io
.
StringIO
()
fig
.
savefig
(
f
,
format
=
"
svg
"
)
fig
.
savefig
(
f
,
format
=
"
svg
"
)
# type: ignore
return
f
.
getvalue
()
return
f
.
getvalue
()
def
__repr__
(
self
):
def
__repr__
(
self
):
...
@@ -539,3 +546,82 @@ class ProcessCollection:
...
@@ -539,3 +546,82 @@ class ProcessCollection:
f
"
ProcessCollection(
{
self
.
_collection
}
,
{
self
.
_schedule_time
}
,
"
f
"
ProcessCollection(
{
self
.
_collection
}
,
{
self
.
_schedule_time
}
,
"
f
"
{
self
.
_cyclic
}
)
"
f
"
{
self
.
_cyclic
}
)
"
)
)
def
__iter__
(
self
):
return
iter
(
self
.
_collection
)
def
graph_color_cell_assignment
(
self
,
coloring_strategy
:
str
=
"
saturation_largest_first
"
,
)
->
Dict
[
int
,
"
ProcessCollection
"
]:
"""
graph_color_cell_assignment.
Parameters
----------
Returns
-------
Dict[int,
"
ProcessCollection
"
]
"""
cell_assignment
:
Dict
[
int
,
ProcessCollection
]
=
dict
()
exclusion_graph
=
self
.
create_exclusion_graph_from_execution_time
()
coloring
:
Dict
[
Process
,
int
]
=
nx
.
coloring
.
greedy_color
(
exclusion_graph
,
strategy
=
coloring_strategy
)
return
cell_assignment
def
left_edge_cell_assignment
(
self
)
->
Dict
[
int
,
"
ProcessCollection
"
]:
"""
Perform left edge cell assignment of this process collection.
Returns
-------
Dict[Process, int]
"""
next_empty_cell
=
0
cell_assignment
:
Dict
[
int
,
ProcessCollection
]
=
dict
()
for
next_process
in
sorted
(
self
):
insert_to_new_cell
=
True
for
cell
in
cell_assignment
:
insert_to_this_cell
=
True
for
process
in
cell_assignment
[
cell
]:
next_process_stop_time
=
(
next_process
.
start_time
+
next_process
.
execution_time
)
%
self
.
_schedule_time
if
(
next_process
.
start_time
<
process
.
start_time
+
process
.
execution_time
or
next_process_stop_time
<
next_process
.
start_time
and
next_process_stop_time
>
process
.
start_time
):
insert_to_this_cell
=
False
break
if
insert_to_this_cell
:
cell_assignment
[
cell
].
add_process
(
next_process
)
insert_to_new_cell
=
False
break
if
insert_to_new_cell
:
cell_assignment
[
next_empty_cell
]
=
ProcessCollection
(
collection
=
set
(),
schedule_time
=
self
.
_schedule_time
)
cell_assignment
[
next_empty_cell
].
add_process
(
next_process
)
next_empty_cell
+=
1
return
cell_assignment
def
generate_memory_based_storage_vhdl
(
self
,
filename
:
str
,
):
"""
Generate VHDL code for memory based storage of processes (MemoryVariables).
Parameters
----------
filename : str
Filename of output file.
"""
# Check that hardware can be generated for the ProcessCollection...
raise
NotImplementedError
(
"
Not implemented yet!
"
)
This diff is collapsed.
Click to expand it.
test/baseline/test_left_edge_cell_assignment.png
0 → 100644
+
0
−
0
View file @
078ac59c
22.5 KiB
This diff is collapsed.
Click to expand it.
test/test_resources.py
+
9
−
0
View file @
078ac59c
...
@@ -29,6 +29,15 @@ class TestProcessCollectionPlainMemoryVariable:
...
@@ -29,6 +29,15 @@ class TestProcessCollectionPlainMemoryVariable:
)
)
assert
len
(
collection_split
)
==
3
assert
len
(
collection_split
)
==
3
@pytest.mark.mpl_image_compare
(
style
=
'
mpl20
'
)
def
test_left_edge_cell_assignment
(
self
,
simple_collection
:
ProcessCollection
):
fig
,
ax
=
plt
.
subplots
(
1
,
2
)
assignment
=
simple_collection
.
left_edge_cell_assignment
()
for
cell
in
assignment
.
keys
():
assignment
[
cell
].
plot
(
ax
=
ax
[
1
],
row
=
cell
)
simple_collection
.
plot
(
ax
[
0
])
return
fig
# Issue: #175
# Issue: #175
def
test_interleaver_issue175
(
self
):
def
test_interleaver_issue175
(
self
):
with
open
(
'
test/fixtures/interleaver-two-port-issue175.p
'
,
'
rb
'
)
as
f
:
with
open
(
'
test/fixtures/interleaver-two-port-issue175.p
'
,
'
rb
'
)
as
f
:
...
...
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