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
Merge requests
!449
Implement Tmin
Code
Review changes
Check out branch
Download
Patches
Plain diff
Closed
Implement Tmin
tmin
into
master
Overview
5
Commits
1
Pipelines
1
Changes
1
Closed
Samuel Fagerlund
requested to merge
tmin
into
master
1 year ago
Overview
5
Commits
1
Pipelines
1
Changes
1
Expand
Closes
#93 (closed)
0
0
Merge request reports
Compare
master
master (base)
and
latest version
latest version
2786b9be
1 commit,
1 year ago
1 file
+
89
−
1
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
b_asic/signal_flow_graph.py
+
89
−
1
Options
@@ -1688,13 +1688,101 @@ class SFG(AbstractOperation):
return
Schedule
(
self
,
algorithm
=
"
ASAP
"
).
schedule_time
def
dfs
(
self
,
graph
,
start
,
end
):
"""
Find loop(s) in graph
Parameters
----------
graph : dictionary
The dictionary that are to be searched for loops.
start : key in dictionary graph
The
"
node
"
in the dictionary that are set as the start point.
end : key in dictionary graph
The
"
node
"
in the dictionary that are set as the end point.
"""
fringe
=
[(
start
,
[])]
while
fringe
:
state
,
path
=
fringe
.
pop
()
if
path
and
state
==
end
:
yield
path
continue
for
next_state
in
graph
[
state
]:
if
next_state
in
path
:
continue
fringe
.
append
((
next_state
,
path
+
[
next_state
]))
def
iteration_period_bound
(
self
)
->
int
:
"""
Return the iteration period bound of the SFG.
If -1, the SFG does not have any loops and therefore no iteration period bound.
Returns
-------
The iteration period bound.
"""
raise
NotImplementedError
()
inputs_used
=
[]
for
used_input
in
self
.
_used_ids
:
if
'
in
'
in
str
(
used_input
):
used_input
=
used_input
.
replace
(
"
in
"
,
""
)
inputs_used
.
append
(
int
(
used_input
))
if
inputs_used
==
[]:
raise
ValueError
(
"
No inputs to sfg
"
)
for
input
in
inputs_used
:
input_op
=
self
.
_input_operations
[
input
]
queue
:
Deque
[
Operation
]
=
deque
([
input_op
])
visited
:
Set
[
Operation
]
=
{
input_op
}
dict_of_sfg
=
{}
while
queue
:
op
=
queue
.
popleft
()
for
output_port
in
op
.
outputs
:
if
not
(
isinstance
(
op
,
Input
)
or
isinstance
(
op
,
Output
)):
dict_of_sfg
[
op
.
graph_id
]
=
[]
for
signal
in
output_port
.
signals
:
if
signal
.
destination
is
not
None
:
new_op
=
signal
.
destination
.
operation
if
not
(
isinstance
(
op
,
Input
)
or
isinstance
(
op
,
Output
)):
if
not
isinstance
(
new_op
,
Output
):
dict_of_sfg
[
op
.
graph_id
]
+=
[
new_op
.
graph_id
]
if
new_op
not
in
visited
:
queue
.
append
(
new_op
)
visited
.
add
(
new_op
)
else
:
raise
ValueError
(
"
Destination does not exist
"
)
if
dict_of_sfg
==
{}:
raise
ValueError
(
"
the SFG does not have any loops and therefore no iteration period bound.
"
)
cycles
=
[
[
node
]
+
path
for
node
in
dict_of_sfg
for
path
in
self
.
dfs
(
dict_of_sfg
,
node
,
node
)
]
if
cycles
==
[]:
return
-
1
op_and_latency
=
{}
for
op
in
self
.
operations
:
for
lista
in
cycles
:
for
element
in
lista
:
if
op
.
type_name
()
not
in
op_and_latency
:
op_and_latency
[
op
.
type_name
()]
=
op
.
latency
t_l_values
=
[]
for
loop
in
cycles
:
loop
.
pop
()
time_of_loop
=
0
number_of_t_in_loop
=
0
for
element
in
loop
:
if
''
.
join
([
i
for
i
in
element
if
not
i
.
isdigit
()])
==
'
t
'
:
number_of_t_in_loop
+=
1
for
key
,
item
in
op_and_latency
.
items
():
if
key
in
element
:
time_of_loop
+=
item
if
number_of_t_in_loop
==
0
or
number_of_t_in_loop
==
1
:
t_l_values
.
append
(
time_of_loop
)
else
:
t_l_values
.
append
(
time_of_loop
/
number_of_t_in_loop
)
return
max
(
t_l_values
)
def
edit
(
self
)
->
Dict
[
str
,
"
SFG
"
]:
"""
Edit SFG in GUI.
"""
Loading