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
35b9a1bf
Commit
35b9a1bf
authored
5 years ago
by
Oscar Gustafsson
Browse files
Options
Downloads
Patches
Plain Diff
Added get_sfg and show_sfg methods
parent
48178a0c
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!73
Added sfg and show_sfg methods
Pipeline
#16841
passed
5 years ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
b_asic/signal_flow_graph.py
+56
-1
56 additions, 1 deletion
b_asic/signal_flow_graph.py
with
56 additions
and
1 deletion
b_asic/signal_flow_graph.py
+
56
−
1
View file @
35b9a1bf
...
@@ -12,7 +12,7 @@ import itertools as it
...
@@ -12,7 +12,7 @@ import itertools as it
from
graphviz
import
Digraph
from
graphviz
import
Digraph
from
b_asic.port
import
SignalSourceProvider
,
OutputPort
from
b_asic.port
import
SignalSourceProvider
,
OutputPort
from
b_asic.operation
import
Operation
,
AbstractOperation
,
ResultKey
,
DelayMap
,
MutableResultMap
,
MutableDelayMap
from
b_asic.operation
import
Operation
,
AbstractOperation
,
ResultKey
,
MutableResultMap
,
MutableDelayMap
from
b_asic.signal
import
Signal
from
b_asic.signal
import
Signal
from
b_asic.graph_component
import
GraphID
,
GraphIDNumber
,
GraphComponent
,
Name
,
TypeName
from
b_asic.graph_component
import
GraphID
,
GraphIDNumber
,
GraphComponent
,
Name
,
TypeName
from
b_asic.special_operations
import
Input
,
Output
,
Delay
from
b_asic.special_operations
import
Input
,
Output
,
Delay
...
@@ -846,3 +846,58 @@ class SFG(AbstractOperation):
...
@@ -846,3 +846,58 @@ class SFG(AbstractOperation):
src
.
index
,
input_values
,
results
,
delays
,
key_base
,
bits_override
,
truncate
)
src
.
index
,
input_values
,
results
,
delays
,
key_base
,
bits_override
,
truncate
)
results
[
key
]
=
value
results
[
key
]
=
value
return
value
return
value
def
get_sfg
(
self
,
format
=
None
,
show_id
=
False
)
->
Digraph
:
"""
Returns a Digraph of the SFG. Can be directly displayed in IPython.
Parameters
----------
format : string, optional
File format of the generated graph. Output formats can be found at https://www.graphviz.org/doc/info/output.html
Most common are
"
pdf
"
,
"
eps
"
,
"
png
"
, and
"
svg
"
. Default is None which leads to PDF.
show_id : Boolean, optional
If True, the graph_id:s of signals are shown. The default is False.
Returns
-------
Digraph
Digraph of the SFG.
"""
if
format
is
not
None
:
pg
=
Digraph
(
format
=
format
)
else
:
pg
=
Digraph
()
pg
.
attr
(
rankdir
=
'
LR
'
)
for
op
in
self
.
_components_by_id
.
values
():
if
isinstance
(
op
,
Signal
):
if
show_id
:
pg
.
edge
(
op
.
source
.
operation
.
graph_id
,
op
.
destination
.
operation
.
graph_id
,
label
=
op
.
graph_id
)
else
:
pg
.
edge
(
op
.
source
.
operation
.
graph_id
,
op
.
destination
.
operation
.
graph_id
)
else
:
if
op
.
type_name
()
==
Delay
.
type_name
():
pg
.
node
(
op
.
graph_id
,
shape
=
'
square
'
)
else
:
pg
.
node
(
op
.
graph_id
)
return
pg
def
show_sfg
(
self
,
format
=
None
,
show_id
=
False
)
->
None
:
"""
Shows a visual representation of the SFG using the default system viewer.
Parameters
----------
format : string, optional
File format of the generated graph. Output formats can be found at https://www.graphviz.org/doc/info/output.html
Most common are
"
pdf
"
,
"
eps
"
,
"
png
"
, and
"
svg
"
. Default is None which leads to PDF.
show_id : Boolean, optional
If True, the graph_id:s of signals are shown. The default is False.
"""
self
.
get_sfg
(
format
=
format
,
show_id
=
show_id
).
view
()
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