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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RTSD
HDL
Commits
52c33b20
Commit
52c33b20
authored
10 years ago
by
Daniel van der Schuur
Browse files
Options
Downloads
Patches
Plain Diff
-Fixed rounding errors by feeding integer data to the Python model also.
parent
5e3e74b1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
libraries/dsp/correlator/tb/python/verify_correlator.py
+62
-7
62 additions, 7 deletions
libraries/dsp/correlator/tb/python/verify_correlator.py
with
62 additions
and
7 deletions
libraries/dsp/correlator/tb/python/verify_correlator.py
+
62
−
7
View file @
52c33b20
...
@@ -98,19 +98,36 @@ def complex_to_int(input_lists):
...
@@ -98,19 +98,36 @@ def complex_to_int(input_lists):
re
=
int
(
round
(
input_lists
[
input_nr
][
word
].
real
))
re
=
int
(
round
(
input_lists
[
input_nr
][
word
].
real
))
im
=
int
(
round
(
input_lists
[
input_nr
][
word
].
imag
))
im
=
int
(
round
(
input_lists
[
input_nr
][
word
].
imag
))
print
'
Input
'
,
input_nr
,
'
Channel
'
,
word
,
'
re,im
'
,
re
,
im
print
'
Input
'
,
input_nr
,
'
Channel
'
,
word
,
'
re,im
'
,
re
,
im
re_bits
=
CommonBits
(
re
,
COMPLEX_WIDTH
)
output_list
.
append
(
complex
(
re
,
im
))
im_bits
=
CommonBits
(
im
,
COMPLEX_WIDTH
)
output_lists
.
append
(
output_list
)
return
output_lists
#correlator_snk_in_arr
def
concat_complex
(
input_lists
):
"""
Concatenate im&re into one integer
"""
output_lists
=
[]
for
input_nr
in
range
(
NOF_INPUTS
):
output_list
=
[]
for
word
in
range
(
NOF_CHANNELS
):
re_bits
=
CommonBits
(
int
(
input_lists
[
input_nr
][
word
].
real
),
COMPLEX_WIDTH
)
im_bits
=
CommonBits
(
int
(
input_lists
[
input_nr
][
word
].
imag
),
COMPLEX_WIDTH
)
concat_bits
=
im_bits
&
re_bits
concat_bits
=
im_bits
&
re_bits
output_list
.
append
(
concat_bits
.
data
)
output_list
.
append
(
concat_bits
.
data
)
output_lists
.
append
(
output_list
)
output_lists
.
append
(
output_list
)
return
output_lists
#correlator_snk_in_arr
return
output_lists
def
gen_correlator_snk_in_arr_hex
(
input_lists
):
def
gen_correlator_snk_in_arr_hex
(
input_lists
):
"""
"""
bla
bla
"""
"""
concat_input_lists
=
concat_complex
(
input_lists
)
# ==========================================================
# ==========================================================
# Interleave the lists if user wants folded correlator input
# Interleave the lists if user wants folded correlator input
# . Note: no support for more than 1 fold yet.
# . Note: no support for more than 1 fold yet.
...
@@ -118,9 +135,9 @@ def gen_correlator_snk_in_arr_hex(input_lists):
...
@@ -118,9 +135,9 @@ def gen_correlator_snk_in_arr_hex(input_lists):
if
NOF_FOLDS
==
1
:
if
NOF_FOLDS
==
1
:
input_stream_lists
=
[]
input_stream_lists
=
[]
for
input_stream_nr
in
range
(
NOF_INPUT_STREAMS
):
for
input_stream_nr
in
range
(
NOF_INPUT_STREAMS
):
input_stream_lists
.
append
(
interleave
([
input_lists
[
2
*
input_stream_nr
],
input_lists
[
2
*
input_stream_nr
+
1
]]
)
)
input_stream_lists
.
append
(
interleave
([
concat_
input_lists
[
2
*
input_stream_nr
],
concat_
input_lists
[
2
*
input_stream_nr
+
1
]]
)
)
elif
NOF_FOLDS
==
0
:
elif
NOF_FOLDS
==
0
:
input_stream_lists
=
input_lists
input_stream_lists
=
concat_
input_lists
# ====================
# ====================
# Write the HEX files
# Write the HEX files
...
@@ -146,6 +163,7 @@ def correlate(input_lists, accumulation_factor):
...
@@ -146,6 +163,7 @@ def correlate(input_lists, accumulation_factor):
"""
"""
# First transpose the lists into nof_channels*nof_inputs
# First transpose the lists into nof_channels*nof_inputs
inputs_per_channel
=
transpose
(
input_lists
)
inputs_per_channel
=
transpose
(
input_lists
)
# Feed each channel to the correlation function
# Feed each channel to the correlation function
vis_per_channel
=
[]
vis_per_channel
=
[]
for
inputs
in
inputs_per_channel
:
for
inputs
in
inputs_per_channel
:
...
@@ -279,7 +297,7 @@ correlator_snk_in_arr_int = complex_to_int(correlator_snk_in_arr_complex)
...
@@ -279,7 +297,7 @@ correlator_snk_in_arr_int = complex_to_int(correlator_snk_in_arr_complex)
gen_correlator_snk_in_arr_hex
(
correlator_snk_in_arr_int
)
gen_correlator_snk_in_arr_hex
(
correlator_snk_in_arr_int
)
# Calculate correlator output from input lists
# Calculate correlator output from input lists
correlator_src_out_arr_ref
=
correlate
(
correlator_snk_in_arr_
complex
,
INTEGRATION_PERIOD
)
correlator_src_out_arr_ref
=
correlate
(
correlator_snk_in_arr_
int
,
INTEGRATION_PERIOD
)
...
@@ -289,12 +307,49 @@ correlator_src_out_arr_ref = correlate(correlator_snk_in_arr_complex, INTEGRATIO
...
@@ -289,12 +307,49 @@ correlator_src_out_arr_ref = correlate(correlator_snk_in_arr_complex, INTEGRATIO
# Read test bench output file written by dp_stream_rec_play.vhd
# Read test bench output file written by dp_stream_rec_play.vhd
correlator_src_out_arr
=
rec_file_to_complex
(
REC_FILE
,
complex_width
=
CORRELATOR_OUTPUT_COMPLEX_WIDTH
)
correlator_src_out_arr
=
rec_file_to_complex
(
REC_FILE
,
complex_width
=
CORRELATOR_OUTPUT_COMPLEX_WIDTH
)
def
nozero
(
input_nr
):
"""
Returns a/b when b is non-zero. Otherwise returns almost zero.
"""
if
not
(
input_nr
==
0
):
return
input_nr
else
:
return
0.00000000000000000000000000000000000001
import
sys
def
compare_correlator_src_out_arr
(
vhdl_out
,
model_out
,
max_deviation_factor
):
"""
Compare the VHDL correlator
'
s output to the Python model output.
. A max_deviation_factor (0..1) is allowed in both the real and the imaginary
values -> 1% max = 0.01
. A too great deviation results in a False being returned.
"""
passed
=
True
channel_nr
=
0
for
vhdl_channel
,
model_channel
in
zip
(
vhdl_out
,
model_out
):
vis_nr
=
0
for
vhdl_visibility
,
model_visibility
in
zip
(
vhdl_channel
,
model_channel
):
diff_re
=
abs
(
model_visibility
.
real
-
vhdl_visibility
.
real
)
/
nozero
(
abs
(
model_visibility
.
real
))
diff_im
=
abs
(
model_visibility
.
imag
-
vhdl_visibility
.
imag
)
/
nozero
(
abs
(
model_visibility
.
imag
))
if
diff_re
>
max_deviation_factor
or
diff_im
>
max_deviation_factor
:
print
'
compare_correlator_src_out_arr: FAILED
'
print
'
. channel
'
,
channel_nr
,
'
visibility
'
,
vis_nr
print
'
. diff_re
'
,
diff_re
print
'
. model_visibility.real
'
,
model_visibility
.
real
print
'
. vhdl_visibility.real
'
,
vhdl_visibility
.
real
print
'
. diff_im
'
,
diff_im
print
'
. model_visibility.imag
'
,
model_visibility
.
imag
print
'
. vhdl_visibility.imag
'
,
vhdl_visibility
.
imag
sys
.
exit
()
vis_nr
+=
1
channel_nr
+=
1
print
'
corr out
'
,
correlator_src_out_arr
[
0
]
print
'
corr out
'
,
correlator_src_out_arr
[
0
]
print
'
corr ref
'
,
correlator_src_out_arr_ref
[
0
]
print
'
corr ref
'
,
correlator_src_out_arr_ref
[
0
]
compare_correlator_src_out_arr
(
correlator_src_out_arr
,
correlator_src_out_arr_ref
,
0.001
)
def
plot_phase_shifts
(
correlator_output
):
def
plot_phase_shifts
(
correlator_output
):
"""
"""
...
...
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