Skip to content

Instantly share code, notes, and snippets.

@pd0wm
Created June 12, 2013 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pd0wm/5763853 to your computer and use it in GitHub Desktop.
Save pd0wm/5763853 to your computer and use it in GitHub Desktop.
if (rising_edge(clk)) then
tick_counter := tick_counter + 1;
if (sensor_mem /= sensor_in and sensor_in = '1') then
if (measure = 1) then
if (i < 2) then -- the number of ticks in a frequency will be measured X times
sum := sum + tick_counter;
i := i + 1;
elsif (i = 2) then
counter_trigger := sum / 2; -- average ticks
sum := 0;
measure := 0;
i := 0;
end if;
end if;
tick_counter := 0;
end if;
sensor_mem := sensor_in;
end if;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment