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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RTSD
HDL
Commits
ddad0120
Commit
ddad0120
authored
2 years ago
by
Eric Kooistra
Browse files
Options
Downloads
Patches
Plain Diff
Verify high word of count and overflow.
parent
1626fb80
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!285
Resolve L2SDP-840
Pipeline
#37487
passed
2 years ago
Stage: simulation
Stage: synthesis
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
libraries/base/dp/tb/vhdl/tb_dp_strobe_total_count.vhd
+43
-21
43 additions, 21 deletions
libraries/base/dp/tb/vhdl/tb_dp_strobe_total_count.vhd
libraries/base/dp/tb/vhdl/tb_tb_dp_strobe_total_count.vhd
+19
-5
19 additions, 5 deletions
libraries/base/dp/tb/vhdl/tb_tb_dp_strobe_total_count.vhd
with
62 additions
and
26 deletions
libraries/base/dp/tb/vhdl/tb_dp_strobe_total_count.vhd
+
43
−
21
View file @
ddad0120
...
@@ -22,6 +22,11 @@
...
@@ -22,6 +22,11 @@
-- Author: E. Kooistra
-- Author: E. Kooistra
-- Purpose: Test bench for dp_strobe_total_count.vhd
-- Purpose: Test bench for dp_strobe_total_count.vhd
-- Description:
-- Description:
-- * maximum g_count_w = 31 to fit in largest NATURAL
-- * Use g_mm_w < c_word_w = 32 to simulate large counts in feasible time.
-- * Use g_nof_sync in combination with g_mm_w and g_count_w to achieve
-- . a count > 2**g_mm_w that uses the high part of an MM word
-- . a count > 2**(g_mm_w*2) that will clip at 2**g_mm_w - 1
-- Usage:
-- Usage:
-- . as 5
-- . as 5
-- . run -all
-- . run -all
...
@@ -38,9 +43,12 @@ USE work.dp_stream_pkg.ALL;
...
@@ -38,9 +43,12 @@ USE work.dp_stream_pkg.ALL;
ENTITY
tb_dp_strobe_total_count
IS
ENTITY
tb_dp_strobe_total_count
IS
GENERIC
(
GENERIC
(
g_count_w
:
NATURAL
:
=
16
;
g_mm_w
:
NATURAL
:
=
8
;
g_gap_size
:
NATURAL
:
=
0
;
g_count_w
:
NATURAL
:
=
7
;
g_clip
:
BOOLEAN
:
=
TRUE
g_nof_blocks_per_sync
:
NATURAL
:
=
10
;
g_nof_valid_per_blk
:
NATURAL
:
=
10
;
g_nof_sync
:
NATURAL
:
=
10
;
g_gap_size
:
NATURAL
:
=
3
);
);
END
tb_dp_strobe_total_count
;
END
tb_dp_strobe_total_count
;
...
@@ -53,22 +61,24 @@ ARCHITECTURE tb OF tb_dp_strobe_total_count IS
...
@@ -53,22 +61,24 @@ ARCHITECTURE tb OF tb_dp_strobe_total_count IS
CONSTANT
c_dp_clk_period
:
TIME
:
=
5
ns
;
CONSTANT
c_dp_clk_period
:
TIME
:
=
5
ns
;
CONSTANT
c_mm_clk_period
:
TIME
:
=
10
ns
;
CONSTANT
c_mm_clk_period
:
TIME
:
=
10
ns
;
CONSTANT
c_nof_blocks_per_sync
:
NATURAL
:
=
5
;
CONSTANT
c_skip_nof_sync
:
NATURAL
:
=
3
;
CONSTANT
c_nof_data_per_blk
:
NATURAL
:
=
9
;
CONSTANT
c_tb_nof_sync
:
NATURAL
:
=
c_skip_nof_sync
+
g_nof_sync
;
CONSTANT
c_nof_sync
:
NATURAL
:
=
5
;
CONSTANT
c_clip
:
BOOLEAN
:
=
TRUE
;
CONSTANT
c_nof_blk
:
NATURAL
:
=
c_nof_blocks_per_sync
*
(
c_nof_sync
-
1
);
-- dut
-- dut
CONSTANT
c_nof_counts_max
:
NATURAL
:
=
15
;
CONSTANT
c_nof_counts_max
:
NATURAL
:
=
15
;
CONSTANT
c_nof_counts
:
NATURAL
:
=
3
;
-- count stimuli.sync, sop, valid
CONSTANT
c_nof_counts
:
NATURAL
:
=
3
;
-- count stimuli.sync, sop, valid
CONSTANT
c_count_max
:
NATURAL
:
=
2
**
g_count_w
-
1
;
CONSTANT
c_mm_addr_clear
:
NATURAL
:
=
c_nof_counts_max
*
2
;
CONSTANT
c_mm_addr_clear
:
NATURAL
:
=
c_nof_counts_max
*
2
;
-- c_nof_sync - 1 because stimuli_sosi.sync is used as ref_sync, and ref_sync is used
-- c_tb_nof_sync - c_skip_nof_sync because first sync intervals are skipped
-- to hold the count.
-- by using clear, and -1, because stimuli_sosi.sync is used as ref_sync,
CONSTANT
c_exp_nof_sync
:
NATURAL
:
=
c_nof_sync
-
1
;
-- and ref_sync is used to hold the counts.
CONSTANT
c_exp_nof_sop
:
NATURAL
:
=
c_nof_blk
;
CONSTANT
c_exp_nof_sync
:
NATURAL
:
=
c_tb_nof_sync
-
c_skip_nof_sync
-
1
;
CONSTANT
c_exp_nof_valid
:
NATURAL
:
=
c_nof_blk
*
c_nof_data_per_blk
;
CONSTANT
c_nof_blk
:
NATURAL
:
=
g_nof_blocks_per_sync
*
c_exp_nof_sync
;
CONSTANT
c_exp_nof_sop
:
NATURAL
:
=
sel_a_b
(
c_nof_blk
<
c_count_max
,
c_nof_blk
,
c_count_max
);
CONSTANT
c_nof_valid
:
NATURAL
:
=
c_nof_blk
*
g_nof_valid_per_blk
;
CONSTANT
c_exp_nof_valid
:
NATURAL
:
=
sel_a_b
(
c_nof_valid
<
c_count_max
,
c_nof_valid
,
c_count_max
);
SIGNAL
dp_clk
:
STD_LOGIC
:
=
'1'
;
SIGNAL
dp_clk
:
STD_LOGIC
:
=
'1'
;
SIGNAL
mm_clk
:
STD_LOGIC
:
=
'1'
;
SIGNAL
mm_clk
:
STD_LOGIC
:
=
'1'
;
...
@@ -104,9 +114,9 @@ BEGIN
...
@@ -104,9 +114,9 @@ BEGIN
-- Generate snk_in with data frames
-- Generate snk_in with data frames
u_stimuli
:
ENTITY
work
.
dp_stream_stimuli
u_stimuli
:
ENTITY
work
.
dp_stream_stimuli
GENERIC
MAP
(
GENERIC
MAP
(
g_sync_period
=>
c
_nof_blocks_per_sync
,
g_sync_period
=>
g
_nof_blocks_per_sync
,
g_nof_repeat
=>
c
_nof_blocks_per_sync
*
c_nof_sync
,
g_nof_repeat
=>
g
_nof_blocks_per_sync
*
c_
tb_
nof_sync
,
g_pkt_len
=>
c
_nof_
data
_per_blk
,
g_pkt_len
=>
g
_nof_
valid
_per_blk
,
g_pkt_gap
=>
g_gap_size
g_pkt_gap
=>
g_gap_size
)
)
PORT
MAP
(
PORT
MAP
(
...
@@ -129,10 +139,11 @@ BEGIN
...
@@ -129,10 +139,11 @@ BEGIN
------------------------------------------------------------------------------
------------------------------------------------------------------------------
u_dut
:
ENTITY
work
.
dp_strobe_total_count
u_dut
:
ENTITY
work
.
dp_strobe_total_count
GENERIC
MAP
(
GENERIC
MAP
(
g_mm_w
=>
g_mm_w
,
g_nof_counts_max
=>
c_nof_counts_max
,
g_nof_counts_max
=>
c_nof_counts_max
,
g_nof_counts
=>
c_nof_counts
,
g_nof_counts
=>
c_nof_counts
,
g_count_w
=>
g_count_w
,
g_count_w
=>
g_count_w
,
g_clip
=>
g
_clip
g_clip
=>
c
_clip
)
)
PORT
MAP
(
PORT
MAP
(
dp_rst
=>
rst
,
dp_rst
=>
rst
,
...
@@ -153,10 +164,15 @@ BEGIN
...
@@ -153,10 +164,15 @@ BEGIN
------------------------------------------------------------------------------
------------------------------------------------------------------------------
p_mm
:
PROCESS
p_mm
:
PROCESS
VARIABLE
v_rd_data
:
STD_LOGIC_VECTOR
(
c_word
_w
-1
DOWNTO
0
);
VARIABLE
v_rd_data
:
STD_LOGIC_VECTOR
(
g_mm
_w
-1
DOWNTO
0
);
VARIABLE
v_rd_count
:
NATURAL
;
VARIABLE
v_rd_count
:
NATURAL
;
BEGIN
BEGIN
proc_common_wait_until_low
(
mm_clk
,
rst
);
-- Wait until strobes have started, skip first sync intervals
FOR
I
IN
0
TO
c_skip_nof_sync
-1
LOOP
proc_common_wait_until_lo_hi
(
dp_clk
,
stimuli_sosi
.
sync
);
END
LOOP
;
proc_common_wait_some_cycles
(
dp_clk
,
1
);
-- Clear to restart counting at next sync interval
proc_mem_mm_bus_wr
(
c_mm_addr_clear
,
1
,
mm_clk
,
reg_mosi
);
proc_mem_mm_bus_wr
(
c_mm_addr_clear
,
1
,
mm_clk
,
reg_mosi
);
proc_common_wait_until_lo_hi
(
dp_clk
,
stimuli_end
);
proc_common_wait_until_lo_hi
(
dp_clk
,
stimuli_end
);
...
@@ -164,10 +180,16 @@ BEGIN
...
@@ -164,10 +180,16 @@ BEGIN
proc_common_wait_some_cycles
(
mm_clk
,
1
);
proc_common_wait_some_cycles
(
mm_clk
,
1
);
FOR
I
IN
0
TO
c_nof_counts
-1
LOOP
FOR
I
IN
0
TO
c_nof_counts
-1
LOOP
-- read low part
proc_mem_mm_bus_rd
(
I
*
2
,
mm_clk
,
reg_miso
,
reg_mosi
);
proc_mem_mm_bus_rd
(
I
*
2
,
mm_clk
,
reg_miso
,
reg_mosi
);
proc_mem_mm_bus_rd_latency
(
1
,
mm_clk
);
proc_mem_mm_bus_rd_latency
(
1
,
mm_clk
);
v_rd_data
:
=
reg_miso
.
rddata
(
c_word
_w
-1
DOWNTO
0
);
v_rd_data
:
=
reg_miso
.
rddata
(
g_mm
_w
-1
DOWNTO
0
);
v_rd_count
:
=
TO_UINT
(
v_rd_data
);
v_rd_count
:
=
TO_UINT
(
v_rd_data
);
-- read and add high part
proc_mem_mm_bus_rd
(
I
*
2
+
1
,
mm_clk
,
reg_miso
,
reg_mosi
);
proc_mem_mm_bus_rd_latency
(
1
,
mm_clk
);
v_rd_data
:
=
reg_miso
.
rddata
(
g_mm_w
-1
DOWNTO
0
);
v_rd_count
:
=
v_rd_count
+
TO_UINT
(
v_rd_data
)
*
2
**
g_mm_w
;
rd_count_arr
(
I
)
<=
v_rd_count
;
rd_count_arr
(
I
)
<=
v_rd_count
;
ASSERT
exp_count_arr
(
I
)
=
v_rd_count
REPORT
"Wrong total block count("
&
NATURAL
'IMAGE
(
I
)
&
")"
SEVERITY
ERROR
;
ASSERT
exp_count_arr
(
I
)
=
v_rd_count
REPORT
"Wrong total block count("
&
NATURAL
'IMAGE
(
I
)
&
")"
SEVERITY
ERROR
;
END
LOOP
;
END
LOOP
;
...
...
This diff is collapsed.
Click to expand it.
libraries/base/dp/tb/vhdl/tb_tb_dp_strobe_total_count.vhd
+
19
−
5
View file @
ddad0120
...
@@ -37,11 +37,25 @@ ARCHITECTURE tb OF tb_tb_dp_strobe_total_count IS
...
@@ -37,11 +37,25 @@ ARCHITECTURE tb OF tb_tb_dp_strobe_total_count IS
SIGNAL
tb_end
:
STD_LOGIC
:
=
'0'
;
-- declare tb_end to avoid 'No objects found' error on 'when -label tb_end'
SIGNAL
tb_end
:
STD_LOGIC
:
=
'0'
;
-- declare tb_end to avoid 'No objects found' error on 'when -label tb_end'
BEGIN
BEGIN
--g_mm_w : NATURAL := c_word_w;
--g_count_w : NATURAL := 16;
--g_count_w : NATURAL := 16;
--g_nof_blocks_per_sync : NATURAL := 10;
--g_nof_valid_per_blk : NATURAL := 10;
--g_nof_sync : NATURAL := 10;
--g_gap_size : NATURAL := 0;
--g_gap_size : NATURAL := 0;
--g_clip : BOOLEAN := TRUE
u_clip_word_gap
:
ENTITY
work
.
tb_dp_strobe_total_count
GENERIC
MAP
(
8
,
3
,
TRUE
);
-- Use g_nof_blocks_per_sync * g_nof_valid_per_blk = 100 valid per sync and
u_clip_word_no_gap
:
ENTITY
work
.
tb_dp_strobe_total_count
GENERIC
MAP
(
8
,
0
,
TRUE
);
-- use g_nof_sync = 10, so maximum expected valid count is 900.
-- Maximum expected sop count is 90
-- Maximum expected sync count is 9
-- Default usage
u_mm32b_cnt16b_no_gap
:
ENTITY
work
.
tb_dp_strobe_total_count
GENERIC
MAP
(
32
,
16
,
10
,
10
,
10
,
0
);
u_mm32b_cnt16b_gap
:
ENTITY
work
.
tb_dp_strobe_total_count
GENERIC
MAP
(
32
,
16
,
10
,
10
,
10
,
3
);
-- Check MM high word and counter overflow (clipping)
u_mm8b_cnt16b_high
:
ENTITY
work
.
tb_dp_strobe_total_count
GENERIC
MAP
(
8
,
16
,
10
,
10
,
10
,
3
);
-- use high part
u_mm8b_cnt9b_overflow
:
ENTITY
work
.
tb_dp_strobe_total_count
GENERIC
MAP
(
8
,
9
,
10
,
10
,
10
,
3
);
-- cause overflow to clip count high part
u_mm8b_cnt7b_overflow
:
ENTITY
work
.
tb_dp_strobe_total_count
GENERIC
MAP
(
8
,
7
,
10
,
10
,
10
,
3
);
-- cause overflow to clip count low part
END
tb
;
END
tb
;
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