vhdl counter integer log
Counting to 50000000 during one second requires 26 bit.
Since you want a 8 bit result we only pass on the highest 8 bits, which is basically a 'div' operation.
result(7 downto 0) <= counter(25 downto 18)
Mind you, since 50000000 does not exactly fit in 26 bit (26 bit == 67 MHz full range) we do loose some range.
An exact 'scaling' is not advised here, although with some simple logic you might increase the resolution.
It would be better to transfer the result by some other means:
- higher resolution
- using fixed point 'arithmetic': bits for integer part and bits for after the decimal point (assuming this is needed)
- instead of measuring during one second, measure the time between two pulses (better: do both)
So, it all depends on the exact 'specifications'. Resolution, accuracy, etc...
Using 8 bits for the full range would have a resolution of 200 kHz steps ....