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
3dbb4ab9
Commit
3dbb4ab9
authored
5 years ago
by
Ivar Härnqvist
Browse files
Options
Downloads
Patches
Plain Diff
Misc. fixes
parent
7c6cbe75
No related branches found
No related tags found
3 merge requests
!67
WIP: B-ASIC version 1.0.0 hotfix
,
!65
B-ASIC version 1.0.0
,
!15
Add changes from sprint 1 and 2 to master
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
b_asic/core_operations.py
+27
-27
27 additions, 27 deletions
b_asic/core_operations.py
b_asic/operation.py
+8
-8
8 additions, 8 deletions
b_asic/operation.py
with
35 additions
and
35 deletions
b_asic/core_operations.py
+
27
−
27
View file @
3dbb4ab9
...
...
@@ -35,7 +35,7 @@ class Constant(AbstractOperation):
self
.
_output_ports
=
[
OutputPort
(
0
,
self
)]
self
.
_parameters
[
"
value
"
]
=
value
def
evaluate
(
self
)
->
Any
:
def
evaluate
(
self
):
return
self
.
param
(
"
value
"
)
@property
...
...
@@ -59,7 +59,7 @@ class Addition(AbstractOperation):
if
source2
is
not
None
:
self
.
_input_ports
[
1
].
connect_to_port
(
source2
)
def
evaluate
(
self
,
a
,
b
)
->
Any
:
def
evaluate
(
self
,
a
,
b
):
return
a
+
b
@property
...
...
@@ -82,11 +82,11 @@ class Subtraction(AbstractOperation):
if
source2
is
not
None
:
self
.
_input_ports
[
1
].
connect_to_port
(
source2
)
def
evaluate
(
self
,
a
,
b
)
->
Any
:
def
evaluate
(
self
,
a
,
b
):
return
a
-
b
@property
def
type_name
(
self
)
->
GraphIDTyp
e
:
def
type_name
(
self
)
->
TypeNam
e
:
return
"
sub
"
...
...
@@ -105,11 +105,11 @@ class Multiplication(AbstractOperation):
if
source2
is
not
None
:
self
.
_input_ports
[
1
].
connect_to_port
(
source2
)
def
evaluate
(
self
,
a
,
b
)
->
Any
:
def
evaluate
(
self
,
a
,
b
):
return
a
*
b
@property
def
type_name
(
self
)
->
GraphIDTyp
e
:
def
type_name
(
self
)
->
TypeNam
e
:
return
"
mul
"
...
...
@@ -128,11 +128,11 @@ class Division(AbstractOperation):
if
source2
is
not
None
:
self
.
_input_ports
[
1
].
connect_to_port
(
source2
)
def
evaluate
(
self
,
a
,
b
)
->
Any
:
def
evaluate
(
self
,
a
,
b
):
return
a
/
b
@property
def
type_name
(
self
)
->
GraphIDTyp
e
:
def
type_name
(
self
)
->
TypeNam
e
:
return
"
div
"
...
...
@@ -150,11 +150,11 @@ class SquareRoot(AbstractOperation):
self
.
_input_ports
[
0
].
connect_to_port
(
source1
)
def
evaluate
(
self
,
a
)
->
Any
:
def
evaluate
(
self
,
a
):
return
sqrt
((
complex
)(
a
))
@property
def
type_name
(
self
)
->
GraphIDTyp
e
:
def
type_name
(
self
)
->
TypeNam
e
:
return
"
sqrt
"
...
...
@@ -172,11 +172,11 @@ class ComplexConjugate(AbstractOperation):
self
.
_input_ports
[
0
].
connect_to_port
(
source1
)
def
evaluate
(
self
,
a
)
->
Any
:
def
evaluate
(
self
,
a
):
return
conjugate
(
a
)
@property
def
type_name
(
self
)
->
GraphIDTyp
e
:
def
type_name
(
self
)
->
TypeNam
e
:
return
"
conj
"
...
...
@@ -195,13 +195,13 @@ class Max(AbstractOperation):
if
source2
is
not
None
:
self
.
_input_ports
[
1
].
connect_to_port
(
source2
)
def
evaluate
(
self
,
a
,
b
)
->
Any
:
def
evaluate
(
self
,
a
,
b
):
assert
not
isinstance
(
a
,
complex
)
and
not
isinstance
(
b
,
complex
),
\
(
"
core_operation.Max does not support complex numbers.
"
)
(
"
core_operation
s
.Max does not support complex numbers.
"
)
return
a
if
a
>
b
else
b
@property
def
type_name
(
self
)
->
GraphIDTyp
e
:
def
type_name
(
self
)
->
TypeNam
e
:
return
"
max
"
...
...
@@ -220,13 +220,13 @@ class Min(AbstractOperation):
if
source2
is
not
None
:
self
.
_input_ports
[
1
].
connect_to_port
(
source2
)
def
evaluate
(
self
,
a
,
b
)
->
Any
:
def
evaluate
(
self
,
a
,
b
):
assert
not
isinstance
(
a
,
complex
)
and
not
isinstance
(
b
,
complex
),
\
(
"
core_operation.Min does not support complex numbers.
"
)
(
"
core_operation
s
.Min does not support complex numbers.
"
)
return
a
if
a
<
b
else
b
@property
def
type_name
(
self
)
->
GraphIDTyp
e
:
def
type_name
(
self
)
->
TypeNam
e
:
return
"
min
"
...
...
@@ -244,11 +244,11 @@ class Absolute(AbstractOperation):
self
.
_input_ports
[
0
].
connect_to_port
(
source1
)
def
evaluate
(
self
,
a
)
->
Any
:
def
evaluate
(
self
,
a
):
return
np_abs
(
a
)
@property
def
type_name
(
self
)
->
GraphIDTyp
e
:
def
type_name
(
self
)
->
TypeNam
e
:
return
"
abs
"
...
...
@@ -266,7 +266,7 @@ class ConstantMultiplication(AbstractOperation):
if
source1
is
not
None
:
self
.
_input_ports
[
0
].
connect_to_port
(
source1
)
def
evaluate
(
self
,
a
)
->
Any
:
def
evaluate
(
self
,
a
):
return
a
*
self
.
param
(
"
coefficient
"
)
@property
...
...
@@ -288,11 +288,11 @@ class ConstantAddition(AbstractOperation):
if
source1
is
not
None
:
self
.
_input_ports
[
0
].
connect_to_port
(
source1
)
def
evaluate
(
self
,
a
)
->
Any
:
def
evaluate
(
self
,
a
):
return
a
+
self
.
param
(
"
coefficient
"
)
@property
def
type_name
(
self
)
->
GraphIDTyp
e
:
def
type_name
(
self
)
->
TypeNam
e
:
return
"
cadd
"
...
...
@@ -310,11 +310,11 @@ class ConstantSubtraction(AbstractOperation):
if
source1
is
not
None
:
self
.
_input_ports
[
0
].
connect_to_port
(
source1
)
def
evaluate
(
self
,
a
)
->
Any
:
def
evaluate
(
self
,
a
):
return
a
-
self
.
param
(
"
coefficient
"
)
@property
def
type_name
(
self
)
->
GraphIDTyp
e
:
def
type_name
(
self
)
->
TypeNam
e
:
return
"
csub
"
...
...
@@ -332,9 +332,9 @@ class ConstantDivision(AbstractOperation):
if
source1
is
not
None
:
self
.
_input_ports
[
0
].
connect_to_port
(
source1
)
def
evaluate
(
self
,
a
)
->
Any
:
def
evaluate
(
self
,
a
):
return
a
/
self
.
param
(
"
coefficient
"
)
@property
def
type_name
(
self
)
->
GraphIDTyp
e
:
def
type_name
(
self
)
->
TypeNam
e
:
return
"
cdiv
"
This diff is collapsed.
Click to expand it.
b_asic/operation.py
+
8
−
8
View file @
3dbb4ab9
...
...
@@ -86,9 +86,9 @@ class Operation(GraphComponent):
@property
@abstractmethod
def
neighbo
u
rs
(
self
)
->
"
List[Operation]
"
:
def
neighbors
(
self
)
->
"
List[Operation]
"
:
"""
Return all operations that are connected by signals to this operation.
If no neighbo
u
rs are found this returns an empty list
If no neighbors are found
,
this returns an empty list
.
"""
raise
NotImplementedError
...
...
@@ -175,17 +175,17 @@ class AbstractOperation(Operation, AbstractGraphComponent):
return
[
self
]
@property
def
neighbo
u
rs
(
self
)
->
List
[
Operation
]:
neighbo
u
rs
:
List
[
Operation
]
=
[]
def
neighbors
(
self
)
->
List
[
Operation
]:
neighbors
:
List
[
Operation
]
=
[]
for
port
in
self
.
_input_ports
:
for
signal
in
port
.
signals
:
neighbo
u
rs
.
append
(
signal
.
source
.
operation
)
neighbors
.
append
(
signal
.
source
.
operation
)
for
port
in
self
.
_output_ports
:
for
signal
in
port
.
signals
:
neighbo
u
rs
.
append
(
signal
.
destination
.
operation
)
neighbors
.
append
(
signal
.
destination
.
operation
)
return
neighbo
u
rs
return
neighbors
def
traverse
(
self
)
->
Operation
:
"""
Traverse the operation tree and return a generator with start point in the operation.
"""
...
...
@@ -198,7 +198,7 @@ class AbstractOperation(Operation, AbstractGraphComponent):
while
queue
:
operation
=
queue
.
popleft
()
yield
operation
for
n_operation
in
operation
.
neighbo
u
rs
:
for
n_operation
in
operation
.
neighbors
:
if
n_operation
not
in
visited
:
visited
.
add
(
n_operation
)
queue
.
append
(
n_operation
)
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