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
5e253f97
Commit
5e253f97
authored
2 years ago
by
Oscar Gustafsson
Browse files
Options
Downloads
Patches
Plain Diff
Revert last changes...
parent
9a17d2d2
No related branches found
No related tags found
No related merge requests found
Pipeline
#88151
passed
2 years ago
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
b_asic/operation.py
+14
-22
14 additions, 22 deletions
b_asic/operation.py
with
14 additions
and
22 deletions
b_asic/operation.py
+
14
−
22
View file @
5e253f97
...
@@ -24,16 +24,8 @@ from typing import (
...
@@ -24,16 +24,8 @@ from typing import (
)
)
from
b_asic.graph_component
import
AbstractGraphComponent
,
GraphComponent
,
Name
from
b_asic.graph_component
import
AbstractGraphComponent
,
GraphComponent
,
Name
from
b_asic.core_operations
import
(
Addition
,
Subtraction
,
Multiplication
,
ConstantMultiplication
,
Division
,
)
from
b_asic.port
import
InputPort
,
OutputPort
,
SignalSourceProvider
from
b_asic.port
import
InputPort
,
OutputPort
,
SignalSourceProvider
from
b_asic.signal
import
Signal
from
b_asic.signal
import
Signal
from
b_asic.signal_flow_graph
import
SFG
ResultKey
=
NewType
(
"
ResultKey
"
,
str
)
ResultKey
=
NewType
(
"
ResultKey
"
,
str
)
ResultMap
=
Mapping
[
ResultKey
,
Optional
[
Number
]]
ResultMap
=
Mapping
[
ResultKey
,
Optional
[
Number
]]
...
@@ -55,7 +47,7 @@ class Operation(GraphComponent, SignalSourceProvider):
...
@@ -55,7 +47,7 @@ class Operation(GraphComponent, SignalSourceProvider):
"""
"""
@abstractmethod
@abstractmethod
def
__add__
(
self
,
src
:
Union
[
SignalSourceProvider
,
Number
])
->
Addition
:
def
__add__
(
self
,
src
:
Union
[
SignalSourceProvider
,
Number
])
->
"
Addition
"
:
"""
"""
Overloads the addition operator to make it return a new Addition operation
Overloads the addition operator to make it return a new Addition operation
object that is connected to the self and other objects.
object that is connected to the self and other objects.
...
@@ -63,7 +55,7 @@ class Operation(GraphComponent, SignalSourceProvider):
...
@@ -63,7 +55,7 @@ class Operation(GraphComponent, SignalSourceProvider):
raise
NotImplementedError
raise
NotImplementedError
@abstractmethod
@abstractmethod
def
__radd__
(
self
,
src
:
Union
[
SignalSourceProvider
,
Number
])
->
Addition
:
def
__radd__
(
self
,
src
:
Union
[
SignalSourceProvider
,
Number
])
->
"
Addition
"
:
"""
"""
Overloads the addition operator to make it return a new Addition operation
Overloads the addition operator to make it return a new Addition operation
object that is connected to the self and other objects.
object that is connected to the self and other objects.
...
@@ -71,7 +63,7 @@ class Operation(GraphComponent, SignalSourceProvider):
...
@@ -71,7 +63,7 @@ class Operation(GraphComponent, SignalSourceProvider):
raise
NotImplementedError
raise
NotImplementedError
@abstractmethod
@abstractmethod
def
__sub__
(
self
,
src
:
Union
[
SignalSourceProvider
,
Number
])
->
Subtraction
:
def
__sub__
(
self
,
src
:
Union
[
SignalSourceProvider
,
Number
])
->
"
Subtraction
"
:
"""
"""
Overloads the subtraction operator to make it return a new Subtraction operation
Overloads the subtraction operator to make it return a new Subtraction operation
object that is connected to the self and other objects.
object that is connected to the self and other objects.
...
@@ -81,7 +73,7 @@ class Operation(GraphComponent, SignalSourceProvider):
...
@@ -81,7 +73,7 @@ class Operation(GraphComponent, SignalSourceProvider):
@abstractmethod
@abstractmethod
def
__rsub__
(
def
__rsub__
(
self
,
src
:
Union
[
SignalSourceProvider
,
Number
]
self
,
src
:
Union
[
SignalSourceProvider
,
Number
]
)
->
Subtraction
:
)
->
"
Subtraction
"
:
"""
"""
Overloads the subtraction operator to make it return a new Subtraction operation
Overloads the subtraction operator to make it return a new Subtraction operation
object that is connected to the self and other objects.
object that is connected to the self and other objects.
...
@@ -91,7 +83,7 @@ class Operation(GraphComponent, SignalSourceProvider):
...
@@ -91,7 +83,7 @@ class Operation(GraphComponent, SignalSourceProvider):
@abstractmethod
@abstractmethod
def
__mul__
(
def
__mul__
(
self
,
src
:
Union
[
SignalSourceProvider
,
Number
]
self
,
src
:
Union
[
SignalSourceProvider
,
Number
]
)
->
Union
[
Multiplication
,
ConstantMultiplication
]:
)
->
Union
[
"
Multiplication
"
,
"
ConstantMultiplication
"
]:
"""
"""
Overloads the multiplication operator to make it return a new Multiplication operation
Overloads the multiplication operator to make it return a new Multiplication operation
object that is connected to the self and other objects. If *src* is a number, then
object that is connected to the self and other objects. If *src* is a number, then
...
@@ -102,7 +94,7 @@ class Operation(GraphComponent, SignalSourceProvider):
...
@@ -102,7 +94,7 @@ class Operation(GraphComponent, SignalSourceProvider):
@abstractmethod
@abstractmethod
def
__rmul__
(
def
__rmul__
(
self
,
src
:
Union
[
SignalSourceProvider
,
Number
]
self
,
src
:
Union
[
SignalSourceProvider
,
Number
]
)
->
Union
[
Multiplication
,
ConstantMultiplication
]:
)
->
Union
[
"
Multiplication
"
,
"
ConstantMultiplication
"
]:
"""
"""
Overloads the multiplication operator to make it return a new Multiplication operation
Overloads the multiplication operator to make it return a new Multiplication operation
object that is connected to the self and other objects. If *src* is a number, then
object that is connected to the self and other objects. If *src* is a number, then
...
@@ -113,7 +105,7 @@ class Operation(GraphComponent, SignalSourceProvider):
...
@@ -113,7 +105,7 @@ class Operation(GraphComponent, SignalSourceProvider):
@abstractmethod
@abstractmethod
def
__truediv__
(
def
__truediv__
(
self
,
src
:
Union
[
SignalSourceProvider
,
Number
]
self
,
src
:
Union
[
SignalSourceProvider
,
Number
]
)
->
Division
:
)
->
"
Division
"
:
"""
"""
Overloads the division operator to make it return a new Division operation
Overloads the division operator to make it return a new Division operation
object that is connected to the self and other objects.
object that is connected to the self and other objects.
...
@@ -123,7 +115,7 @@ class Operation(GraphComponent, SignalSourceProvider):
...
@@ -123,7 +115,7 @@ class Operation(GraphComponent, SignalSourceProvider):
@abstractmethod
@abstractmethod
def
__rtruediv__
(
def
__rtruediv__
(
self
,
src
:
Union
[
SignalSourceProvider
,
Number
]
self
,
src
:
Union
[
SignalSourceProvider
,
Number
]
)
->
Division
:
)
->
"
Division
"
:
"""
"""
Overloads the division operator to make it return a new Division operation
Overloads the division operator to make it return a new Division operation
object that is connected to the self and other objects.
object that is connected to the self and other objects.
...
@@ -280,7 +272,7 @@ class Operation(GraphComponent, SignalSourceProvider):
...
@@ -280,7 +272,7 @@ class Operation(GraphComponent, SignalSourceProvider):
raise
NotImplementedError
raise
NotImplementedError
@abstractmethod
@abstractmethod
def
to_sfg
(
self
)
->
SFG
:
def
to_sfg
(
self
)
->
"
SFG
"
:
"""
"""
Convert the operation into its corresponding SFG.
Convert the operation into its corresponding SFG.
If the operation is composed by multiple operations, the operation will be split.
If the operation is composed by multiple operations, the operation will be split.
...
@@ -498,7 +490,7 @@ class AbstractOperation(Operation, AbstractGraphComponent):
...
@@ -498,7 +490,7 @@ class AbstractOperation(Operation, AbstractGraphComponent):
def
__mul__
(
def
__mul__
(
self
,
src
:
Union
[
SignalSourceProvider
,
Number
]
self
,
src
:
Union
[
SignalSourceProvider
,
Number
]
)
->
"
Union[Multiplication, ConstantMultiplication
]
"
:
)
->
Union
[
"
Multiplication
"
,
"
ConstantMultiplication
"
]
:
# Import here to avoid circular imports.
# Import here to avoid circular imports.
from
b_asic.core_operations
import
(
from
b_asic.core_operations
import
(
ConstantMultiplication
,
ConstantMultiplication
,
...
@@ -513,7 +505,7 @@ class AbstractOperation(Operation, AbstractGraphComponent):
...
@@ -513,7 +505,7 @@ class AbstractOperation(Operation, AbstractGraphComponent):
def
__rmul__
(
def
__rmul__
(
self
,
src
:
Union
[
SignalSourceProvider
,
Number
]
self
,
src
:
Union
[
SignalSourceProvider
,
Number
]
)
->
Union
[
Multiplication
,
ConstantMultiplication
]:
)
->
Union
[
"
Multiplication
"
,
"
ConstantMultiplication
"
]:
# Import here to avoid circular imports.
# Import here to avoid circular imports.
from
b_asic.core_operations
import
(
from
b_asic.core_operations
import
(
ConstantMultiplication
,
ConstantMultiplication
,
...
@@ -528,7 +520,7 @@ class AbstractOperation(Operation, AbstractGraphComponent):
...
@@ -528,7 +520,7 @@ class AbstractOperation(Operation, AbstractGraphComponent):
def
__truediv__
(
def
__truediv__
(
self
,
src
:
Union
[
SignalSourceProvider
,
Number
]
self
,
src
:
Union
[
SignalSourceProvider
,
Number
]
)
->
Division
:
)
->
"
Division
"
:
# Import here to avoid circular imports.
# Import here to avoid circular imports.
from
b_asic.core_operations
import
Constant
,
Division
from
b_asic.core_operations
import
Constant
,
Division
...
@@ -538,7 +530,7 @@ class AbstractOperation(Operation, AbstractGraphComponent):
...
@@ -538,7 +530,7 @@ class AbstractOperation(Operation, AbstractGraphComponent):
def
__rtruediv__
(
def
__rtruediv__
(
self
,
src
:
Union
[
SignalSourceProvider
,
Number
]
self
,
src
:
Union
[
SignalSourceProvider
,
Number
]
)
->
Division
:
)
->
"
Division
"
:
# Import here to avoid circular imports.
# Import here to avoid circular imports.
from
b_asic.core_operations
import
Constant
,
Division
from
b_asic.core_operations
import
Constant
,
Division
...
@@ -753,7 +745,7 @@ class AbstractOperation(Operation, AbstractGraphComponent):
...
@@ -753,7 +745,7 @@ class AbstractOperation(Operation, AbstractGraphComponent):
pass
pass
return
[
self
]
return
[
self
]
def
to_sfg
(
self
)
->
SFG
:
def
to_sfg
(
self
)
->
"
SFG
"
:
# Import here to avoid circular imports.
# Import here to avoid circular imports.
from
b_asic.signal_flow_graph
import
SFG
from
b_asic.signal_flow_graph
import
SFG
from
b_asic.special_operations
import
Input
,
Output
from
b_asic.special_operations
import
Input
,
Output
...
...
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