Change same signal at either rising or falling state of a signal
your problem is not complex... assuming your ADC code is working correctly..

you can use 2 edge detector circuit to generate a pulse: one on rising edge and one falling edge.. this will simplify your process...

http://fpgacenter.com/examples/basic/edge_detector.php

your process should have a reset condition and set initial value for the variables...