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
4d0c50b5
Commit
4d0c50b5
authored
1 year ago
by
Oscar Gustafsson
Browse files
Options
Downloads
Patches
Plain Diff
Minor modifications
parent
2a591089
No related branches found
No related tags found
1 merge request
!340
Minor modifications
Pipeline
#96554
passed
1 year ago
Stage: test
Stage: deploy
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
b_asic/architecture.py
+41
-30
41 additions, 30 deletions
b_asic/architecture.py
test/test_architecture.py
+2
-2
2 additions, 2 deletions
test/test_architecture.py
with
43 additions
and
32 deletions
b_asic/architecture.py
+
41
−
30
View file @
4d0c50b5
...
@@ -15,9 +15,14 @@ class ProcessingElement:
...
@@ -15,9 +15,14 @@ class ProcessingElement:
Parameters
Parameters
----------
----------
process_collection : :class:`~b_asic.resources.ProcessCollection`
process_collection : :class:`~b_asic.resources.ProcessCollection`
Process collection containing operations to map to processing element.
entity_name : str, optional
Name of processing element entity.
"""
"""
def
__init__
(
self
,
process_collection
:
ProcessCollection
,
name
=
""
):
def
__init__
(
self
,
process_collection
:
ProcessCollection
,
entity_name
:
Optional
[
str
]
=
None
):
if
not
len
(
process_collection
):
if
not
len
(
process_collection
):
raise
ValueError
(
raise
ValueError
(
"
Do not create ProcessingElement with empty ProcessCollection
"
"
Do not create ProcessingElement with empty ProcessCollection
"
...
@@ -40,22 +45,19 @@ class ProcessingElement:
...
@@ -40,22 +45,19 @@ class ProcessingElement:
self
.
_collection
=
process_collection
self
.
_collection
=
process_collection
self
.
_operation_type
=
op_type
self
.
_operation_type
=
op_type
self
.
_type_name
=
op_type
.
type_name
()
self
.
_type_name
=
op_type
.
type_name
()
self
.
_
name
=
name
self
.
_
entity_name
=
entity_
name
@property
@property
def
processes
(
self
)
->
Set
[
OperatorProcess
]:
def
processes
(
self
)
->
Set
[
OperatorProcess
]:
return
{
cast
(
OperatorProcess
,
p
)
for
p
in
self
.
_collection
}
return
{
cast
(
OperatorProcess
,
p
)
for
p
in
self
.
_collection
}
def
__str__
(
self
):
return
self
.
_name
or
self
.
_type_name
def
__repr__
(
self
):
def
__repr__
(
self
):
return
self
.
_name
or
self
.
_type_name
return
self
.
_
entity_
name
or
self
.
_type_name
def
set_name
(
self
,
name
:
str
):
def
set_
entity_
name
(
self
,
entity_
name
:
str
):
self
.
_
name
=
name
self
.
_
entity_name
=
entity_
name
def
write_code
(
self
,
path
:
str
,
entity_name
:
str
)
->
None
:
def
write_code
(
self
,
path
:
str
)
->
None
:
"""
"""
Write VHDL code for processing element.
Write VHDL code for processing element.
...
@@ -63,8 +65,9 @@ class ProcessingElement:
...
@@ -63,8 +65,9 @@ class ProcessingElement:
----------
----------
path : str
path : str
Directory to write code in.
Directory to write code in.
entity_name : str
"""
"""
if
not
self
.
_entity_name
:
raise
ValueError
(
"
Entity name must be set
"
)
raise
NotImplementedError
raise
NotImplementedError
...
@@ -78,10 +81,15 @@ class Memory:
...
@@ -78,10 +81,15 @@ class Memory:
The ProcessCollection to create a Memory for.
The ProcessCollection to create a Memory for.
memory_type : {
'
RAM
'
,
'
register
'
}
memory_type : {
'
RAM
'
,
'
register
'
}
The type of memory.
The type of memory.
entity_name : str, optional
Name of memory entity.
"""
"""
def
__init__
(
def
__init__
(
self
,
process_collection
:
ProcessCollection
,
memory_type
:
str
=
"
RAM
"
,
name
=
""
self
,
process_collection
:
ProcessCollection
,
memory_type
:
str
=
"
RAM
"
,
entity_name
:
Optional
[
str
]
=
None
,
):
):
if
not
len
(
process_collection
):
if
not
len
(
process_collection
):
raise
ValueError
(
"
Do not create Memory with empty ProcessCollection
"
)
raise
ValueError
(
"
Do not create Memory with empty ProcessCollection
"
)
...
@@ -93,23 +101,24 @@ class Memory:
...
@@ -93,23 +101,24 @@ class Memory:
"
Can only have MemoryVariable or PlainMemoryVariable in
"
"
Can only have MemoryVariable or PlainMemoryVariable in
"
"
ProcessCollection when creating Memory
"
"
ProcessCollection when creating Memory
"
)
)
if
memory_type
not
in
(
"
RAM
"
,
"
register
"
):
raise
ValueError
(
f
"
memory_type must be
'
RAM
'
or
'
register
'
, not
{
memory_type
!r}
"
)
self
.
_collection
=
process_collection
self
.
_collection
=
process_collection
self
.
_memory_type
=
memory_type
self
.
_memory_type
=
memory_type
self
.
_
name
=
name
self
.
_
entity_name
=
entity_
name
def
__iter__
(
self
):
def
__iter__
(
self
):
return
iter
(
self
.
_collection
)
return
iter
(
self
.
_collection
)
def
set_name
(
self
,
name
:
str
):
def
set_entity_name
(
self
,
entity_name
:
str
):
self
.
_name
=
name
self
.
_entity_name
=
entity_name
def
__str__
(
self
):
return
self
.
_name
or
self
.
_memory_type
def
__repr__
(
self
):
def
__repr__
(
self
):
return
self
.
_name
or
self
.
_memory_type
return
self
.
_
entity_
name
or
self
.
_memory_type
def
write_code
(
self
,
path
:
str
,
entity_name
:
str
)
->
None
:
def
write_code
(
self
,
path
:
str
)
->
None
:
"""
"""
Write VHDL code for memory.
Write VHDL code for memory.
...
@@ -117,13 +126,9 @@ class Memory:
...
@@ -117,13 +126,9 @@ class Memory:
----------
----------
path : str
path : str
Directory to write code in.
Directory to write code in.
entity_name : str
Returns
-------
"""
"""
if
not
self
.
_entity_name
:
raise
ValueError
(
"
Entity name must be set
"
)
raise
NotImplementedError
raise
NotImplementedError
...
@@ -137,9 +142,8 @@ class Architecture:
...
@@ -137,9 +142,8 @@ class Architecture:
The processing elements in the architecture.
The processing elements in the architecture.
memories : set of :class:`~b_asic.architecture.Memory`
memories : set of :class:`~b_asic.architecture.Memory`
The memories in the architecture.
The memories in the architecture.
name : str, default:
"
arch
"
entity_name : str, default:
"
arch
"
Name for the top-level architecture. Used for the entity and as prefix for all
Name for the top-level entity.
building blocks.
direct_interconnects : ProcessCollection, optional
direct_interconnects : ProcessCollection, optional
Process collection of zero-time memory variables used for direct interconnects.
Process collection of zero-time memory variables used for direct interconnects.
"""
"""
...
@@ -148,12 +152,12 @@ class Architecture:
...
@@ -148,12 +152,12 @@ class Architecture:
self
,
self
,
processing_elements
:
Set
[
ProcessingElement
],
processing_elements
:
Set
[
ProcessingElement
],
memories
:
Set
[
Memory
],
memories
:
Set
[
Memory
],
name
:
str
=
"
arch
"
,
entity_
name
:
str
=
"
arch
"
,
direct_interconnects
:
Optional
[
ProcessCollection
]
=
None
,
direct_interconnects
:
Optional
[
ProcessCollection
]
=
None
,
):
):
self
.
_processing_elements
=
processing_elements
self
.
_processing_elements
=
processing_elements
self
.
_memories
=
memories
self
.
_memories
=
memories
self
.
_
name
=
name
self
.
_
entity_name
=
entity_
name
self
.
_direct_interconnects
=
direct_interconnects
self
.
_direct_interconnects
=
direct_interconnects
self
.
_variable_inport_to_resource
=
{}
self
.
_variable_inport_to_resource
=
{}
self
.
_variable_outport_to_resource
=
{}
self
.
_variable_outport_to_resource
=
{}
...
@@ -259,6 +263,9 @@ class Architecture:
...
@@ -259,6 +263,9 @@ class Architecture:
d_out
[
i
][
self
.
_variable_outport_to_resource
[
output
]]
+=
1
d_out
[
i
][
self
.
_variable_outport_to_resource
[
output
]]
+=
1
return
[
dict
(
d
)
for
d
in
d_in
],
[
dict
(
d
)
for
d
in
d_out
]
return
[
dict
(
d
)
for
d
in
d_in
],
[
dict
(
d
)
for
d
in
d_out
]
def
set_entity_name
(
self
,
entity_name
:
str
):
self
.
_entity_name
=
entity_name
@property
@property
def
memories
(
self
)
->
Set
[
Memory
]:
def
memories
(
self
)
->
Set
[
Memory
]:
return
self
.
_memories
return
self
.
_memories
...
@@ -266,3 +273,7 @@ class Architecture:
...
@@ -266,3 +273,7 @@ class Architecture:
@property
@property
def
processing_elements
(
self
)
->
Set
[
ProcessingElement
]:
def
processing_elements
(
self
)
->
Set
[
ProcessingElement
]:
return
self
.
_processing_elements
return
self
.
_processing_elements
@property
def
direct_interconnects
(
self
)
->
Optional
[
ProcessCollection
]:
return
self
.
_direct_interconnects
This diff is collapsed.
Click to expand it.
test/test_architecture.py
+
2
−
2
View file @
4d0c50b5
...
@@ -86,7 +86,7 @@ def test_architecture(schedule_direct_form_iir_lp_filter: Schedule):
...
@@ -86,7 +86,7 @@ def test_architecture(schedule_direct_form_iir_lp_filter: Schedule):
for
operation
in
chain
(
adders
,
const_mults
,
inputs
,
outputs
)
for
operation
in
chain
(
adders
,
const_mults
,
inputs
,
outputs
)
]
]
for
i
,
pe
in
enumerate
(
processing_elements
):
for
i
,
pe
in
enumerate
(
processing_elements
):
pe
.
set_name
(
f
"
{
pe
.
_type_name
.
upper
()
}
-
{
i
}
"
)
pe
.
set_
entity_
name
(
f
"
{
pe
.
_type_name
.
upper
()
}
-
{
i
}
"
)
# Extract zero-length memory variables
# Extract zero-length memory variables
direct_conn
,
mvs
=
mvs
.
split_on_length
()
direct_conn
,
mvs
=
mvs
.
split_on_length
()
...
@@ -97,7 +97,7 @@ def test_architecture(schedule_direct_form_iir_lp_filter: Schedule):
...
@@ -97,7 +97,7 @@ def test_architecture(schedule_direct_form_iir_lp_filter: Schedule):
]
]
assert
len
(
memories
)
==
1
assert
len
(
memories
)
==
1
for
i
,
memory
in
enumerate
(
memories
):
for
i
,
memory
in
enumerate
(
memories
):
memory
.
set_name
(
f
"
mem-
{
i
}
"
)
memory
.
set_
entity_
name
(
f
"
mem-
{
i
}
"
)
# Create architecture from
# Create architecture from
architecture
=
Architecture
(
architecture
=
Architecture
(
...
...
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