Commit f00f4d0d authored by Tristan Gingold's avatar Tristan Gingold

tb_vtu: add observer for initial pulse.

parent 40e6f0b1
...@@ -68,6 +68,8 @@ architecture arch of tb_vtu is ...@@ -68,6 +68,8 @@ architecture arch of tb_vtu is
signal observer_state : obs_state_type := IDLE; signal observer_state : obs_state_type := IDLE;
signal observer_count : natural; signal observer_count : natural;
signal observer_period : time; signal observer_period : time;
signal observer_delay : time; -- Delay between sync and first pulse,
signal wait_sync : boolean;
begin begin
-- System clock, 62.5 Mhz -- System clock, 62.5 Mhz
process process
...@@ -108,7 +110,7 @@ begin ...@@ -108,7 +110,7 @@ begin
); );
-- VTU observer. -- VTU observer.
process (trig_p, observer_cmd) process (trig_p, clk_rf, observer_cmd)
variable last_ts : time; variable last_ts : time;
variable this_period : time; variable this_period : time;
begin begin
...@@ -119,11 +121,18 @@ begin ...@@ -119,11 +121,18 @@ begin
observer_state <= WORKING; observer_state <= WORKING;
observer_count <= 1; observer_count <= 1;
last_ts := now; last_ts := now;
wait_sync <= True;
when WORKING => when WORKING =>
report "VTU observer command overrides the previous one" severity error; report "VTU observer command overrides the previous one" severity error;
end case; end case;
end if; end if;
if rising_edge(clk_rf) and sync = '1' and wait_sync then
last_ts := now;
wait_sync <= false;
report "VTU observer: got sync";
end if;
if trig_p'event and (observer_cmd.square or trig_p = '1') then if trig_p'event and (observer_cmd.square or trig_p = '1') then
report "Trigger:" & Natural'image(observer_count); report "Trigger:" & Natural'image(observer_count);
case observer_state is case observer_state is
...@@ -131,7 +140,11 @@ begin ...@@ -131,7 +140,11 @@ begin
report "VTU observer: trigger before command" severity error; report "VTU observer: trigger before command" severity error;
when WORKING | OBS_DONE => when WORKING | OBS_DONE =>
this_period := now - last_ts; this_period := now - last_ts;
if observer_count = 2 then if observer_count = 1 then
-- First pulse.
assert not wait_sync report "VTU observer: trigger before sync";
observer_delay <= this_period;
elsif observer_count = 2 then
observer_period <= this_period; observer_period <= this_period;
elsif observer_count > 2 then elsif observer_count > 2 then
if this_period /= observer_period then if this_period /= observer_period then
...@@ -280,6 +293,8 @@ begin ...@@ -280,6 +293,8 @@ begin
wait on observer_state; wait on observer_state;
-- Check observer status. -- Check observer status.
assert observer_state = OBS_DONE severity error; assert observer_state = OBS_DONE severity error;
report natural'image(observer_delay / 5 ns);
report time'image(observer_delay);
assert observer_period = 8 * 5 ns; assert observer_period = 8 * 5 ns;
-- Check VTU status. -- Check VTU status.
read_status(val); read_status(val);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment