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
5c7a2182
Commit
5c7a2182
authored
9 years ago
by
Daniel van der Schuur
Browse files
Options
Downloads
Patches
Plain Diff
-Added command line args.
parent
9e7a56de
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/designs/apertif_unb1_fn_bf_emu/tb/python/tc_apertif_unb1_fn_bf_emu.py
+47
-36
47 additions, 36 deletions
...tif_unb1_fn_bf_emu/tb/python/tc_apertif_unb1_fn_bf_emu.py
with
47 additions
and
36 deletions
applications/apertif/designs/apertif_unb1_fn_bf_emu/tb/python/tc_apertif_unb1_fn_bf_emu.py
+
47
−
36
View file @
5c7a2182
...
...
@@ -30,9 +30,12 @@
# looped through by the block generator;
# . Each BG stream contains 2*64 = 128 timesamples;
# . This TC overwrites the default block gen RAM contents.
# . All 4*2=8 BG output signals will be the same.
# Usage:
# . Change CHANNELS as desired;
# . python tc_apertif_unb1_fn_bf_emu.py --unb 3 --fn 0:2
# . python tc_apertif_unb1_fn_bf_emu.py --unb 3 --fn 0 -r [channels] -n [phase shift]
# . Pass -s noplot to disable plotting.
# Example:
# . python tc_apertif_unb1_fn_bf_emu.py --unb 3 --fn 0 -r 3,5,7,34,60 -n 0
import
test_case
import
node_io
...
...
@@ -60,17 +63,22 @@ io = node_io.NodeIO(tc.nodeImages, tc.base_ip)
bg
=
pi_diag_block_gen
.
PiDiagBlockGen
(
tc
,
io
,
NOF_STREAMS
,
NOF_RAM_WORDS_PER_STREAM
)
###############################################################################
# Define which channels are present in the BG output signal
# . A sub-signal is created for each channel number (a.k.a. bin number) defined
# in CHANNELS.
# . All sub-signals are added yielding our composite signal
# Assign the user passed arguments -r and -n
# . CHANNELS (-r):
# . Define which channels are present in the BG output signal
# . A sub-signal is created for each channel number (a.k.a. bin number) defined
# in CHANNELS.
# . All sub-signals are added yielding our composite signal
# . PHASE_SHIFT_DEG (-n):
# . Pass a phase shift in degrees that is applied to each channel signal
###############################################################################
CHANNELS
=
tc
.
gpNumbers
# -r argument
PHASE_SHIFT_DEG
=
tc
.
number
# -n argument
NOPLOT
=
tc
.
gpString
==
'
noplot
'
# True if -s noplot is passed
###############################################################################
# Create the channel sub-signals and the resulting composite signal
###############################################################################
# Define your list of channel numbers 0..63) to put in the signal here
#CHANNELS = [1]
#CHANNELS = [60]
#CHANNELS = [1,60]
CHANNELS
=
[
10
]
#CHANNELS = [1,5,12,17,21,25,28,34,41,47,54,55,60]
# Sample spacing
T
=
1.0
/
NOF_WORDS_PER_SIGNAL
...
...
@@ -80,10 +88,12 @@ x = np.linspace(0.0, NOF_WORDS_PER_SIGNAL*T, NOF_WORDS_PER_SIGNAL)
channel_signals
=
[]
NOF_CHANNELS
=
len
(
CHANNELS
)
for
bin_nr
in
CHANNELS
:
phase_shift_rad
=
phase_shift_rad
=
math
.
radians
(
PHASE_SHIFT_DEG
)
# Make sure the summed amplitude of all channels does not exceed AMPL_MAX
ampl
=
AMPL_MAX
/
NOF_CHANNELS
# Create the signal in this channel and append to list
channel_signal
=
ampl
*
np
.
exp
(
bin_nr
*
1.j
*
(
2.0
*
np
.
pi
*
x
)
)
channel_signal
=
ampl
*
np
.
exp
(
bin_nr
*
1.j
*
(
2.0
*
np
.
pi
*
x
+
(
phase_shift_rad
/
bin_nr
)
)
)
channel_signals
.
append
(
channel_signal
)
# Adding all channel sub-signals yields our composite signal
...
...
@@ -93,29 +103,30 @@ composite_signal=np.sum(channel_signals, axis=0)
# Plot our composite signal + FFT
# . This step is optional and not required to overwrite the RAM contents.
###############################################################################
# Convert the float values to 8-bit complex
s_bits
=
[]
for
fword
in
composite_signal
:
re_signed
=
to_signed
(
fword
.
real
,
COMPLEX_WIDTH
)
im_signed
=
to_signed
(
fword
.
imag
,
COMPLEX_WIDTH
)
s_bits
.
append
(
complex
(
re_signed
,
im_signed
)
)
# Define our axes and plot the signal
s
=
np
.
array
(
s_bits
)
t
=
range
(
NOF_WORDS_PER_SIGNAL
)
plt
.
plot
(
t
,
s
.
real
,
'
b-
'
,
t
,
s
.
imag
,
'
r--
'
)
plt
.
legend
((
'
real
'
,
'
imaginary
'
))
plt
.
show
()
# Calculate and plot the FFT
yf
=
fft
(
s
)
xf
=
fftfreq
(
NOF_WORDS_PER_SIGNAL
,
T
)
xf
=
range
(
NOF_WORDS_PER_SIGNAL
)
xf
=
fftshift
(
xf
)
yplot
=
fftshift
(
yf
)
plt
.
bar
(
xf
,
1.0
/
NOF_WORDS_PER_SIGNAL
*
np
.
abs
(
yplot
))
plt
.
grid
()
plt
.
show
()
if
NOPLOT
==
False
:
# Convert the float values to 8-bit complex
s_bits
=
[]
for
fword
in
composite_signal
:
re_signed
=
to_signed
(
fword
.
real
,
COMPLEX_WIDTH
)
im_signed
=
to_signed
(
fword
.
imag
,
COMPLEX_WIDTH
)
s_bits
.
append
(
complex
(
re_signed
,
im_signed
)
)
# Define our axes and plot the signal
s
=
np
.
array
(
s_bits
)
t
=
range
(
NOF_WORDS_PER_SIGNAL
)
plt
.
plot
(
t
,
s
.
real
,
'
b-
'
,
t
,
s
.
imag
,
'
r--
'
)
plt
.
legend
((
'
real
'
,
'
imaginary
'
))
plt
.
show
()
# Calculate and plot the FFT
yf
=
fft
(
s
)
xf
=
fftfreq
(
NOF_WORDS_PER_SIGNAL
,
T
)
xf
=
range
(
NOF_WORDS_PER_SIGNAL
)
xf
=
fftshift
(
xf
)
yplot
=
fftshift
(
yf
)
plt
.
bar
(
xf
,
1.0
/
NOF_WORDS_PER_SIGNAL
*
np
.
abs
(
yplot
))
plt
.
grid
()
plt
.
show
()
###############################################################################
# Prepare the data to be written to RAM
...
...
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