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
4672f718
Commit
4672f718
authored
4 years ago
by
Kevin
Browse files
Options
Downloads
Patches
Plain Diff
changed some tests and desc. of replace operations
parent
5e5056c6
No related branches found
Branches containing commit
No related tags found
2 merge requests
!44
Resolve "Operation Replacement in a SFG"
,
!42
Resolve "Operation to SFG Conversion"
Pipeline
#14053
failed
4 years ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
b_asic/signal_flow_graph.py
+6
-5
6 additions, 5 deletions
b_asic/signal_flow_graph.py
test/test_sfg.py
+25
-7
25 additions, 7 deletions
test/test_sfg.py
with
31 additions
and
12 deletions
b_asic/signal_flow_graph.py
+
6
−
5
View file @
4672f718
...
...
@@ -406,14 +406,15 @@ class SFG(AbstractOperation):
return
self
()
def
replace_operations
(
self
,
inputs
:
Sequence
[
Input
],
outputs
:
Sequence
[
Output
],
operation
:
Operation
):
"""
Replace
one or mor
e operations in the sfg with a operation
that hav
e same number of inputs and outputs.
Then return a new deepcopy of the sfg.
"""
Replace
multipl
e operations in the sfg with a operation
of equivalent functionallity with th
e same number of inputs and outputs.
Then return a new deepcopy of the sfg
with the replaced operations
.
Arguments:
inputs: The inputs f
or
the operations we are replacing.
outputs: The outputs f
or
the operations we are replacing.
operation: The
replacing operation
.
inputs: The inputs
o
f the operations we are replacing.
outputs: The outputs
o
f the operations we are replacing.
operation: The
operation used for replacement
.
"""
return
self
()
def
_evaluate_source
(
self
,
src
:
OutputPort
,
results
:
MutableResultMap
,
registers
:
MutableRegisterMap
,
prefix
:
str
)
->
Number
:
src_prefix
=
prefix
...
...
This diff is collapsed.
Click to expand it.
test/test_sfg.py
+
25
−
7
View file @
4672f718
import
pytest
from
b_asic
import
SFG
,
Signal
,
Input
,
Output
,
Constant
,
Addition
,
Multiplication
,
MAD
from
b_asic
import
SFG
,
Signal
,
Input
,
Output
,
Constant
,
Addition
,
Subtraction
,
Multiplication
,
MAD
,
ConstantMultiplication
,
Butterfly
class
TestInit
:
...
...
@@ -256,20 +256,38 @@ class TestReplaceComponents:
assert
False
class
TestReplaceOperations
:
def
test_replace_mul_add_with_
MAD
(
self
):
def
test_replace_mul_add_with_
mad
(
self
):
in1
=
Input
()
in2
=
Input
()
in3
=
Input
()
mul1
=
in1
*
in2
add1
=
mul1
+
in3
out1
=
Output
(
add1
)
sfg
=
SFG
(
inputs
=
[
in1
,
in2
,
in3
],
outputs
=
[
out1
])
assert
len
(
sfg
.
operations
)
==
6
mad1
=
MAD
()
sfg
.
replace_operations
([
in1
,
in2
,
in3
],
[
out1
],
mad1
)
assert
len
(
sfg
.
operations
)
==
5
assert
mad1
in
sfg
.
operations
assert
{
add1
,
mul1
}
not
in
sfg
.
operations
\ No newline at end of file
def
test_replace_neg_add_with_sub
(
self
):
in1
=
Input
()
in2
=
Input
()
neg
=
ConstantMultiplication
(
-
1
,
in1
)
add1
=
neg
+
in2
out1
=
Output
(
add1
)
sfg
=
SFG
(
inputs
=
[
in1
,
in2
],
outputs
=
[
out1
])
sub1
=
Subtraction
()
sfg
.
replace_operations
([
in1
,
in2
],
[
out1
],
sub1
)
assert
sub1
in
sfg
.
operations
assert
{
add1
,
neg
}
not
in
sfg
.
operations
def
test_not_equal_functionallity
(
self
,
operation_tree
):
sfg
=
SFG
(
outputs
=
[
Output
(
operation_tree
)])
mul1
=
Multiplication
()
with
pytest
.
raises
(
AssertionError
):
sfg
.
replace_operations
([
sfg
.
inputs
(
0
),
sfg
.
inputs
(
1
)],
[
sfg
.
outputs
(
0
)],
mul1
)
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