Hi,
the input is in decimal value
There is no decimal input to an FPGA. Either there are ten lines per digit, or BCD, or the input is not dcimal, but binary.
for hardware i know its in binary format but for simulation its decimal value
Maybe it´s straight binary, but the "input" or "display" in the simulator is "decimal".
You urgently need to know this, else it is impossible to write code.
***
For an 8 bit binary value (uint8)
My solution is to use a counter "n" which counts 8 down to 0
on each run check the "n-1"-th bit of the input
If the value of the bit is "1", then out put n as result and stop forther runs.
Example: (pseudo code)
Decimal "36" --> binary "0010 0100"
(it contains 8 bits. bit 0 = LSB with value "1", bit 7 = MSB with value "128")
init counter = 8
test bit (8-1) = test bit 7 = test MSB ("
0010 0100")
it is not "1"
next run
counter = 7
test bit (7-1) = test bit 6 ("0
010 0100")
it is not "1"
next run
counter = 6
test bit (6-1) = test bit 5 ("00
10 0100")
it is "1"
Match! --> output counter value (in this case "6")
finish
Klaus