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
676a6e96
Commit
676a6e96
authored
4 years ago
by
Kevin
Browse files
Options
Downloads
Patches
Plain Diff
Added some defintions, need to implement operation to SFG conversion in another issue
parent
033f9ee1
No related branches found
No related tags found
2 merge requests
!44
Resolve "Operation Replacement in a SFG"
,
!42
Resolve "Operation to SFG Conversion"
Pipeline
#14319
failed
4 years ago
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
b_asic/operation.py
+4
-0
4 additions, 0 deletions
b_asic/operation.py
b_asic/signal_flow_graph.py
+14
-1
14 additions, 1 deletion
b_asic/signal_flow_graph.py
test/test_sfg.py
+3
-3
3 additions, 3 deletions
test/test_sfg.py
with
21 additions
and
4 deletions
b_asic/operation.py
+
4
−
0
View file @
676a6e96
...
...
@@ -180,6 +180,10 @@ class Operation(GraphComponent, SignalSourceProvider):
"""
raise
NotImplementedError
@abstractmethod
def
to_sfg
(
self
)
->
self
:
"""
Convert a operation to its correspnding
"""
class
AbstractOperation
(
Operation
,
AbstractGraphComponent
):
"""
Generic abstract operation class which most implementations will derive from.
...
...
This diff is collapsed.
Click to expand it.
b_asic/signal_flow_graph.py
+
14
−
1
View file @
676a6e96
...
...
@@ -405,7 +405,7 @@ class SFG(AbstractOperation):
# The old SFG will be deleted by Python GC
return
self
()
def
replace_operations
(
self
,
inputs
:
Sequence
[
Input
],
output
s
:
Sequence
[
Output
],
operation
:
Operation
):
def
replace_operations
(
self
,
operation_id
s
:
Sequence
[
GraphID
],
operation
:
Operation
):
"""
Replace multiple operations in the sfg with a operation of equivalent functionallity with the same number of inputs and outputs.
Then return a new deepcopy of the sfg with the replaced operations.
...
...
@@ -414,6 +414,19 @@ class SFG(AbstractOperation):
outputs: The outputs of the operations we are replacing.
operation: The operation used for replacement.
"""
operations
=
[
self
.
find_by_id
(
_id
)
for
_id
in
operation_ids
]
for
_index
,
_inp
in
enumerate
(
inputs
):
for
_signal
in
_inp
.
output_signals
:
_signal
.
remove_destination
()
_signal
.
set_destination
(
operation
.
input
(
_index
))
for
_index
,
_out
in
enumerate
(
outputs
):
for
_signal
in
_out
.
input_signals
:
_signal
.
remove_destination
()
_signal
.
set_source
(
operation
.
output
(
_index
))
return
self
()
def
_evaluate_source
(
self
,
src
:
OutputPort
,
results
:
MutableResultMap
,
registers
:
MutableRegisterMap
,
prefix
:
str
)
->
Number
:
...
...
This diff is collapsed.
Click to expand it.
test/test_sfg.py
+
3
−
3
View file @
676a6e96
...
...
@@ -266,10 +266,10 @@ class TestReplaceOperations:
sfg
=
SFG
(
inputs
=
[
in1
,
in2
,
in3
],
outputs
=
[
out1
])
mad1
=
MAD
()
sfg
.
replace_operations
([
in1
,
in2
,
in3
],
[
out1
],
mad1
)
_sfg
=
sfg
.
replace_operations
([
'
add1
'
,
'
mul1
'
],
mad1
)
assert
mad1
in
sfg
.
operations
assert
{
add1
,
mul1
}
not
in
sfg
.
operations
assert
mad1
in
_
sfg
.
operations
assert
{
add1
,
mul1
}
not
in
_
sfg
.
operations
def
test_replace_neg_add_with_sub
(
self
):
in1
=
Input
()
...
...
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