Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
W
White Rabbit core collection
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
30
Issues
30
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Schedules
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
White Rabbit core collection
Commits
fa6e7288
Commit
fa6e7288
authored
Oct 19, 2018
by
Tomasz Wlostowski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wr_streamers: hopefully fixed all bugs in fixed_latency_ts_match...
parent
2aa4c259
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
92 additions
and
53 deletions
+92
-53
fixed_latency_delay.vhd
modules/wr_streamers/fixed_latency_delay.vhd
+1
-1
fixed_latency_ts_match.vhd
modules/wr_streamers/fixed_latency_ts_match.vhd
+91
-52
No files found.
modules/wr_streamers/fixed_latency_delay.vhd
View file @
fa6e7288
...
...
@@ -217,7 +217,7 @@ begin
tm_tai_i
=>
tm_tai_i
,
tm_cycles_i
=>
tm_cycles_i
,
match_o
=>
delay_match
,
miss
_o
=>
delay_miss
);
late
_o
=>
delay_miss
);
p_fsm_comb
:
process
(
state
,
rx_dreq_i
,
fifo_empty
,
delay_miss
,
fifo_last
,
delay_match
,
fifo_target_ts_en
,
fifo_valid
)
begin
...
...
modules/wr_streamers/fixed_latency_ts_match.vhd
View file @
fa6e7288
...
...
@@ -4,8 +4,8 @@ use ieee.numeric_std.all;
entity
fixed_latency_ts_match
is
generic
(
g_clk_ref_rate
:
integer
;
g_simulation
:
integer
:
=
0
;
(
g_clk_ref_rate
:
integer
;
g_simulation
:
integer
:
=
0
;
g_sim_cycle_counter_range
:
integer
:
=
125000000
);
...
...
@@ -27,96 +27,135 @@ entity fixed_latency_ts_match is
-- Fractional part of the second (in clk_ref_i cycles)
tm_cycles_i
:
in
std_logic_vector
(
27
downto
0
)
:
=
x"0000000"
;
match_o
:
out
std_logic
;
miss_o
:
out
std_logic
late_o
:
out
std_logic
);
end
entity
;
architecture
rtl
of
fixed_latency_ts_match
is
type
t_state
is
(
IDLE
,
WRAP_ADJ_TS
,
CHECK_LATE
,
WAIT_TRIG
);
impure
function
f_cycles_counter_range
return
integer
is
begin
if
g_simulation
=
1
then
return
g_sim_cycle_counter_range
;
if
g_clk_ref_rate
=
62500000
then
return
2
*
g_sim_cycle_counter_range
;
else
return
g_sim_cycle_counter_range
;
end
if
;
else
return
125000000
;
end
if
;
end
function
;
constant
c_rollover_threshold_lo
:
integer
:
=
f_cycles_counter_range
/
4
;
constant
c_rollover_threshold_hi
:
integer
:
=
f_cycles_counter_range
*
3
/
4
;
signal
ts_adjusted
:
unsigned
(
28
downto
0
);
signal
target_cycles
:
unsigned
(
28
downto
0
);
signal
arm_d
:
std_logic_vector
(
2
downto
0
);
signal
armed
:
std_logic
;
signal
tm_cycles_scaled
:
unsigned
(
28
downto
0
);
signal
tm_cycles_scaled
:
unsigned
(
28
downto
0
);
signal
ts_latency_scaled
:
unsigned
(
28
downto
0
);
signal
match
:
std_logic
;
signal
state
:
t_state
;
signal
ts_adj_next_cycle
,
roll_lo
,
roll_hi
:
std_logic
;
begin
process
(
tm_cycles_i
,
ts_latency_i
)
begin
if
g_clk_ref_rate
=
62500000
then
tm_cycles_scaled
<=
unsigned
(
tm_cycles_i
&
'0'
);
tm_cycles_scaled
<=
unsigned
(
tm_cycles_i
&
'0'
);
ts_latency_scaled
<=
unsigned
(
ts_latency_i
&
'0'
);
elsif
g_clk_ref_rate
=
125000000
then
tm_cycles_scaled
<=
unsigned
(
'0'
&
tm_cycles_i
);
tm_cycles_scaled
<=
unsigned
(
'0'
&
tm_cycles_i
);
ts_latency_scaled
<=
unsigned
(
'0'
&
ts_latency_i
);
else
report
"Unsupported g_clk_ref_rate (62.5 / 125 MHz)"
severity
failure
;
end
if
;
end
process
;
process
(
clk_i
)
begin
if
rising_edge
(
clk_i
)
then
if
rst_n_i
=
'0'
then
armed
<=
'0'
;
arm_d
<=
(
others
=>
'0'
);
miss_o
<=
'0'
;
armed
<=
'0'
;
late_o
<=
'0'
;
match
<=
'0'
;
State
<=
IDLE
;
else
arm_d
<=
arm_d
(
1
downto
0
)
&
arm_i
;
if
arm_i
=
'1'
then
match_o
<=
'0'
;
miss_o
<=
'0'
;
ts_adjusted
<=
resize
(
unsigned
(
ts_origin_i
)
+
unsigned
(
ts_latency_i
),
29
);
end
if
;
if
ts_adjusted
<
c_rollover_threshold_lo
and
tm_cycles_scaled
>
c_rollover_threshold_hi
then
target_cycles
<=
tm_cycles_scaled
+
f_cycles_counter_range
;
if
arm_d
(
0
)
=
'1'
then
ts_adjusted
<=
ts_adjusted
+
f_cycles_counter_range
;
end
if
;
else
target_cycles
<=
tm_cycles_scaled
;
end
if
;
if
(
arm_d
(
1
)
=
'1'
)
then
if
ts_adjusted
<
target_cycles
then
miss_o
<=
'1'
;
else
armed
<=
'1'
;
end
if
;
end
if
;
if
armed
=
'1'
and
ts_adjusted
=
tm_cycles_scaled
then
match_o
<=
'1'
;
armed
<=
'0'
;
else
match_o
<=
'0'
;
end
if
;
case
State
is
when
IDLE
=>
match
<=
'0'
;
late_o
<=
'0'
;
armed
<=
'0'
;
if
arm_i
=
'1'
then
ts_adjusted
<=
resize
(
unsigned
(
ts_origin_i
)
+
unsigned
(
ts_latency_i
),
29
);
State
<=
WRAP_ADJ_TS
;
armed
<=
'1'
;
end
if
;
when
WRAP_ADJ_TS
=>
ts_adj_next_cycle
<=
'0'
;
roll_lo
<=
'0'
;
roll_hi
<=
'0'
;
if
ts_adjusted
>=
f_cycles_counter_range
then
ts_adj_next_cycle
<=
'1'
;
ts_adjusted
<=
ts_adjusted
-
f_cycles_counter_range
;
end
if
;
if
ts_adjusted
<
c_rollover_threshold_lo
then
roll_lo
<=
'1'
;
end
if
;
if
tm_cycles_scaled
>
c_rollover_threshold_hi
then
roll_hi
<=
'1'
;
end
if
;
State
<=
CHECK_LATE
;
when
CHECK_LATE
=>
if
roll_lo
=
'1'
and
roll_hi
=
'1'
then
if
ts_adj_next_cycle
=
'0'
then
late_o
<=
'1'
;
State
<=
IDLE
;
else
State
<=
WAIT_TRIG
;
end
if
;
else
State
<=
WAIT_TRIG
;
end
if
;
when
WAIT_TRIG
=>
if
ts_adjusted
=
tm_cycles_scaled
then
match
<=
'1'
;
State
<=
IDLE
;
end
if
;
end
case
;
end
if
;
end
if
;
end
process
;
match_o
<=
match
;
end
rtl
;
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