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
f8334097
Commit
f8334097
authored
5 years ago
by
angloth
Browse files
Options
Downloads
Patches
Plain Diff
Add graph id generator and function for adding operation to SFG
parent
bb7ec09a
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/graph_id.py
+7
-8
7 additions, 8 deletions
b_asic/graph_id.py
b_asic/signal_flow_graph.py
+18
-13
18 additions, 13 deletions
b_asic/signal_flow_graph.py
with
25 additions
and
21 deletions
b_asic/graph_id.py
+
7
−
8
View file @
f8334097
...
...
@@ -10,15 +10,18 @@ class GraphIDGenerator:
"""
A class that generates Graph IDs for objects.
"""
_next_id_number
:
DefaultDict
(
str
,
int
)
def
__init__
(
self
):
_next_id_number
=
defaultdict
(
lambda
:
1
)
# Initalises every key element to 1
self
.
_next_id_number
=
defaultdict
(
lambda
:
1
)
# Initalises every key element to 1
def
get_next_id
(
self
,
graph_id_type
:
str
):
graph_id
=
GraphID
(
graph_id_type
,
_next_id_number
[
graph_id_type
])
_next_id_number
[
graph_id_type
]
+=
1
"""
Retrns the next graph id for a certain graph id type.
"""
graph_id
=
GraphID
(
graph_id_type
,
self
.
_next_id_number
[
graph_id_type
])
self
.
_next_id_number
[
graph_id_type
]
+=
1
# Increment the current number
return
graph_id
...
...
@@ -58,7 +61,3 @@ class GraphID:
Returns a new GraphID of the same type with an incremented id number.
"""
return
GraphID
(
self
.
graph_id_type
,
self
.
graph_id_number
+
1
)
def
is_id_in_use
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
b_asic/signal_flow_graph.py
+
18
−
13
View file @
f8334097
...
...
@@ -7,12 +7,8 @@ from b_asic.operation import Operation
from
b_asic.basic_operation
import
BasicOperation
from
b_asic.signal
import
Signal
,
SignalSource
,
SignalDestination
from
b_asic.simulation
import
SimulationState
,
OperationState
from
typing
import
List
,
Dict
# Types
OperationId
=
NewType
(
"
OperationId
"
,
int
)
SignalId
=
NewType
(
"
SignalId
"
,
int
)
from
typing
import
List
,
Dict
,
Union
from
graph_id
import
GraphIDGenerator
,
GraphID
class
SFG
(
BasicOperation
):
...
...
@@ -21,18 +17,18 @@ class SFG(BasicOperation):
TODO: More info.
"""
_
operations
:
Dict
[
OperationID
,
Operation
]
_
signals
:
Dict
[
SignalID
,
Signal
]
_
graph_objects
:
Dict
(
GraphID
,
Union
(
Operation
,
Signal
))
_
graph_id_generator
:
GraphIDGenerator
def
__init__
(
self
,
input_destinations
:
List
[
SignalDestination
],
output_sources
:
List
[
SignalSource
]):
"""
Construct a SFG.
"""
super
().
__init__
(
identifier
)
super
().
__init__
()
# TODO: Allocate input/output ports with appropriate IDs.
self
.
_
operation
s
=
dict
# Map Operation ID to Operation objects
self
.
_
signals
=
dict
# Map Signal ID to Signal objects
self
.
_
graph_object
s
=
dict
# Map Operation ID to Operation objects
self
.
_
graph_id_generator
=
GraphIDGenerator
()
# TODO: Traverse the graph between the inputs/outputs and add to self._operations.
# TODO: Connect ports with signals with appropriate IDs.
...
...
@@ -40,6 +36,15 @@ class SFG(BasicOperation):
def
evaluate
(
self
,
inputs
:
list
)
->
list
:
return
[]
# TODO: Implement
def
split
(
self
)
->
List
[
Operation
]:
return
self
def
add_operation
(
self
,
operation
:
Operation
)
->
GraphID
:
"""
Adds the entered operation to the SFG
'
s dictionary of graph objects and
generates and returns a GraphID for it.
"""
graph_id
=
self
.
_graph_id_generator
.
get_next_id
(
"
op
"
)
self
.
_graph_objects
[
graph_id
]
=
operation
return
graph_id
def
_generate_id
(
self
)
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