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
b0d9fcf0
Commit
b0d9fcf0
authored
1 year ago
by
Oscar Gustafsson
Browse files
Options
Downloads
Patches
Plain Diff
Add support for parallel interleaver generation
parent
4f32ce08
No related branches found
No related tags found
1 merge request
!253
Add support for parallel interleaver generation
Pipeline
#92544
passed
1 year ago
Stage: test
Changes
1
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
b_asic/research/interleaver.py
+42
-25
42 additions, 25 deletions
b_asic/research/interleaver.py
with
42 additions
and
25 deletions
b_asic/research/interleaver.py
+
42
−
25
View file @
b0d9fcf0
...
...
@@ -3,6 +3,7 @@ Functions to generate memory-variable test data that are used for research.
"""
import
random
from
itertools
import
product
from
typing
import
List
,
Optional
,
Tuple
from
b_asic.process
import
PlainMemoryVariable
...
...
@@ -10,21 +11,25 @@ from b_asic.resources import ProcessCollection
def
_insert_delays
(
inputorder
:
List
[
int
],
outputorder
:
List
[
int
],
min_lifetime
:
int
,
cyclic
:
bool
)
->
Tuple
[
List
[
int
],
List
[
int
]]:
inputorder
:
List
[
Tuple
[
int
,
int
]],
outputorder
:
List
[
Tuple
[
int
,
int
]],
min_lifetime
:
int
,
cyclic
:
bool
,
time
:
int
,
)
->
Tuple
[
List
[
Tuple
[
int
,
int
]],
List
[
Tuple
[
int
,
int
]]]:
size
=
len
(
inputorder
)
maxdiff
=
min
(
outputorder
[
i
]
-
inputorder
[
i
]
for
i
in
range
(
size
))
outputorder
=
[
o
-
maxdiff
+
min_lifetime
for
o
in
outputorder
]
maxdelay
=
max
(
outputorder
[
i
]
-
inputorder
[
i
]
for
i
in
range
(
size
))
maxdiff
=
min
(
outputorder
[
i
]
[
0
]
-
inputorder
[
i
]
[
0
]
for
i
in
range
(
size
))
outputorder
=
[
(
o
[
0
]
-
maxdiff
+
min_lifetime
,
o
[
1
])
for
o
in
outputorder
]
maxdelay
=
max
(
outputorder
[
i
]
[
0
]
-
inputorder
[
i
]
[
0
]
for
i
in
range
(
size
))
if
cyclic
:
if
maxdelay
>=
siz
e
:
inputorder
=
inputorder
+
[
i
+
size
for
i
in
inputorder
]
outputorder
=
outputorder
+
[
o
+
size
for
o
in
outputorder
]
if
maxdelay
>=
tim
e
:
inputorder
=
inputorder
+
[
(
i
[
0
]
+
time
,
i
[
1
])
for
i
in
inputorder
]
outputorder
=
outputorder
+
[
(
o
[
0
]
+
time
,
o
[
1
])
for
o
in
outputorder
]
return
inputorder
,
outputorder
def
generate_random_interleaver
(
size
:
int
,
min_lifetime
:
int
=
0
,
cyclic
:
bool
=
True
size
:
int
,
min_lifetime
:
int
=
0
,
cyclic
:
bool
=
True
,
parallelism
:
int
=
1
)
->
ProcessCollection
:
"""
Generate a ProcessCollection with memory variable corresponding to a random
...
...
@@ -40,24 +45,28 @@ def generate_random_interleaver(
cyclic : bool, default: True
If the interleaver should operate continuously in a cyclic manner. That is,
start a new interleaving operation directly after the previous.
parallelism : int, default: 1
Number of values to input and output every cycle.
Returns
-------
ProcessCollection
"""
inputorders
=
list
(
range
(
size
))
inputorders
=
list
(
product
(
range
(
size
)
,
range
(
parallelism
))
)
outputorders
=
inputorders
[:]
random
.
shuffle
(
outputorders
)
inputorders
,
outputorders
=
_insert_delays
(
inputorders
,
outputorders
,
min_lifetime
,
cyclic
inputorders
,
outputorders
,
min_lifetime
,
cyclic
,
size
)
return
ProcessCollection
(
{
PlainMemoryVariable
(
inputorder
,
0
,
{
0
:
outputorders
[
i
]
-
inputorder
})
PlainMemoryVariable
(
*
inputorder
,
{
outputorders
[
i
][
1
]:
outputorders
[
i
][
0
]
-
inputorder
[
0
]}
)
for
i
,
inputorder
in
enumerate
(
inputorders
)
},
len
(
inputorders
),
len
(
inputorders
)
//
parallelism
,
cyclic
,
)
...
...
@@ -67,6 +76,7 @@ def generate_matrix_transposer(
cols
:
Optional
[
int
]
=
None
,
min_lifetime
:
int
=
0
,
cyclic
:
bool
=
True
,
parallelism
:
int
=
1
,
)
->
ProcessCollection
:
r
"""
Generate a ProcessCollection with memory variable corresponding to transposing a
...
...
@@ -86,6 +96,8 @@ def generate_matrix_transposer(
cyclic : bool, default: True
If the interleaver should operate continuously in a cyclic manner. That is,
start a new interleaving operation directly after the previous.
parallelism : int, default: 1
Number of values to input and output every cycle.
Returns
-------
...
...
@@ -94,29 +106,34 @@ def generate_matrix_transposer(
if
cols
is
None
:
cols
=
rows
inputorder
=
[]
if
(
rows
*
cols
//
parallelism
)
*
parallelism
!=
rows
*
cols
:
raise
ValueError
(
f
"
parallelism (
{
parallelism
}
) must be an integer multiple of rows*cols
"
f
"
(
{
rows
}
*
{
cols
}
=
{
rows
*
cols
}
)
"
)
inputorders
=
[]
for
col
in
range
(
cols
):
for
row
in
range
(
rows
):
inputorder
.
append
(
row
+
rows
*
col
)
inputorder
s
.
append
(
((
row
+
rows
*
col
)
//
parallelism
,
row
%
parallelism
))
outputorder
=
[]
outputorder
s
=
[]
for
row
in
range
(
rows
):
for
col
in
range
(
cols
):
outputorder
.
append
(
col
*
rows
+
row
)
outputorder
s
.
append
(
((
col
*
rows
+
row
)
//
parallelism
,
col
%
parallelism
))
inputorder
,
outputorder
=
_insert_delays
(
inputorder
,
outputorder
,
min_lifetime
,
cyclic
inputorder
s
,
outputorder
s
=
_insert_delays
(
inputorder
s
,
outputorder
s
,
min_lifetime
,
cyclic
,
rows
*
cols
//
parallelism
)
return
ProcessCollection
(
{
PlainMemoryVariable
(
inputorder
[
i
],
0
,
{
0
:
outputorder
[
i
]
-
inputorder
[
i
]},
name
=
f
"
{
inputorder
[
i
]
}
"
,
*
inputorder
,
{
outputorders
[
i
][
1
]:
outputorders
[
i
][
0
]
-
inputorder
[
0
]},
name
=
f
"
{
inputorders
[
i
][
0
]
*
parallelism
+
inputorders
[
i
][
1
]
}
"
,
)
for
i
in
range
(
len
(
inputorder
)
)
for
i
,
in
putorder
in
enumerate
(
inputorder
s
)
},
len
(
inputorder
)
,
len
(
inputorder
s
)
//
parallelism
,
cyclic
,
)
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