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
861edd50
Commit
861edd50
authored
5 years ago
by
angloth
Browse files
Options
Downloads
Patches
Plain Diff
Add abstract method get_op_name to Operation and implement it for the existing core operations
parent
1bb21a40
No related branches found
Branches containing commit
No related tags found
1 merge request
!2
Integrated ID system, traversing and som signal tests
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
b_asic/core_operations.py
+14
-5
14 additions, 5 deletions
b_asic/core_operations.py
b_asic/operation.py
+7
-1
7 additions, 1 deletion
b_asic/operation.py
with
21 additions
and
6 deletions
b_asic/core_operations.py
+
14
−
5
View file @
861edd50
...
...
@@ -6,6 +6,7 @@ TODO: More info.
from
b_asic.port
import
InputPort
,
OutputPort
from
b_asic.operation
import
OperationId
,
Operation
from
b_asic.basic_operation
import
BasicOperation
from
b_asic.graph_id
import
GraphIDType
from
numbers
import
Number
...
...
@@ -15,7 +16,7 @@ class Input(Operation):
TODO: More info.
"""
# TODO: Implement.
# TODO: Implement
all functions
.
pass
...
...
@@ -36,6 +37,8 @@ class Constant(BasicOperation):
def
evaluate
(
self
,
inputs
:
list
)
->
list
:
return
[
self
.
param
(
"
value
"
)]
def
get_op_name
(
self
)
->
GraphIDType
:
return
"
const
"
class
Addition
(
BasicOperation
):
"""
...
...
@@ -48,12 +51,15 @@ class Addition(BasicOperation):
Construct an Addition.
"""
super
().
__init__
(
identifier
)
self
.
_input_ports
=
[
InputPort
(),
InputPort
()]
# TODO: Generate appropriate ID for ports.
self
.
_output_ports
=
[
OutputPort
()]
# TODO: Generate appropriate ID for ports.
self
.
_input_ports
=
[
InputPort
(
1
),
InputPort
(
1
)]
# TODO: Generate appropriate ID for ports.
self
.
_output_ports
=
[
OutputPort
(
1
)]
# TODO: Generate appropriate ID for ports.
def
evaluate
(
self
,
inputs
:
list
)
->
list
:
return
[
inputs
[
0
]
+
inputs
[
1
]]
def
get_op_name
(
self
)
->
GraphIDType
:
return
"
add
"
class
ConstantMultiplication
(
BasicOperation
):
"""
...
...
@@ -66,11 +72,14 @@ class ConstantMultiplication(BasicOperation):
Construct a ConstantMultiplication.
"""
super
().
__init__
(
identifier
)
self
.
_input_ports
=
[
InputPort
()]
# TODO: Generate appropriate ID for ports.
self
.
_output_ports
=
[
OutputPort
()]
# TODO: Generate appropriate ID for ports.
self
.
_input_ports
=
[
InputPort
(
1
)]
# TODO: Generate appropriate ID for ports.
self
.
_output_ports
=
[
OutputPort
(
1
)]
# TODO: Generate appropriate ID for ports.
self
.
_parameters
[
"
coefficient
"
]
=
coefficient
def
evaluate
(
self
,
inputs
:
list
)
->
list
:
return
[
inputs
[
0
]
*
self
.
param
(
"
coefficient
"
)]
def
get_op_name
(
self
)
->
GraphIDType
:
return
"
const_mul
"
# TODO: More operations.
This diff is collapsed.
Click to expand it.
b_asic/operation.py
+
7
−
1
View file @
861edd50
...
...
@@ -10,6 +10,7 @@ from typing import NewType, List, Dict, Optional, Any, TYPE_CHECKING
if
TYPE_CHECKING
:
from
b_asic.port
import
InputPort
,
OutputPort
from
b_asic.simulation
import
SimulationState
from
b_asic.graph_id
import
GraphIDType
class
Operation
(
ABC
):
"""
...
...
@@ -87,7 +88,7 @@ class Operation(ABC):
"""
Simulate the circuit until its iteration count matches that of the simulation state,
then return the resulting output vector.
"""
"""
pass
@abstractmethod
...
...
@@ -98,5 +99,10 @@ class Operation(ABC):
"""
pass
@abstractmethod
def
get_op_name
(
self
)
->
"
GraphIDType
"
:
"""
Returns a string representing the operation name of the operation.
"""
pass
# TODO: More stuff.
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