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
5eec2b7f
Commit
5eec2b7f
authored
2 years ago
by
Oscar Gustafsson
Browse files
Options
Downloads
Patches
Plain Diff
Unify operation shapes in SFG and precendence graph
parent
13b52f73
No related branches found
No related tags found
1 merge request
!197
Unify operation shapes in SFG and precendence graph
Pipeline
#89846
passed
2 years ago
Stage: test
Stage: deploy
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
b_asic/signal_flow_graph.py
+28
-10
28 additions, 10 deletions
b_asic/signal_flow_graph.py
test/test_sfg.py
+26
-23
26 additions, 23 deletions
test/test_sfg.py
with
54 additions
and
33 deletions
b_asic/signal_flow_graph.py
+
28
−
10
View file @
5eec2b7f
...
...
@@ -48,6 +48,16 @@ from b_asic.special_operations import Delay, Input, Output
DelayQueue
=
List
[
Tuple
[
str
,
ResultKey
,
OutputPort
]]
_OPERATION_SHAPE
:
DefaultDict
[
TypeName
,
str
]
=
defaultdict
(
lambda
:
"
ellipse
"
)
_OPERATION_SHAPE
.
update
(
{
Input
.
type_name
():
"
cds
"
,
Output
.
type_name
():
"
cds
"
,
Delay
.
type_name
():
"
square
"
,
}
)
class
GraphIDGenerator
:
"""
Generates Graph IDs for objects.
"""
...
...
@@ -813,7 +823,7 @@ class SFG(AbstractOperation):
for
i
in
range
(
len
(
p_list
)):
ports
=
p_list
[
i
]
with
pg
.
subgraph
(
name
=
f
"
cluster_
{
i
}
"
)
as
sub
:
sub
.
attr
(
label
=
f
"
N
{
i
+
1
}
"
)
sub
.
attr
(
label
=
f
"
N
{
i
}
"
)
for
port
in
ports
:
portstr
=
f
"
{
port
.
operation
.
graph_id
}
.
{
port
.
index
}
"
if
port
.
operation
.
output_count
>
1
:
...
...
@@ -821,7 +831,10 @@ class SFG(AbstractOperation):
else
:
sub
.
node
(
portstr
,
shape
=
'
rectangle
'
,
label
=
port
.
operation
.
graph_id
,
height
=
"
0.1
"
,
width
=
"
0.1
"
,
)
# Creates edges for each output port and creates nodes for each operation
# and edges for them as well
...
...
@@ -830,14 +843,20 @@ class SFG(AbstractOperation):
for
port
in
ports
:
for
signal
in
port
.
signals
:
destination
=
cast
(
InputPort
,
signal
.
destination
)
if
destination
.
operation
.
type_name
()
==
Delay
.
type_name
(
):
if
isinstance
(
destination
.
operation
,
Delay
):
dest_node
=
destination
.
operation
.
graph_id
+
"
In
"
else
:
dest_node
=
destination
.
operation
.
graph_id
dest_label
=
destination
.
operation
.
graph_id
node_node
=
f
"
{
port
.
operation
.
graph_id
}
.
{
port
.
index
}
"
pg
.
edge
(
node_node
,
dest_node
)
pg
.
node
(
dest_node
,
label
=
dest_label
,
shape
=
"
square
"
)
pg
.
node
(
dest_node
,
label
=
dest_label
,
shape
=
_OPERATION_SHAPE
[
destination
.
operation
.
type_name
()
],
)
if
port
.
operation
.
type_name
()
==
Delay
.
type_name
():
source_node
=
port
.
operation
.
graph_id
+
"
Out
"
else
:
...
...
@@ -845,7 +864,11 @@ class SFG(AbstractOperation):
source_label
=
port
.
operation
.
graph_id
node_node
=
f
"
{
port
.
operation
.
graph_id
}
.
{
port
.
index
}
"
pg
.
edge
(
source_node
,
node_node
)
pg
.
node
(
source_node
,
label
=
source_label
,
shape
=
"
square
"
)
pg
.
node
(
source_node
,
label
=
source_label
,
shape
=
_OPERATION_SHAPE
[
port
.
operation
.
type_name
()],
)
return
pg
...
...
@@ -1417,12 +1440,7 @@ class SFG(AbstractOperation):
destination
.
operation
.
graph_id
,
)
else
:
if
isinstance
(
op
,
Delay
):
dg
.
node
(
op
.
graph_id
,
shape
=
"
square
"
)
elif
isinstance
(
op
,
(
Input
,
Output
)):
dg
.
node
(
op
.
graph_id
,
shape
=
"
cds
"
)
else
:
dg
.
node
(
op
.
graph_id
)
dg
.
node
(
op
.
graph_id
,
shape
=
_OPERATION_SHAPE
[
op
.
type_name
()])
return
dg
def
_repr_mimebundle_
(
self
,
include
=
None
,
exclude
=
None
):
...
...
This diff is collapsed.
Click to expand it.
test/test_sfg.py
+
26
−
23
View file @
5eec2b7f
...
...
@@ -1376,21 +1376,23 @@ class TestGetComponentsOfType:
class
TestPrecedenceGraph
:
def
test_precedence_graph
(
self
,
sfg_simple_filter
):
res
=
(
"
digraph {
\n\t
rankdir=LR
\n\t
subgraph cluster_0
"
"
{
\n\t\t
label=N1
\n\t\t\"
in1.0
\"
[label=in1]
\n\t\t\"
t1.0
\"
"
"
[label=t1]
\n\t
}
\n\t
subgraph cluster_1
"
"
{
\n\t\t
label=N2
\n\t\t\"
cmul1.0
\"
[label=cmul1]
\n\t
}
\n\t
subgraph
"
"
cluster_2 {
\n\t\t
label=N3
\n\t\t\"
add1.0
\"
"
"
[label=add1]
\n\t
}
\n\t\"
in1.0
\"
-> add1
\n\t
add1 [label=add1
"
"
shape=square]
\n\t
in1 ->
\"
in1.0
\"\n\t
in1 [label=in1
"
"
shape=square]
\n\t\"
t1.0
\"
-> cmul1
\n\t
cmul1 [label=cmul1
"
"
shape=square]
\n\t\"
t1.0
\"
-> out1
\n\t
out1 [label=out1
"
"
shape=square]
\n\t
t1Out ->
\"
t1.0
\"\n\t
t1Out [label=t1
"
"
shape=square]
\n\t\"
cmul1.0
\"
-> add1
\n\t
add1 [label=add1
"
"
shape=square]
\n\t
cmul1 ->
\"
cmul1.0
\"\n\t
cmul1 [label=cmul1
"
"
shape=square]
\n\t\"
add1.0
\"
-> t1In
\n\t
t1In [label=t1
"
"
shape=square]
\n\t
add1 ->
\"
add1.0
\"\n\t
add1 [label=add1
"
"
shape=square]
\n
}
"
'
digraph {
\n\t
rankdir=LR
\n\t
subgraph cluster_0
'
'
{
\n\t\t
label=N0
\n\t\t
"
in1.0
"
[label=in1 height=0.1
'
'
shape=rectangle width=0.1]
\n\t\t
"
t1.0
"
[label=t1 height=0.1
'
'
shape=rectangle width=0.1]
\n\t
}
\n\t
subgraph cluster_1
'
'
{
\n\t\t
label=N1
\n\t\t
"
cmul1.0
"
[label=cmul1 height=0.1
'
'
shape=rectangle width=0.1]
\n\t
}
\n\t
subgraph cluster_2
'
'
{
\n\t\t
label=N2
\n\t\t
"
add1.0
"
[label=add1 height=0.1
'
'
shape=rectangle width=0.1]
\n\t
}
\n\t
"
in1.0
"
-> add1
\n\t
add1
'
'
[label=add1 shape=ellipse]
\n\t
in1 ->
"
in1.0
"
\n\t
in1 [label=in1
'
'
shape=cds]
\n\t
"
t1.0
"
-> cmul1
\n\t
cmul1 [label=cmul1
'
'
shape=ellipse]
\n\t
"
t1.0
"
-> out1
\n\t
out1 [label=out1
'
'
shape=cds]
\n\t
t1Out ->
"
t1.0
"
\n\t
t1Out [label=t1
'
'
shape=square]
\n\t
"
cmul1.0
"
-> add1
\n\t
add1 [label=add1
'
'
shape=ellipse]
\n\t
cmul1 ->
"
cmul1.0
"
\n\t
cmul1 [label=cmul1
'
'
shape=ellipse]
\n\t
"
add1.0
"
-> t1In
\n\t
t1In [label=t1
'
'
shape=square]
\n\t
add1 ->
"
add1.0
"
\n\t
add1 [label=add1
'
'
shape=ellipse]
\n
}
'
)
assert
sfg_simple_filter
.
precedence_graph
().
source
in
(
res
,
res
+
"
\n
"
)
...
...
@@ -1399,19 +1401,20 @@ class TestPrecedenceGraph:
class
TestSFGGraph
:
def
test_sfg
(
self
,
sfg_simple_filter
):
res
=
(
"
digraph {
\n\t
rankdir=LR
\n\t
in1 [shape=cds]
\n\t
in1 ->
"
"
add1
\n\t
out1
[shape=cds]
\n\t
t1 -> out1
\n\t
add1
\n\t
cmul1 ->
"
"
add1
\n\t
cmul1
\n\t
add1 -> t1
\n\t
t1
[shape=square]
\n\t
t1
"
"
-> cmul1
\n
}
"
'
digraph {
\n\t
rankdir=LR
\n\t
in1 [shape=cds]
\n\t
in1 ->
add1
\n\t
out1
'
'
[shape=cds]
\n\t
t1 -> out1
\n\t
add1
[shape=ellipse]
\n\t
cmul1 ->
'
'
add1
\n\t
cmul1
[shape=ellipse]
\n\t
add1 -> t1
\n\t
t1
'
'
[shape=square]
\n\t
t1
-> cmul1
\n
}
'
)
assert
sfg_simple_filter
.
sfg_digraph
().
source
in
(
res
,
res
+
"
\n
"
)
def
test_sfg_show_id
(
self
,
sfg_simple_filter
):
res
=
(
"
digraph {
\n\t
rankdir=LR
\n\t
in1 [shape=cds]
\n\t
in1 -> add1
"
"
[label=s1]
\n\t
out1 [shape=cds]
\n\t
t1 -> out1 [label=s2]
\n\t
add1
"
"
\n\t
cmul1 -> add1 [label=s3]
\n\t
cmul1
\n\t
add1 -> t1
"
"
[label=s4]
\n\t
t1 [shape=square]
\n\t
t1 -> cmul1 [label=s5]
\n
}
"
'
digraph {
\n\t
rankdir=LR
\n\t
in1 [shape=cds]
\n\t
in1 -> add1
'
'
[label=s1]
\n\t
out1 [shape=cds]
\n\t
t1 -> out1 [label=s2]
\n\t
add1
'
'
[shape=ellipse]
\n\t
cmul1 -> add1 [label=s3]
\n\t
cmul1
'
'
[shape=ellipse]
\n\t
add1 -> t1 [label=s4]
\n\t
t1
'
'
[shape=square]
\n\t
t1 -> cmul1 [label=s5]
\n
}
'
)
assert
sfg_simple_filter
.
sfg_digraph
(
show_id
=
True
).
source
in
(
...
...
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