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
1483b9d3
Commit
1483b9d3
authored
5 years ago
by
Adam Jakobsson
Browse files
Options
Downloads
Patches
Plain Diff
add print constant and all tests is passing
parent
4a2cb543
No related branches found
No related tags found
1 merge request
!21
Resolve "Print SFG"
Pipeline
#12734
failed
5 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
+9
-2
9 additions, 2 deletions
b_asic/signal_flow_graph.py
test/test_print_sfg.py
+18
-14
18 additions, 14 deletions
test/test_print_sfg.py
with
27 additions
and
16 deletions
b_asic/signal_flow_graph.py
+
9
−
2
View file @
1483b9d3
...
@@ -359,10 +359,17 @@ class SFG(AbstractOperation):
...
@@ -359,10 +359,17 @@ class SFG(AbstractOperation):
for
key
,
value
in
self
.
_components_by_id
.
items
():
for
key
,
value
in
self
.
_components_by_id
.
items
():
if
value
is
comp
:
if
value
is
comp
:
output_string
+=
"
id:
"
+
key
+
"
, name:
"
output_string
+=
"
id:
"
+
key
+
"
, name:
"
if
comp
.
name
!=
None
:
if
comp
.
name
!=
None
:
output_string
+=
comp
.
name
+
"
, input: [
"
output_string
+=
comp
.
name
+
"
,
"
else
:
output_string
+=
"
-,
"
if
comp
.
type_name
is
"
c
"
:
output_string
+=
"
value:
"
+
str
(
comp
.
value
)
+
"
, input: [
"
else
:
else
:
output_string
+=
"
-, input: [
"
output_string
+=
"
input: [
"
counter_input
=
0
counter_input
=
0
for
input
in
comp
.
inputs
:
for
input
in
comp
.
inputs
:
counter_input
+=
1
counter_input
+=
1
...
...
This diff is collapsed.
Click to expand it.
test/test_print_sfg.py
+
18
−
14
View file @
1483b9d3
from
b_asic.signal_flow_graph
import
SFG
from
b_asic.signal_flow_graph
import
SFG
from
b_asic.core_operations
import
Addition
from
b_asic.core_operations
import
Addition
,
Multiplication
,
Constant
,
ConstantAddition
from
b_asic.port
import
InputPort
,
OutputPort
from
b_asic.port
import
InputPort
,
OutputPort
from
b_asic.signal
import
Signal
from
b_asic.signal
import
Signal
from
b_asic.special_operations
import
Input
,
Output
from
b_asic.special_operations
import
Input
,
Output
...
@@ -16,23 +16,27 @@ class TestPrintSfg:
...
@@ -16,23 +16,27 @@ class TestPrintSfg:
out1
=
Output
(
add1
,
"
OUT1
"
)
out1
=
Output
(
add1
,
"
OUT1
"
)
sfg
=
SFG
(
inputs
=
[
inp1
,
inp2
],
outputs
=
[
out1
],
name
=
"
sf1
"
)
sfg
=
SFG
(
inputs
=
[
inp1
,
inp2
],
outputs
=
[
out1
],
name
=
"
sf1
"
)
assert
print
(
sfg
)
==
(
"
id: add1, name: ADD1, input: [s1, s2], output: [s3]
\n
id: in1, name: INP1, input: [], output: [s1]
\n
id: in2, name: INP2, input: [], output: [s2]
\n
id: out1, name: OUT1, input: [s3], output: []
\n
"
)
assert
sfg
.
__str__
(
)
==
(
"
id: add1, name: ADD1, input: [s1, s2], output: [s3]
\n
id: in1, name: INP1, input: [], output: [s1]
\n
id: in2, name: INP2, input: [], output: [s2]
\n
id: out1, name: OUT1, input: [s3], output: []
\n
"
)
def
test_print_signal_id
(
self
):
def
test_print_add_mul
(
self
):
in_port1
=
InputPort
(
0
,
None
)
inp1
=
Input
(
"
INP1
"
)
out_port1
=
OutputPort
(
0
,
None
)
inp2
=
Input
(
"
INP2
"
)
inp3
=
Input
(
"
INP3
"
)
add1
=
Addition
(
inp1
,
inp2
,
"
ADD1
"
)
mul1
=
Multiplication
(
add1
,
inp3
,
"
MUL1
"
)
out1
=
Output
(
mul1
,
"
OUT1
"
)
sfg
=
SFG
(
inputs
=
[
inp1
,
inp2
,
inp3
],
outputs
=
[
out1
],
name
=
"
mac_sfg
"
)
test_signal1
=
Signal
(
out_port1
,
in_port1
)
assert
sfg
.
__str__
()
==
(
"
id: add1, name: ADD1, input: [s1, s2], output: [s5]
\n
id: in1, name: INP1, input: [], output: [s1]
\n
id: in2, name: INP2, input: [], output: [s2]
\n
id: mul1, name: MUL1, input: [s5, s3], output: [s4]
\n
id: in3, name: INP3, input: [], output: [s3]
\n
id: out1, name: OUT1, input: [s4], output: []
\n
"
)
assert
test_signal1
.
type_name
==
"
s
"
def
test_print_constant
(
self
):
inp1
=
Input
(
"
INP1
"
)
const1
=
Constant
(
3
,
"
CONST
"
)
add1
=
Addition
(
const1
,
inp1
,
"
ADD1
"
)
out1
=
Output
(
add1
,
"
OUT1
"
)
def
test_print_operation_id
(
self
):
sfg
=
SFG
(
inputs
=
[
inp1
],
outputs
=
[
out1
],
name
=
"
sfg
"
)
test_operation
=
Addition
()
assert
test_operation
.
type_name
==
"
add
"
def
test_print_operation_name
(
self
):
assert
sfg
.
__str__
()
==
(
"
id: add1, name: ADD1, input: [s3, s1], output: [s2]
\n
id: c1, name: CONST, value: 3, input: [], output: [s3]
\n
id: in1, name: INP1, input: [], output: [s1]
\n
id: out1, name: OUT1, input: [s2], output: []
\n
"
)
test_operation
=
Addition
()
test_operation
.
_name
=
"
my_add
"
assert
test_operation
.
_name
==
"
my_add
"
\ No newline at end of file
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