# vga - Measurement system of response time of computer monitor - VHDL

I'm in work placement and I have this subject in VHDL : Measurement system of response time of computer monitor.

To succeed I thought about to put a photodiode in front of the monitor and switch in black and white every second the monitor to known the response time.

But I don't know really how to make that, I use a spartan 3 connected at the monitor by VGA.

I right a program I'm not sure if it's right, (I think it's wrong). I show you my program :

``LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALLUSE IEEE.NUMERIC_STD.ALLENTITY Counter ISPORT(clk, rst : IN STD_LOGIC;sync, PhD : IN STD_LOGIC;s : OUT STD_LOGIC_VECTOR(3 DOWNTO 0));END ENTITY Counter;ARCHITECTURE Main OF Counter ISSIGNAL q : UNSIGNED (3 DOWNTO 0);BEGINs <= STD_LOGIC_VECTOR(q);PROCESS (clk, rst) ISBEGINIF rst='1' THENq<=(OTHERS => '0');ELSIF RISING_EDGE(clk) THENIF sync='0' THENq=q;ELSIF sync='1' THENIF PhD='0' THENq<=q+1;ELSIF PhD='1' THENq=q;END IF;END IF;END IF;END PROCESS;END ARCHITECTURE Mai``

n;

Tell me if you need something more maybe I forgot something. And tell me what you thing about my program.

What you wrote is a counter that is incremented in each clock cycle that sync is 1 and phd is 0. Without knowing your exact requirements, it is difficult to say whether this is what you want or not.

If you want to determine the amount of time between sync going high and phd going high, you should set q to 0 when sync=0. This will cause the counter to start from 0 each time sync goes high.

You should probably also increase the width of q, depending on how fast your clock is. Currently it has only 4 bits, meaning it will wrap back to 0 every 16 cycles. Given typical clock frequencies (e.g. 100 MHz), this is less than a microsecond. To count for one second at 100 MHz, you would need a counter of at least 27 bits.