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
8008ef14
Commit
8008ef14
authored
9 years ago
by
Reinier van der Walle
Browse files
Options
Downloads
Patches
Plain Diff
initial commit
parent
28989cf2
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/stagiair/libraries/wave_gen/tb/python/tc_wave_gen.py
+139
-0
139 additions, 0 deletions
...ions/stagiair/libraries/wave_gen/tb/python/tc_wave_gen.py
with
139 additions
and
0 deletions
applications/stagiair/libraries/wave_gen/tb/python/tc_wave_gen.py
0 → 100644
+
139
−
0
View file @
8008ef14
#! /usr/bin/env python
###############################################################################
#
# Copyright (C) 2012
# ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###############################################################################
"""
Test case for the bf_unit entity.
Description:
This testcase is used in conjunction with the tb_bf_unit.vhd file.
Generics for the VHDL testbench are passed to modelsim to configure the
current simulation.
To observe the VHDL signals in the wave window modelsim needs to be
started manually and then c_start_modelsim must be set to 0 and the generics
also must be set manually.
NOTE: Use c_write_bg, c_write_bf_weights and c_write_bf_ss_wide to en- or disable
the time-consuming writes to the mm-interface. WHen disabled, be sure to
have the according .hex files in place. The .hex files can be generated
with the bf_unit.py script.
BEWARE: If the hex files change due to different script settings, then it is
necessary to run the script again to ensure that Modelsim starts with the
latest hex files.
Usage:
> python tc_bf_unit.py --unb 0 --fn 0 --sim
"""
###############################################################################
# System imports
import
test_case
import
node_io
import
sys
import
pi_diag_data_buffer
import
pi_stagiair_wave_gen
from
tools
import
*
from
common
import
*
import
csv
import
cmath
###############################################################################
# Debug control
c_debug_print
=
False
# Create a test case object
tc
=
test_case
.
Testcase
(
'
TB -
'
,
''
)
tc
.
append_log
(
3
,
'
>>>
'
)
tc
.
append_log
(
1
,
'
>>> Title : Test bench for wave_gen
'
)
tc
.
append_log
(
3
,
'
>>>
'
)
tc
.
append_log
(
3
,
''
)
tc
.
set_result
(
'
PASSED
'
)
###############################################################################
c_size
=
2048
c_filename
=
'
values.csv
'
# Create access object for nodes
io
=
node_io
.
NodeIO
(
tc
.
nodeImages
,
tc
.
base_ip
)
# Create databuffer instances
db
=
pi_diag_data_buffer
.
PiDiagDataBuffer
(
tc
,
io
,
instanceName
=
''
,
nofStreams
=
1
,
ramSizePerStream
=
c_size
)
wg
=
pi_stagiair_wave_gen
.
PiWaveGen
(
tc
,
io
,
nof_inst
=
1
)
def
listToCsv
(
fileName
=
'
default.csv
'
,
overwrite
=
False
,
value_list
=
[]):
header
=
None
if
overwrite
:
ofile
=
open
(
fileName
,
"
w
"
)
header
=
[
'
real
'
,
'
imag
'
,
'
abs
'
,
'
phase
'
]
else
:
ofile
=
open
(
fileName
,
"
a
"
)
writer
=
csv
.
writer
(
ofile
,
delimiter
=
'
,
'
,
quoting
=
csv
.
QUOTE_NONE
)
if
not
header
==
None
:
writer
.
writerow
(
header
)
for
value
in
value_list
:
if
type
(
value
)
==
complex
:
row_list
=
[
value
.
real
,
value
.
imag
,
abs
(
value
),
cmath
.
phase
(
value
)]
else
:
row_list
=
[
value
]
writer
.
writerow
(
row_list
)
if
__name__
==
"
__main__
"
:
wg
.
write
(
registers
=
[(
'
gain_sel
'
,
16
)])
wg
.
write
(
registers
=
[(
'
wave_sel
'
,
0
)])
wg
.
write
(
registers
=
[(
'
enable
'
,
1
)])
do_until_ge
(
db
.
read_nof_words
,
ms_retry
=
1000
,
val
=
c_size
,
s_timeout
=
3600
)
wg
.
write
(
registers
=
[(
'
enable
'
,
0
)])
val_list
=
flatten
(
db
.
read_data_buffer
(
streamNr
=
0
,
n
=
c_size
,
radix
=
'
dec
'
,
width
=
8
,
nofColumns
=
1
))
listToCsv
(
fileName
=
c_filename
,
overwrite
=
True
,
value_list
=
val_list
)
for
i
in
range
(
1
,
5
):
wg
.
write
(
registers
=
[(
'
wave_sel
'
,
i
)])
wg
.
write
(
registers
=
[(
'
enable
'
,
1
)])
do_until_ge
(
db
.
read_nof_words
,
ms_retry
=
1000
,
val
=
c_size
,
s_timeout
=
3600
)
wg
.
write
(
registers
=
[(
'
enable
'
,
0
)])
val_list
=
flatten
(
db
.
read_data_buffer
(
streamNr
=
0
,
n
=
c_size
,
radix
=
'
dec
'
,
width
=
8
,
nofColumns
=
1
))
listToCsv
(
fileName
=
c_filename
,
overwrite
=
False
,
value_list
=
val_list
)
###############################################################################
# End
tc
.
set_section_id
(
''
)
tc
.
append_log
(
3
,
''
)
tc
.
append_log
(
3
,
'
>>>
'
)
tc
.
append_log
(
0
,
'
>>> Test bench result: %s
'
%
tc
.
get_result
())
tc
.
append_log
(
3
,
'
>>>
'
)
sys
.
exit
(
tc
.
get_result
())
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