Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
wr2rf-vme
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
5
Issues
5
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
wr2rf-vme
Commits
7efea296
Commit
7efea296
authored
Apr 24, 2020
by
Tristan Gingold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tb_vtu: add a test for lowfreq mode.
parent
c1ebd73b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
74 additions
and
13 deletions
+74
-13
tb_vtu.vhd
hdl/testbench/vtu/tb_vtu.vhd
+74
-13
No files found.
hdl/testbench/vtu/tb_vtu.vhd
View file @
7efea296
...
...
@@ -51,7 +51,14 @@ architecture arch of tb_vtu is
-- Command to be sent to the VTU observer: number of expected pulses.
type
observer_type
is
record
-- Number of expected pulses.
count
:
natural
;
-- True if can go beyond the number of pulses (infinite window).
infinite
:
boolean
;
-- If True, expect square waves. Check half-period.
square
:
boolean
;
end
record
;
signal
observer_cmd
:
observer_type
;
...
...
@@ -59,6 +66,7 @@ architecture arch of tb_vtu is
-- VTU observer state.
type
obs_state_type
is
(
IDLE
,
WORKING
,
OBS_DONE
,
OBS_ERR
);
signal
observer_state
:
obs_state_type
:
=
IDLE
;
signal
observer_count
:
natural
;
signal
observer_period
:
time
;
begin
-- System clock, 62.5 Mhz
...
...
@@ -101,7 +109,6 @@ begin
-- VTU observer.
process
(
trig_p
,
observer_cmd
)
variable
count
:
natural
;
variable
last_ts
:
time
;
variable
this_period
:
time
;
begin
...
...
@@ -110,38 +117,41 @@ begin
case
observer_state
is
when
IDLE
|
OBS_DONE
|
OBS_ERR
=>
observer_state
<=
WORKING
;
count
:
=
0
;
observer_count
<=
1
;
last_ts
:
=
now
;
when
WORKING
=>
report
"VTU observer command overrides the previous one"
severity
error
;
end
case
;
end
if
;
if
trig_p
'event
and
trig_p
=
'1'
then
report
"Trigger:"
&
Natural
'image
(
count
);
if
trig_p
'event
and
(
observer_cmd
.
square
or
trig_p
=
'1'
)
then
report
"Trigger:"
&
Natural
'image
(
observer_
count
);
case
observer_state
is
when
IDLE
=>
report
"VTU observer: trigger before command"
severity
error
;
when
WORKING
=>
when
WORKING
|
OBS_DONE
=>
this_period
:
=
now
-
last_ts
;
if
count
=
1
then
if
observer_count
=
2
then
observer_period
<=
this_period
;
elsif
count
>
1
then
elsif
observer_count
>
2
then
if
this_period
/=
observer_period
then
report
"VTU observer: irregular period"
severity
error
;
end
if
;
end
if
;
last_ts
:
=
now
;
count
:
=
count
+
1
;
if
count
=
observer_cmd
.
count
then
observer_count
<=
observer_
count
+
1
;
if
observer_
count
=
observer_cmd
.
count
then
observer_state
<=
OBS_DONE
;
elsif
observer_count
>
observer_cmd
.
count
and
not
observer_cmd
.
infinite
then
report
"VTU observer: too many pulses"
severity
error
;
end
if
;
when
OBS_
DONE
|
OBS_
ERR
=>
when
OBS_ERR
=>
null
;
end
case
;
end
if
;
end
process
;
-- Test process.
process
-- Send a pulse on the start signal and wait until it is propagated to the VTU.
procedure
start_pulse
is
...
...
@@ -162,7 +172,7 @@ begin
sync
<=
'1'
;
wait
for
10
ns
;
sync
<=
'0'
;
-- Wait until the VTU get the sync pulse.
for
i
in
1
to
3
loop
wait
until
rising_edge
(
clk_vtu
);
...
...
@@ -223,7 +233,7 @@ begin
assert
val
=
x"0000"
severity
error
;
-- Expect 64 syncs.
observer_cmd
<=
(
count
=>
64
);
observer_cmd
<=
(
count
=>
64
,
infinite
=>
False
,
square
=>
False
);
-- Start pulse.
start_pulse
;
...
...
@@ -276,14 +286,65 @@ begin
assert
val
(
TRIGUNIT_REGS_STATUS_STARTREADY_OFFSET
)
=
'1'
severity
error
;
assert
val
(
TRIGUNIT_REGS_STATUS_RUNNING_OFFSET
)
=
'0'
severity
error
;
-- Second test: check that missing valid parameters is reported.
-------------------------------------------------------------------------------------------------
-- Test 2: check that missing valid parameters is reported.
-- (A cycle has been finished, the start signal has to be ignored because
-- parameters aren't set.)
report
"test 2 - start"
;
start_pulse
;
read_status
(
val
);
assert
val
(
TRIGUNIT_REGS_STATUS_MISSVALID_OFFSET
)
=
'1'
severity
error
;
-------------------------------------------------------------------------------------------------
-- Test 3: Program the vtu
-- Delay between start and the first pulse.
write64be_pl
(
clk_sys
,
wb_in
,
wb_out
,
ADDR_TRIGUNIT_REGS_BVALUEOFFLINE
,
x"0000_0000_0000_0010"
);
-- Delay between the pulses.
write64be_pl
(
clk_sys
,
wb_in
,
wb_out
,
ADDR_TRIGUNIT_REGS_HTVALUEOFFLINE
,
x"0000_0000_0000_0011"
);
-- Number of pulses (unused).
write64be_pl
(
clk_sys
,
wb_in
,
wb_out
,
ADDR_TRIGUNIT_REGS_WVALUEOFFLINE
,
x"0000_0000_0000_0014"
);
-- Lowfreq generation, enable.
write16_pl
(
clk_sys
,
wb_in
,
wb_out
,
ADDR_TRIGUNIT_REGS_CONFIGOFFLINE
,
x"0041"
);
-- Expect 64 syncs.
observer_cmd
<=
(
count
=>
20
,
infinite
=>
true
,
square
=>
true
);
report
"test 3 - start"
;
start_pulse
;
read_status
(
val
);
assert
val
(
TRIGUNIT_REGS_STATUS_MISSVALID_OFFSET
)
=
'0'
severity
error
;
-- Sync pulse.
sync_pulse
;
-- Check ...
read_status
(
val
);
assert
val
(
TRIGUNIT_REGS_STATUS_STARTREADY_OFFSET
)
=
'1'
severity
error
;
assert
val
(
TRIGUNIT_REGS_STATUS_RUNNING_OFFSET
)
=
'1'
severity
error
;
-- Wait until end of generation.
wait
on
observer_state
;
-- Check observer status.
assert
observer_state
=
OBS_DONE
severity
error
;
assert
observer_period
=
17
*
5
ns
;
-- Stop counter. Synchronize to
wait
until
rising_edge
(
clk_vtu
);
stop
<=
'1'
;
wait
for
40
ns
;
stop
<=
'0'
;
-- Wait a little bit (2 full periods)
wait
for
2
*
2
*
observer_period
;
-- We should have stopped after 20 periods. There are some extra periods because of synchronizers.
assert
observer_count
=
23
severity
error
;
report
"end of tests"
;
wait
;
end
process
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment