Skip to content
GitLab
Explore
Sign in
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
1e461c6b
Commit
1e461c6b
authored
10 years ago
by
Daniel van der Schuur
Browse files
Options
Downloads
Patches
Plain Diff
-Fiex phase shifting.
parent
5216a8ba
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
applications/apertif/apertif_unb1_correlator/src/python/gen_hex_files_composite_signals.py
+28
-25
28 additions, 25 deletions
..._correlator/src/python/gen_hex_files_composite_signals.py
with
28 additions
and
25 deletions
applications/apertif/apertif_unb1_correlator/src/python/gen_hex_files_composite_signals.py
+
28
−
25
View file @
1e461c6b
...
@@ -40,7 +40,7 @@ NOF_INPUT_SIGNALS = 24
...
@@ -40,7 +40,7 @@ NOF_INPUT_SIGNALS = 24
COMPLEX_WIDTH
=
8
COMPLEX_WIDTH
=
8
NOF_WORDS_PER_BLOCK
=
64
NOF_WORDS_PER_BLOCK
=
64
PATH
=
"
..
/hex
"
PATH
=
os
.
environ
[
'
RADIOHDL
'
]
+
'
/applications/apertif/apertif_unb1_correlator/src
/hex
'
FILENAME
=
"
composite_signals
"
FILENAME
=
"
composite_signals
"
###############################################################################
###############################################################################
...
@@ -57,54 +57,57 @@ x = np.linspace(0.0, N*T, N)
...
@@ -57,54 +57,57 @@ x = np.linspace(0.0, N*T, N)
# 8 bit signed -> WAAROM LIJKT AMPL_MAX DAN TOCH 63 te zijn IPV 127??
# 8 bit signed -> WAAROM LIJKT AMPL_MAX DAN TOCH 63 te zijn IPV 127??
# . Boven ~70 wordt de waarde aan de FFT output jusit lager...
# . Boven ~70 wordt de waarde aan de FFT output jusit lager...
AMPL_MAX
=
63
# 7 bits+sign #HUH?! 100->62; 63->118; 80->105; 70->123; 72->121; 75->110
AMPL_MAX
=
63
# 7 bits+sign #HUH?! 100->62; 63->118; 80->105; 70->123; 72->121; 75->110
NOF_CHANNELS
=
1
# Note: starting from 0 in -31..31.
CHANNELS
=
[
19
]
NOF_CHANNELS
=
len
(
CHANNELS
)
input_signals
=
[]
input_signals
=
[]
for
input_signal_nr
in
range
(
NOF_INPUT_SIGNALS
):
for
input_signal_nr
in
range
(
NOF_INPUT_SIGNALS
):
phase_shift_deg
=
input_signal_nr
phase_shift_deg
=
input_signal_nr
channel_signals
=
[]
channel_signals
=
[]
for
bin_nr
in
range
(
NOF_
CHANNELS
)
:
for
bin_nr
in
CHANNELS
:
phase_shift_rad
=
math
.
radians
(
phase_shift_deg
)
phase_shift_rad
=
math
.
radians
(
phase_shift_deg
)
ampl
=
AMPL_MAX
/
NOF_CHANNELS
ampl
=
AMPL_MAX
/
NOF_CHANNELS
signal
=
ampl
*
np
.
exp
(
(
bin_nr
+
1
)
*
1.j
*
(
2.0
*
np
.
pi
*
x
+
phase_shift_rad
)
)
signal
=
ampl
*
np
.
exp
(
(
bin_nr
)
*
1.j
*
(
2.0
*
np
.
pi
*
x
+
(
phase_shift_rad
/
bin_nr
))
)
channel_signals
.
append
(
signal
)
channel_signals
.
append
(
signal
)
composite_signal
=
numpy
.
sum
(
channel_signals
,
axis
=
0
)
composite_signal
=
numpy
.
sum
(
channel_signals
,
axis
=
0
)
input_signals
.
append
(
composite_signal
)
input_signals
.
append
(
composite_signal
)
s
=
input_signals
[
23
]
s
=
input_signals
[
1
]
###############################################################################
###############################################################################
# Convert the float values to n-bits
# Convert the float values to n-bits
###############################################################################
###############################################################################
#
s_bits = []
s_bits
=
[]
#
for fword in s:
for
fword
in
s
:
#
re_signed = to_signed(fword.real, COMPLEX_WIDTH)
re_signed
=
to_signed
(
fword
.
real
,
COMPLEX_WIDTH
)
#
im_signed = to_signed(fword.imag, COMPLEX_WIDTH)
im_signed
=
to_signed
(
fword
.
imag
,
COMPLEX_WIDTH
)
#
#
s_bits.append( complex(re_signed, im_signed) )
s_bits
.
append
(
complex
(
re_signed
,
im_signed
)
)
#
#
s = numpy.array(s_bits)
s
=
numpy
.
array
(
s_bits
)
#
print s
print
s
###############################################################################
###############################################################################
# Plot the signal
# Plot the signal
###############################################################################
###############################################################################
#
plt.plot(t, s.real, 'b-', t, s.imag, 'r--')
plt
.
plot
(
t
,
s
.
real
,
'
b-
'
,
t
,
s
.
imag
,
'
r--
'
)
#
plt.legend(('real', 'imaginary'))
plt
.
legend
((
'
real
'
,
'
imaginary
'
))
#
plt.show()
plt
.
show
()
###############################################################################
###############################################################################
# Plot FFT
# Plot FFT
###############################################################################
###############################################################################
#
yf = fft(s)
yf
=
fft
(
s
)
#
#
xf = fftfreq(N, T)
xf
=
fftfreq
(
N
,
T
)
#
xf = fftshift(xf)
xf
=
fftshift
(
xf
)
#
yplot = fftshift(yf)
yplot
=
fftshift
(
yf
)
#
plt.bar(xf, 1.0/N * np.abs(yplot))
plt
.
bar
(
xf
,
1.0
/
N
*
np
.
abs
(
yplot
))
#
plt.grid()
plt
.
grid
()
#
plt.show()
plt
.
show
()
###############################################################################
###############################################################################
# Convert complex floats to concatenated integers
# Convert complex floats to concatenated integers
...
...
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