Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
HDL
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RTSD
HDL
Commits
446933cd
Commit
446933cd
authored
8 years ago
by
Daniel van der Schuur
Browse files
Options
Downloads
Patches
Plain Diff
-Added generator output limiter (nof_blocks).
parent
9a0b73bb
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
applications/arts/doc/python/arts_sc1.py
+5
-12
5 additions, 12 deletions
applications/arts/doc/python/arts_sc1.py
applications/arts/doc/python/stream.py
+35
-30
35 additions, 30 deletions
applications/arts/doc/python/stream.py
with
40 additions
and
42 deletions
applications/arts/doc/python/arts_sc1.py
+
5
−
12
View file @
446933cd
...
@@ -42,7 +42,7 @@ N_POL = 2 # Number of polarizations
...
@@ -42,7 +42,7 @@ N_POL = 2 # Number of polarizations
N_BAND
=
16
# Number of bands
N_BAND
=
16
# Number of bands
# Serial (time) dimensions
# Serial (time) dimensions
N_INT_X
=
800000
# Number of time samples per corrrelator intergration period
N_INT_X
=
800000
# Number of time samples per corrrelator intergration period
N_SLOT
=
1024
#
FIXME we need global indices here, don't we?
N_SLOT
=
1024
#
Number of beamlet slots on single BF FN
W_BEAMLET
=
6
# Complex beamlet data width
W_BEAMLET
=
6
# Complex beamlet data width
nof_intervals
=
0
# Unlimited runtime
nof_intervals
=
0
# Unlimited runtime
...
@@ -57,25 +57,18 @@ data_width = N_POL*W_BEAMLET
...
@@ -57,25 +57,18 @@ data_width = N_POL*W_BEAMLET
parallel_definition
=
((
'
dish
'
,
N_DISH
),
(
'
polarization
'
,
N_POL
),
(
'
band
'
,
N_BAND
))
parallel_definition
=
((
'
dish
'
,
N_DISH
),
(
'
polarization
'
,
N_POL
),
(
'
band
'
,
N_BAND
))
serial_definition
=
((
'
interval
'
,
nof_intervals
,
T_INT_X
),(
'
timesample
'
,
N_INT_X
),
(
'
slot
'
,
N_SLOT
))
serial_definition
=
((
'
interval
'
,
nof_intervals
,
T_INT_X
),(
'
timesample
'
,
N_INT_X
),
(
'
slot
'
,
N_SLOT
))
CB444
=
StreamArray
(
parallel_definition
,
serial_definition
,
data_width
,
block_size
=
1024
)
CB444
=
StreamArray
(
parallel_definition
,
serial_definition
,
data_width
,
block_size
=
1024
,
nof_blocks
=
1
)
# Print dish 0, pol 0, band (front node) 0:
# Print dish 0, pol 0, band (front node) 0:
for
i
in
CB444
[
0
][
0
][
0
]:
for
i
in
CB444
[
0
][
0
][
0
]:
print
i
[
'
dish
'
]
print
i
[
'
slot
'
]
break
for
i
in
CB444
[
0
][
0
][
1
]:
print
i
[
'
dish
'
]
break
###############################################################################
###############################################################################
# Equation 2: transpose the band and dish (physical) dimensions of CB444: flip dimensions 0 and 2
# Equation 2: transpose the band and dish (physical) dimensions of CB444: flip dimensions 0 and 2
###############################################################################
###############################################################################
CB444_T
=
CB444
.
transpose
((
2
,
1
,
0
))
#NOTE transpose works. How to print this nicely?
CB444_T
=
CB444
.
transpose
((
2
,
1
,
0
))
for
i
in
CB444_T
[
0
][
0
][
0
]:
for
i
in
CB444_T
[
0
][
0
][
0
]:
print
i
[
'
dish
'
]
print
i
[
'
dish
'
]
break
for
i
in
CB444_T
[
0
][
0
][
1
]:
print
i
[
'
dish
'
]
break
This diff is collapsed.
Click to expand it.
applications/arts/doc/python/stream.py
+
35
−
30
View file @
446933cd
...
@@ -7,7 +7,7 @@ class Stream:
...
@@ -7,7 +7,7 @@ class Stream:
"""
"""
Single serial stream generator
Single serial stream generator
"""
"""
def
__init__
(
self
,
parallel_definition
,
serial_definition
,
data_width
,
block_size
):
def
__init__
(
self
,
parallel_definition
,
serial_definition
,
data_width
,
block_size
,
nof_blocks
):
# Parallel definition: physical stream tags and indices for this serial stream
# Parallel definition: physical stream tags and indices for this serial stream
self
.
parallel_definition
=
parallel_definition
self
.
parallel_definition
=
parallel_definition
...
@@ -34,11 +34,18 @@ class Stream:
...
@@ -34,11 +34,18 @@ class Stream:
self
.
serial_data_out
.
append
(
dimension
-
1
)
self
.
serial_data_out
.
append
(
dimension
-
1
)
# Create an interval out counter. Initialize to -1 as there is no maximum
# Create an interval out counter. Initialize to -1 as there is no maximum
self
.
interval_out
=
-
1
self
.
interval_out
=
-
1
self
.
block_size
=
block_size
self
.
block_size
=
block_size
self
.
last
_block
_lo
=
0
self
.
nof
_block
s
=
nof_blocks
self
.
last_block_hi
=
block_size
self
.
out_count
=
0
def
next
(
self
):
def
next
(
self
):
# Break out of the generator loop when we've output nof_blocks
if
self
.
nof_blocks
>
0
and
self
.
out_count
==
self
.
nof_blocks
:
self
.
out_count
=
0
raise
StopIteration
else
:
self
.
out_count
+=
1
block
=
[]
block
=
[]
for
i
in
range
(
self
.
block_size
):
for
i
in
range
(
self
.
block_size
):
# Start with the fastest changing dimension (index -1). When we have e.g. 2 dimensions, don't go beyond index -2.
# Start with the fastest changing dimension (index -1). When we have e.g. 2 dimensions, don't go beyond index -2.
...
@@ -67,12 +74,10 @@ class Stream:
...
@@ -67,12 +74,10 @@ class Stream:
class
StreamArray
(
np
.
ndarray
):
class
StreamArray
(
np
.
ndarray
):
"""
"""
NOTE: Use get() functions instead of fixed attributes as indexing a subset of StreamArray should yield e.g.
User can limit the generated output using nof_intervals (highest dimension = still large amount of output)
a different data rate than the full array.
or nof_blocks (lowest dimension = small amount of output). 0=unlimited.
NOTE: An ESSENTIAL property of subclassing numpy array is that method return values *DEPEND ON THE INDEXED SUBSTREAMS*!
. e.g. pass substream to Component without the difficulties of component_class.py!
"""
"""
def
__new__
(
cls
,
parallel_definition
,
serial_definition
,
data_width
,
block_size
):
def
__new__
(
cls
,
parallel_definition
,
serial_definition
,
data_width
,
block_size
,
nof_blocks
):
# We need the parallel dimensions here, but we'll pass the parallel tags to the serial Stream instances.
# We need the parallel dimensions here, but we'll pass the parallel tags to the serial Stream instances.
parallel_tags
=
[
pair
[
0
]
for
pair
in
parallel_definition
]
parallel_tags
=
[
pair
[
0
]
for
pair
in
parallel_definition
]
parallel_dimensions
=
[
pair
[
1
]
for
pair
in
parallel_definition
]
parallel_dimensions
=
[
pair
[
1
]
for
pair
in
parallel_definition
]
...
@@ -84,7 +89,7 @@ class StreamArray(np.ndarray):
...
@@ -84,7 +89,7 @@ class StreamArray(np.ndarray):
for
index
in
np
.
ndindex
(
tuple
(
parallel_dimensions
)):
for
index
in
np
.
ndindex
(
tuple
(
parallel_dimensions
)):
parallel_definition
=
zip
(
parallel_tags
,
index
)
parallel_definition
=
zip
(
parallel_tags
,
index
)
# Replace the dimension size in the parallel_definition with the actual stream index
# Replace the dimension size in the parallel_definition with the actual stream index
streams
.
append
(
Stream
(
parallel_definition
,
serial_definition
,
data_width
,
block_size
))
streams
.
append
(
Stream
(
parallel_definition
,
serial_definition
,
data_width
,
block_size
,
nof_blocks
))
input_array
=
np
.
array
(
streams
)
input_array
=
np
.
array
(
streams
)
input_array
.
resize
(
parallel_dimensions
)
input_array
.
resize
(
parallel_dimensions
)
...
...
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