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
9419afdb
Commit
9419afdb
authored
4 years ago
by
Pieter Donker
Browse files
Options
Downloads
Patches
Plain Diff
L2SDP-180
, now with checks
parent
312c5d22
No related branches found
No related tags found
2 merge requests
!100
Removed text for XSub that is now written in Confluence Subband correlator...
,
!59
Resolve L2SDP-180
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
libraries/base/common/src/vhdl/common_variable_delay.vhd
+25
-32
25 additions, 32 deletions
libraries/base/common/src/vhdl/common_variable_delay.vhd
libraries/base/common/tb/vhdl/tb_common_variable_delay.vhd
+56
-45
56 additions, 45 deletions
libraries/base/common/tb/vhdl/tb_common_variable_delay.vhd
with
81 additions
and
77 deletions
libraries/base/common/src/vhdl/common_variable_delay.vhd
+
25
−
32
View file @
9419afdb
...
@@ -33,13 +33,11 @@ USE work.common_pkg.ALL;
...
@@ -33,13 +33,11 @@ USE work.common_pkg.ALL;
ENTITY
common_variable_delay
IS
ENTITY
common_variable_delay
IS
--GENERIC (
--);
PORT
(
PORT
(
rst
:
IN
STD_LOGIC
;
rst
:
IN
STD_LOGIC
;
clk
:
IN
STD_LOGIC
;
clk
:
IN
STD_LOGIC
;
delay
:
IN
NATURAL
:
=
0
;
delay
:
IN
NATURAL
:
=
0
;
enable
:
IN
STD_LOGIC
:
=
'0'
;
enable
:
IN
STD_LOGIC
:
=
'0'
;
in_val
:
IN
STD_LOGIC
;
in_val
:
IN
STD_LOGIC
;
out_val
:
OUT
STD_LOGIC
out_val
:
OUT
STD_LOGIC
...
@@ -53,44 +51,39 @@ ARCHITECTURE rtl OF common_variable_delay IS
...
@@ -53,44 +51,39 @@ ARCHITECTURE rtl OF common_variable_delay IS
SIGNAL
nxt_i_out_val
:
STD_LOGIC
;
SIGNAL
nxt_i_out_val
:
STD_LOGIC
;
SIGNAL
delay_cnt
:
NATURAL
;
SIGNAL
delay_cnt
:
NATURAL
;
SIGNAL
nxt_delay_cnt
:
NATURAL
;
SIGNAL
nxt_delay_cnt
:
NATURAL
;
SIGNAL
in_val_
hold
:
STD_LOGIC
;
SIGNAL
in_val_
lock
:
STD_LOGIC
;
SIGNAL
nxt_in_val_
hold
:
STD_LOGIC
;
SIGNAL
nxt_in_val_
lock
:
STD_LOGIC
;
BEGIN
BEGIN
out_val
<=
i_out_val
AND
enable
;
out_val
<=
i_out_val
;
--
AND enable;
p_delay
:
PROCESS
(
delay
,
in_val
,
i_out_val
,
delay_cnt
,
in_val_
hold
)
p_delay
:
PROCESS
(
enable
,
delay
,
in_val
,
i_out_val
,
delay_cnt
,
in_val_
lock
)
BEGIN
BEGIN
nxt_i_out_val
<=
i_out_val
;
nxt_i_out_val
<=
'0'
;
nxt_delay_cnt
<=
delay_cnt
;
nxt_delay_cnt
<=
delay_cnt
+
1
;
nxt_in_val_hold
<=
in_val_hold
;
nxt_in_val_lock
<=
in_val_lock
;
IF
delay
=
0
THEN
IF
enable
=
'1'
THEN
nxt_i_out_val
<=
in_val
;
IF
rising_edge
(
in_val
)
THEN
ELSE
nxt_in_val_lock
<=
'1'
;
IF
RISING_EDGE
(
in_val
)
AND
in_val_hold
=
'0'
THEN
IF
delay
=
0
THEN
nxt_in_val_hold
<=
'1'
;
nxt_delay_cnt
<=
0
;
nxt_delay_cnt
<=
1
;
END
IF
;
END
IF
;
IF
in_val_hold
=
'1'
AND
i_out_val
=
'1'
THEN
nxt_in_val_hold
<=
'0'
;
END
IF
;
END
IF
;
IF
in_val_
hold
=
'
1
'
THEN
IF
nxt_
in_val_
lock
=
'
0
'
THEN
nxt_delay_cnt
<=
delay_cnt
+
1
;
nxt_delay_cnt
<=
0
;
END
IF
;
END
IF
;
IF
i_out_val
=
'1'
THEN
IF
nxt_delay_cnt
=
(
delay
+
1
)
THEN
nxt_i_out_val
<=
'0'
;
END
IF
;
IF
delay_cnt
=
delay
THEN
nxt_i_out_val
<=
'1'
;
nxt_i_out_val
<=
'1'
;
nxt_in_val_hold
<=
'0'
;
nxt_in_val_lock
<=
'0'
;
--nxt_delay_cnt <= 0;
END
IF
;
END
IF
;
ELSE
nxt_delay_cnt
<=
0
;
nxt_in_val_lock
<=
'0'
;
END
IF
;
END
IF
;
END
PROCESS
;
END
PROCESS
;
p_clk
:
PROCESS
(
rst
,
clk
)
p_clk
:
PROCESS
(
rst
,
clk
)
...
@@ -98,11 +91,11 @@ BEGIN
...
@@ -98,11 +91,11 @@ BEGIN
IF
rst
=
'1'
THEN
IF
rst
=
'1'
THEN
i_out_val
<=
'0'
;
i_out_val
<=
'0'
;
delay_cnt
<=
0
;
delay_cnt
<=
0
;
in_val_
hold
<=
'0'
;
in_val_
lock
<=
'0'
;
ELSIF
rising_edge
(
clk
)
THEN
ELSIF
rising_edge
(
clk
)
THEN
i_out_val
<=
nxt_i_out_val
;
i_out_val
<=
nxt_i_out_val
;
delay_cnt
<=
nxt_delay_cnt
;
delay_cnt
<=
nxt_delay_cnt
;
in_val_
hold
<=
nxt_in_val_
hold
;
in_val_
lock
<=
nxt_in_val_
lock
;
END
IF
;
END
IF
;
END
PROCESS
;
END
PROCESS
;
...
...
This diff is collapsed.
Click to expand it.
libraries/base/common/tb/vhdl/tb_common_variable_delay.vhd
+
56
−
45
View file @
9419afdb
...
@@ -23,6 +23,7 @@ LIBRARY IEEE;
...
@@ -23,6 +23,7 @@ LIBRARY IEEE;
USE
IEEE
.
std_logic_1164
.
ALL
;
USE
IEEE
.
std_logic_1164
.
ALL
;
USE
IEEE
.
numeric_std
.
ALL
;
USE
IEEE
.
numeric_std
.
ALL
;
USE
work
.
common_pkg
.
ALL
;
USE
work
.
common_pkg
.
ALL
;
USE
work
.
common_str_pkg
.
ALL
;
USE
work
.
tb_common_pkg
.
ALL
;
USE
work
.
tb_common_pkg
.
ALL
;
ENTITY
tb_common_variable_delay
IS
ENTITY
tb_common_variable_delay
IS
...
@@ -30,66 +31,79 @@ END tb_common_variable_delay;
...
@@ -30,66 +31,79 @@ END tb_common_variable_delay;
ARCHITECTURE
tb
OF
tb_common_variable_delay
IS
ARCHITECTURE
tb
OF
tb_common_variable_delay
IS
CONSTANT
clk_period
:
TIME
:
=
10
ns
;
CONSTANT
c_clk_period
:
TIME
:
=
10
ns
;
CONSTANT
max_delay
:
NATURAL
:
=
5
;
CONSTANT
c_trigger_interval
:
NATURAL
:
=
40
;
-- in clk's
CONSTANT
c_trigger_latency
:
NATURAL
:
=
3
;
-- in clk's
CONSTANT
c_delay_arr
:
t_natural_arr
(
0
TO
3
)
:
=
(
0
,
1
,
3
,
12
);
SIGNAL
tb_end
:
STD_LOGIC
:
=
'0'
;
SIGNAL
tb_end
:
STD_LOGIC
:
=
'0'
;
SIGNAL
rst
:
STD_LOGIC
;
SIGNAL
rst
:
STD_LOGIC
;
SIGNAL
clk
:
STD_LOGIC
:
=
'0'
;
SIGNAL
clk
:
STD_LOGIC
:
=
'0'
;
SIGNAL
delay
:
NATURAL
:
=
0
;
SIGNAL
delay
:
NATURAL
:
=
0
;
SIGNAL
enable
:
STD_LOGIC
:
=
'0'
;
SIGNAL
enable
:
STD_LOGIC
:
=
'0'
;
SIGNAL
trigger
:
STD_LOGIC
;
SIGNAL
trigger
:
STD_LOGIC
:
=
'0'
;
SIGNAL
trigger_dly
:
STD_LOGIC
;
SIGNAL
trigger_dly
:
STD_LOGIC
:
=
'0'
;
SIGNAL
clk_cnt
:
NATURAL
:
=
0
;
BEGIN
BEGIN
clk
<=
(
NOT
clk
)
OR
tb_end
AFTER
clk_period
/
2
;
clk
<=
(
NOT
clk
)
OR
tb_end
AFTER
c_clk_period
/
2
;
rst
<=
'1'
,
'0'
AFTER
clk_period
*
3
;
rst
<=
'1'
,
'0'
AFTER
c_clk_period
*
4
;
-- generate trigger signal
p_trigger
:
PROCESS
BEGIN
WAIT
UNTIL
rst
=
'0'
;
proc_common_wait_some_cycles
(
clk
,
10
);
WAIT
UNTIL
rising_edge
(
clk
);
WHILE
tb_end
=
'0'
LOOP
trigger
<=
NOT
trigger
;
proc_common_wait_some_cycles
(
clk
,
c_trigger_interval
/
2
);
END
LOOP
;
WAIT
;
END
PROCESS
;
-- run 1 us
p_in_stimuli
:
PROCESS
p_in_stimuli
:
PROCESS
BEGIN
BEGIN
delay
<=
0
;
delay
<=
0
;
enable
<=
'0'
;
enable
<=
'0'
;
trigger
<=
'0'
;
WAIT
UNTIL
rst
=
'0'
;
WAIT
UNTIL
rst
=
'0'
;
WAIT
UNTIL
rising_edge
(
clk
);
WAIT
UNTIL
rising_edge
(
clk
);
-- Start counting
-- If enable = 0, no trigger_dly is expected, see wave-window
enable
<=
'0'
;
proc_common_wait_some_cycles
(
clk
,
50
);
proc_common_wait_some_cycles
(
clk
,
50
);
FOR
i
IN
0
TO
10
LOOP
trigger
<=
'1'
;
proc_common_wait_some_cycles
(
clk
,
4
);
trigger
<=
'0'
;
proc_common_wait_some_cycles
(
clk
,
4
);
END
LOOP
;
enable
<=
'1'
;
enable
<=
'1'
;
FOR
i
IN
0
TO
10
LOOP
-- enable trigger output and count clk's between trigger lo-hi and trigger_dly lo-hi
trigger
<=
'1'
;
-- check if counted clk's = c_trigger_latency + delay
proc_common_wait_some_cycles
(
clk
,
4
);
FOR
i
IN
0
TO
c_delay_arr
'LENGTH
-1
LOOP
trigger
<=
'0'
;
delay
<=
c_delay_arr
(
i
);
proc_common_wait_some_cycles
(
clk
,
4
);
clk_cnt
<=
0
;
proc_common_wait_until_lo_hi
(
clk
,
trigger
);
WHILE
trigger_dly
=
'0'
LOOP
clk_cnt
<=
clk_cnt
+
1
;
proc_common_wait_some_cycles
(
clk
,
1
);
END
LOOP
;
ASSERT
clk_cnt
=
(
c_trigger_latency
+
delay
)
REPORT
"delay failure, got "
&
int_to_str
(
clk_cnt
)
&
", expect "
&
int_to_str
(
c_trigger_latency
+
delay
)
SEVERITY
ERROR
;
proc_common_wait_some_cycles
(
clk
,
10
);
END
LOOP
;
END
LOOP
;
delay
<=
1
;
-- If delay > trigger interval, trigger lo-hi shold not start new delay, see also wave window
FOR
i
IN
0
TO
10
LOOP
delay
<=
c_trigger_interval
+
2
;
trigger
<=
'1'
;
clk_cnt
<=
0
;
proc_common_wait_some_cycles
(
clk
,
4
);
proc_common_wait_until_lo_hi
(
clk
,
trigger
);
trigger
<=
'0'
;
WHILE
trigger_dly
=
'0'
LOOP
proc_common_wait_some_cycles
(
clk
,
4
);
clk_cnt
<=
clk_cnt
+
1
;
proc_common_wait_some_cycles
(
clk
,
1
);
END
LOOP
;
END
LOOP
;
ASSERT
clk_cnt
=
(
c_trigger_latency
+
delay
)
REPORT
"delay failure, got "
&
int_to_str
(
clk_cnt
)
&
", expect "
&
int_to_str
(
c_trigger_latency
+
delay
)
SEVERITY
ERROR
;
proc_common_wait_some_cycles
(
clk
,
10
);
delay
<=
12
;
enable
<=
'0'
;
FOR
i
IN
0
TO
10
LOOP
proc_common_wait_some_cycles
(
clk
,
10
);
trigger
<=
'1'
;
proc_common_wait_some_cycles
(
clk
,
4
);
trigger
<=
'0'
;
proc_common_wait_some_cycles
(
clk
,
4
);
END
LOOP
;
tb_end
<=
'1'
;
tb_end
<=
'1'
;
...
@@ -98,9 +112,6 @@ BEGIN
...
@@ -98,9 +112,6 @@ BEGIN
-- device under test
-- device under test
u_dut
:
ENTITY
work
.
common_variable_delay
u_dut
:
ENTITY
work
.
common_variable_delay
GENERIC
MAP
(
g_max_delay
=>
max_delay
)
PORT
MAP
(
PORT
MAP
(
rst
=>
rst
,
rst
=>
rst
,
clk
=>
clk
,
clk
=>
clk
,
...
...
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