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
signal observer_state : obs_state_type := IDLE;
signal observer_count : natural;
signal observer_period : time;
signal observer_delay : time; -- Delay between sync and first pulse,
signal wait_sync : boolean;
begin
-- System clock, 62.5 Mhz
process
......@@ -108,7 +110,7 @@ begin
);
-- VTU observer.
process (trig_p, observer_cmd)
process (trig_p, clk_rf, observer_cmd)
variable last_ts : time;
variable this_period : time;
begin
......@@ -119,11 +121,18 @@ begin
observer_state <= WORKING;
observer_count <= 1;
last_ts := now;
wait_sync <= True;
when WORKING =>
report "VTU observer command overrides the previous one" severity error;
end case;
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
report "Trigger:" & Natural'image(observer_count);
case observer_state is
......@@ -131,7 +140,11 @@ begin
report "VTU observer: trigger before command" severity error;
when WORKING | OBS_DONE =>
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;
elsif observer_count > 2 then
if this_period /= observer_period then
......@@ -280,6 +293,8 @@ begin
wait on observer_state;
-- Check observer status.
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;
-- Check VTU status.
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