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
b7624227
Commit
b7624227
authored
1 year ago
by
Oscar Gustafsson
Browse files
Options
Downloads
Patches
Plain Diff
Add support for operator processcollections
parent
595bd54f
Branches
operationspc2
No related tags found
1 merge request
!290
Add support for operator processcollections
Pipeline
#94130
passed
1 year ago
Stage: test
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
b_asic/process.py
+6
-6
6 additions, 6 deletions
b_asic/process.py
b_asic/resources.py
+27
-1
27 additions, 1 deletion
b_asic/resources.py
b_asic/schedule.py
+24
-5
24 additions, 5 deletions
b_asic/schedule.py
examples/secondorderdirectformiir.py
+2
-0
2 additions, 0 deletions
examples/secondorderdirectformiir.py
with
59 additions
and
12 deletions
b_asic/process.py
+
6
−
6
View file @
b7624227
...
...
@@ -29,8 +29,8 @@ class Process:
self
.
_start_time
=
start_time
self
.
_execution_time
=
execution_time
if
name
is
None
:
self
.
_name
=
f
"
Proc.
{
P
lainMemoryVariable
.
_name_cnt
}
"
P
lainMemoryVariable
.
_name_cnt
+=
1
self
.
_name
=
f
"
Proc.
{
P
rocess
.
_name_cnt
}
"
P
rocess
.
_name_cnt
+=
1
else
:
self
.
_name
=
name
...
...
@@ -87,12 +87,12 @@ class OperatorProcess(Process):
execution_time
=
operation
.
execution_time
if
execution_time
is
None
:
raise
ValueError
(
"
Operation {operation!r} does not have an execution time specified!
"
f
"
Operation
{
operation
!r}
does not have an execution time specified!
"
)
super
().
__init__
(
start_time
,
execution_time
,
name
=
name
,
name
=
name
or
operation
.
name
or
operation
.
graph_id
,
)
self
.
_operation
=
operation
...
...
@@ -109,8 +109,8 @@ class MemoryVariable(Process):
write_port : :class:`~b_asic.port.OutputPort`
The OutputPort that the memory variable originates from.
reads : dict
Dictionary with :class:`~b_asic.port.InputPort` that reads the memory variable
as key and
for how long after the *write_time* it will read.
Dictionary with :class:`~b_asic.port.InputPort` that reads the memory variable
as key and
for how long after the *write_time* it will read.
name : str, optional
The name of the process.
"""
...
...
This diff is collapsed.
Click to expand it.
b_asic/resources.py
+
27
−
1
View file @
b7624227
...
...
@@ -9,7 +9,8 @@ from matplotlib.axes import Axes
from
matplotlib.ticker
import
MaxNLocator
from
b_asic._preferences
import
LATENCY_COLOR
from
b_asic.process
import
MemoryVariable
,
PlainMemoryVariable
,
Process
from
b_asic.process
import
MemoryVariable
,
OperatorProcess
,
PlainMemoryVariable
,
Process
from
b_asic.types
import
TypeName
# Default latency coloring RGB tuple
_LATENCY_COLOR
=
tuple
(
c
/
255
for
c
in
LATENCY_COLOR
)
...
...
@@ -1120,3 +1121,28 @@ class ProcessCollection:
write_ports
=
write_ports
,
total_ports
=
total_ports
,
)
def
get_by_type_name
(
self
,
type_name
:
TypeName
)
->
"
ProcessCollection
"
:
"""
Return a ProcessCollection with only a given type of operations.
Parameters
----------
type_name : TypeName
The type_name of the operation.
Returns
-------
ProcessCollection
"""
return
ProcessCollection
(
{
process
for
process
in
self
.
_collection
if
isinstance
(
process
,
OperatorProcess
)
and
process
.
_operation
.
type_name
()
==
type_name
},
self
.
_schedule_time
,
self
.
_cyclic
,
)
This diff is collapsed.
Click to expand it.
b_asic/schedule.py
+
24
−
5
View file @
b7624227
...
...
@@ -31,7 +31,7 @@ from b_asic._preferences import (
from
b_asic.graph_component
import
GraphID
from
b_asic.operation
import
Operation
from
b_asic.port
import
InputPort
,
OutputPort
from
b_asic.process
import
MemoryVariable
from
b_asic.process
import
MemoryVariable
,
OperatorProcess
from
b_asic.resources
import
ProcessCollection
from
b_asic.signal_flow_graph
import
SFG
from
b_asic.special_operations
import
Delay
,
Input
,
Output
...
...
@@ -294,13 +294,13 @@ class Schedule:
@property
def
start_times
(
self
)
->
Dict
[
GraphID
,
int
]:
"""
The start times of the operations in the
current
schedule.
"""
"""
The start times of the operations in the schedule.
"""
return
self
.
_start_times
@property
def
laps
(
self
)
->
Dict
[
GraphID
,
int
]:
"""
The number of laps for the start times of the operations in the
current
schedule.
The number of laps for the start times of the operations in the schedule.
"""
return
self
.
_laps
...
...
@@ -674,8 +674,8 @@ class Schedule:
]
+
cast
(
int
,
source_port
.
latency_offset
)
self
.
_remove_delays
()
def
_get_memory_variables_list
(
self
)
->
List
[
'
MemoryVariable
'
]:
ret
:
List
[
'
MemoryVariable
'
]
=
[]
def
_get_memory_variables_list
(
self
)
->
List
[
MemoryVariable
]:
ret
:
List
[
MemoryVariable
]
=
[]
for
graph_id
,
start_time
in
self
.
_start_times
.
items
():
slacks
=
self
.
_forward_slacks
(
graph_id
)
for
outport
,
signals
in
slacks
.
items
():
...
...
@@ -707,6 +707,25 @@ class Schedule:
set
(
self
.
_get_memory_variables_list
()),
self
.
schedule_time
)
def
get_operations
(
self
)
->
ProcessCollection
:
"""
Return a :class:`~b_asic.resources.ProcessCollection` containing all
operations.
Returns
-------
ProcessCollection
"""
return
ProcessCollection
(
{
OperatorProcess
(
start_time
,
self
.
_sfg
.
find_by_id
(
graph_id
))
for
graph_id
,
start_time
in
self
.
_start_times
.
items
()
},
self
.
schedule_time
,
self
.
cyclic
,
)
def
_get_y_position
(
self
,
graph_id
,
operation_height
=
1.0
,
operation_gap
=
None
)
->
float
:
...
...
This diff is collapsed.
Click to expand it.
examples/secondorderdirectformiir.py
+
2
−
0
View file @
b7624227
...
...
@@ -35,6 +35,8 @@ sfg.set_latency_of_type(ConstantMultiplication.type_name(), 2)
sfg
.
set_latency_of_type
(
Addition
.
type_name
(),
1
)
sfg
.
set_execution_time_of_type
(
ConstantMultiplication
.
type_name
(),
1
)
sfg
.
set_execution_time_of_type
(
Addition
.
type_name
(),
1
)
sfg
.
set_execution_time_of_type
(
Input
.
type_name
(),
1
)
sfg
.
set_execution_time_of_type
(
Output
.
type_name
(),
1
)
# %%
# Create schedule
...
...
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