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
691e04ca
Commit
691e04ca
authored
2 years ago
by
Oscar Gustafsson
Browse files
Options
Downloads
Patches
Plain Diff
Never ending doc-fixes
parent
a631e6b6
No related branches found
No related tags found
No related merge requests found
Pipeline
#87879
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
+55
-29
55 additions, 29 deletions
b_asic/operation.py
with
55 additions
and
29 deletions
b_asic/operation.py
+
55
−
29
View file @
691e04ca
...
@@ -35,7 +35,8 @@ MutableDelayMap = MutableMapping[ResultKey, Number]
...
@@ -35,7 +35,8 @@ MutableDelayMap = MutableMapping[ResultKey, Number]
class
Operation
(
GraphComponent
,
SignalSourceProvider
):
class
Operation
(
GraphComponent
,
SignalSourceProvider
):
"""
Operation interface.
"""
Operation interface.
Operations are graph components that perform a certain function.
Operations are graph components that perform a certain function.
They are connected to each other by signals through their input/output
They are connected to each other by signals through their input/output
...
@@ -47,14 +48,16 @@ class Operation(GraphComponent, SignalSourceProvider):
...
@@ -47,14 +48,16 @@ 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.
"""
"""
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.
"""
"""
raise
NotImplementedError
raise
NotImplementedError
...
@@ -63,7 +66,8 @@ class Operation(GraphComponent, SignalSourceProvider):
...
@@ -63,7 +66,8 @@ class Operation(GraphComponent, SignalSourceProvider):
def
__sub__
(
def
__sub__
(
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.
"""
"""
raise
NotImplementedError
raise
NotImplementedError
...
@@ -72,7 +76,8 @@ class Operation(GraphComponent, SignalSourceProvider):
...
@@ -72,7 +76,8 @@ class Operation(GraphComponent, SignalSourceProvider):
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.
"""
"""
raise
NotImplementedError
raise
NotImplementedError
...
@@ -81,7 +86,8 @@ class Operation(GraphComponent, SignalSourceProvider):
...
@@ -81,7 +86,8 @@ class Operation(GraphComponent, SignalSourceProvider):
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
returns a ConstantMultiplication operation object instead.
returns a ConstantMultiplication operation object instead.
"""
"""
...
@@ -193,13 +199,13 @@ class Operation(GraphComponent, SignalSourceProvider):
...
@@ -193,13 +199,13 @@ class Operation(GraphComponent, SignalSourceProvider):
)
->
Optional
[
Number
]:
)
->
Optional
[
Number
]:
"""
"""
Get the current output at the given index of this operation, if available.
Get the current output at the given index of this operation, if available.
The delays parameter will be used for lookup.
The
*
delays
*
parameter will be used for lookup.
The prefix parameter will be used as a prefix for the key string when looking for delays.
The
*
prefix
*
parameter will be used as a prefix for the key string when looking for delays.
See also
See also
========
========
current_outputs, evaluate_output, evaluate_outputs
.
current_outputs, evaluate_output, evaluate_outputs
"""
"""
raise
NotImplementedError
raise
NotImplementedError
...
@@ -216,16 +222,20 @@ class Operation(GraphComponent, SignalSourceProvider):
...
@@ -216,16 +222,20 @@ class Operation(GraphComponent, SignalSourceProvider):
)
->
Number
:
)
->
Number
:
"""
"""
Evaluate the output at the given index of this operation with the given input values.
Evaluate the output at the given index of this operation with the given input values.
The results parameter will be used to store any results (including intermediate results)
The
*
results
*
parameter will be used to store any results (including intermediate results)
for caching.
for caching.
The delays parameter will be used to get the current value of any intermediate delays
The
*
delays
*
parameter will be used to get the current value of any intermediate delays
that are encountered, and be updated with their new values.
that are encountered, and be updated with their new values.
The prefix parameter will be used as a prefix for the key string when storing results/delays.
The
*
prefix
*
parameter will be used as a prefix for the key string when storing results/delays.
The bits_override parameter specifies a word length override when truncating inputs
The
*
bits_override
*
parameter specifies a word length override when truncating inputs
which ignores the word length specified by the input signal.
which ignores the word length specified by the input signal.
The truncate parameter specifies whether input truncation should be enabled in the first
The
*
truncate
*
parameter specifies whether input truncation should be enabled in the first
place. If set to False, input values will be used directly without any bit truncation.
place. If set to False, input values will be used directly without any bit truncation.
See also: evaluate_outputs, current_output, current_outputs.
See also
========
evaluate_outputs, current_output, current_outputs
"""
"""
raise
NotImplementedError
raise
NotImplementedError
...
@@ -233,7 +243,8 @@ class Operation(GraphComponent, SignalSourceProvider):
...
@@ -233,7 +243,8 @@ class Operation(GraphComponent, SignalSourceProvider):
def
current_outputs
(
def
current_outputs
(
self
,
delays
:
Optional
[
DelayMap
]
=
None
,
prefix
:
str
=
""
self
,
delays
:
Optional
[
DelayMap
]
=
None
,
prefix
:
str
=
""
)
->
Sequence
[
Optional
[
Number
]]:
)
->
Sequence
[
Optional
[
Number
]]:
"""
Get all current outputs of this operation, if available.
"""
Get all current outputs of this operation, if available.
See current_output for more information.
See current_output for more information.
"""
"""
raise
NotImplementedError
raise
NotImplementedError
...
@@ -248,21 +259,24 @@ class Operation(GraphComponent, SignalSourceProvider):
...
@@ -248,21 +259,24 @@ class Operation(GraphComponent, SignalSourceProvider):
bits_override
:
Optional
[
int
]
=
None
,
bits_override
:
Optional
[
int
]
=
None
,
truncate
:
bool
=
True
,
truncate
:
bool
=
True
,
)
->
Sequence
[
Number
]:
)
->
Sequence
[
Number
]:
"""
Evaluate all outputs of this operation given the input values.
"""
Evaluate all outputs of this operation given the input values.
See evaluate_output for more information.
See evaluate_output for more information.
"""
"""
raise
NotImplementedError
raise
NotImplementedError
@abstractmethod
@abstractmethod
def
split
(
self
)
->
Iterable
[
"
Operation
"
]:
def
split
(
self
)
->
Iterable
[
"
Operation
"
]:
"""
Split the operation into multiple operations.
"""
Split the operation into multiple operations.
If splitting is not possible, this may return a list containing only the operation itself.
If splitting is not possible, this may return a list containing only the operation itself.
"""
"""
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.
"""
"""
raise
NotImplementedError
raise
NotImplementedError
...
@@ -302,7 +316,8 @@ class Operation(GraphComponent, SignalSourceProvider):
...
@@ -302,7 +316,8 @@ class Operation(GraphComponent, SignalSourceProvider):
@abstractmethod
@abstractmethod
def
set_latency
(
self
,
latency
:
int
)
->
None
:
def
set_latency
(
self
,
latency
:
int
)
->
None
:
"""
Sets the latency of the operation to the specified integer value by setting the
"""
Sets the latency of the operation to the specified integer value by setting the
latency-offsets of operations input ports to 0 and the latency-offsets of the operations
latency-offsets of operations input ports to 0 and the latency-offsets of the operations
output ports to the specified value. The latency cannot be a negative integers.
output ports to the specified value. The latency cannot be a negative integers.
"""
"""
...
@@ -320,7 +335,8 @@ class Operation(GraphComponent, SignalSourceProvider):
...
@@ -320,7 +335,8 @@ class Operation(GraphComponent, SignalSourceProvider):
@property
@property
@abstractmethod
@abstractmethod
def
execution_time
(
self
)
->
int
:
def
execution_time
(
self
)
->
int
:
"""
Get the execution time of the operation, which is the time it takes before the
"""
Get the execution time of the operation, which is the time it takes before the
processing element implementing the operation can be reused for starting another operation.
processing element implementing the operation can be reused for starting another operation.
"""
"""
raise
NotImplementedError
raise
NotImplementedError
...
@@ -328,7 +344,8 @@ class Operation(GraphComponent, SignalSourceProvider):
...
@@ -328,7 +344,8 @@ class Operation(GraphComponent, SignalSourceProvider):
@execution_time.setter
@execution_time.setter
@abstractmethod
@abstractmethod
def
execution_time
(
self
,
latency
:
int
)
->
None
:
def
execution_time
(
self
,
latency
:
int
)
->
None
:
"""
Sets the execution time of the operation to the specified integer
"""
Sets the execution time of the operation to the specified integer
value. The execution time cannot be a negative integer.
value. The execution time cannot be a negative integer.
"""
"""
raise
NotImplementedError
raise
NotImplementedError
...
@@ -337,7 +354,8 @@ class Operation(GraphComponent, SignalSourceProvider):
...
@@ -337,7 +354,8 @@ class Operation(GraphComponent, SignalSourceProvider):
def
get_plot_coordinates
(
def
get_plot_coordinates
(
self
,
self
,
)
->
Tuple
[
List
[
List
[
Number
]],
List
[
List
[
Number
]]]:
)
->
Tuple
[
List
[
List
[
Number
]],
List
[
List
[
Number
]]]:
"""
Get a tuple constaining coordinates for the two polygons outlining
"""
Get a tuple constaining coordinates for the two polygons outlining
the latency and execution time of the operation.
the latency and execution time of the operation.
The polygons are corresponding to a start time of 0 and are of height 1.
The polygons are corresponding to a start time of 0 and are of height 1.
"""
"""
...
@@ -347,7 +365,8 @@ class Operation(GraphComponent, SignalSourceProvider):
...
@@ -347,7 +365,8 @@ class Operation(GraphComponent, SignalSourceProvider):
def
get_io_coordinates
(
def
get_io_coordinates
(
self
,
self
,
)
->
Tuple
[
List
[
List
[
Number
]],
List
[
List
[
Number
]]]:
)
->
Tuple
[
List
[
List
[
Number
]],
List
[
List
[
Number
]]]:
"""
Get a tuple constaining coordinates for inputs and outputs, respectively.
"""
Get a tuple constaining coordinates for inputs and outputs, respectively.
These maps to the polygons and are corresponding to a start time of 0
These maps to the polygons and are corresponding to a start time of 0
and height 1.
and height 1.
"""
"""
...
@@ -355,7 +374,8 @@ class Operation(GraphComponent, SignalSourceProvider):
...
@@ -355,7 +374,8 @@ class Operation(GraphComponent, SignalSourceProvider):
class
AbstractOperation
(
Operation
,
AbstractGraphComponent
):
class
AbstractOperation
(
Operation
,
AbstractGraphComponent
):
"""
Generic abstract operation base class.
"""
Generic abstract operation base class.
Concrete operations should normally derive from this to get the default
Concrete operations should normally derive from this to get the default
behavior.
behavior.
...
@@ -377,7 +397,8 @@ class AbstractOperation(Operation, AbstractGraphComponent):
...
@@ -377,7 +397,8 @@ class AbstractOperation(Operation, AbstractGraphComponent):
latency_offsets
:
Optional
[
Dict
[
str
,
int
]]
=
None
,
latency_offsets
:
Optional
[
Dict
[
str
,
int
]]
=
None
,
execution_time
:
Optional
[
int
]
=
None
,
execution_time
:
Optional
[
int
]
=
None
,
):
):
"""
Construct an operation with the given input/output count.
"""
Construct an operation with the given input/output count.
A list of input sources may be specified to automatically connect
A list of input sources may be specified to automatically connect
to the input ports.
to the input ports.
...
@@ -428,7 +449,8 @@ class AbstractOperation(Operation, AbstractGraphComponent):
...
@@ -428,7 +449,8 @@ class AbstractOperation(Operation, AbstractGraphComponent):
@abstractmethod
@abstractmethod
def
evaluate
(
self
,
*
inputs
)
->
Any
:
# pylint: disable=arguments-differ
def
evaluate
(
self
,
*
inputs
)
->
Any
:
# pylint: disable=arguments-differ
"""
"""
Evaluate the operation and generate a list of output values given a list of input values.
Evaluate the operation and generate a list of output values given a
list of input values.
"""
"""
raise
NotImplementedError
raise
NotImplementedError
...
@@ -773,7 +795,9 @@ class AbstractOperation(Operation, AbstractGraphComponent):
...
@@ -773,7 +795,9 @@ class AbstractOperation(Operation, AbstractGraphComponent):
@property
@property
def
preceding_operations
(
self
)
->
Iterable
[
Operation
]:
def
preceding_operations
(
self
)
->
Iterable
[
Operation
]:
"""
Returns an Iterable of all Operations that are connected to this Operations input ports.
"""
Return an Iterable of all Operations that are connected to this
Operations input ports.
"""
"""
return
[
return
[
signal
.
source
.
operation
signal
.
source
.
operation
...
@@ -783,7 +807,9 @@ class AbstractOperation(Operation, AbstractGraphComponent):
...
@@ -783,7 +807,9 @@ class AbstractOperation(Operation, AbstractGraphComponent):
@property
@property
def
subsequent_operations
(
self
)
->
Iterable
[
Operation
]:
def
subsequent_operations
(
self
)
->
Iterable
[
Operation
]:
"""
Returns an Iterable of all Operations that are connected to this Operations output ports.
"""
Return an Iterable of all Operations that are connected to this
Operations output ports.
"""
"""
return
[
return
[
signal
.
destination
.
operation
signal
.
destination
.
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