I am programming an application in vhdl for a National Instruments CompactRio. One of the inputs is from a scale that only outputs an ASCII string of the weight on the scale. I know I can convert the ASCII digits to Binary Coded Decimal simply by removing the 4 MSBs, but how do I convert that do an unsigned integer using vhdl? What is the fastest algorithm for values that range from 0 to 9999?
Asked
Active
Viewed 1,825 times
0
-
2By "fastest", do you mean "lowest footprint"? – Oliver Charlesworth Aug 15 '11 at 20:59
-
Fastest to develop? I'm sure NI has a string to integer block... – Martin Thompson Aug 16 '11 at 13:00
-
1After re-reading your question it's not clear to me if you want LabVIEW code or VHDL code? – Ton Plomp Aug 16 '11 at 17:03
-
fastest as in least clock cycles to complete while running. Labview does not appear to have a string to integer conversion when targeting the CompactRio FPGA platform. – user435050 Aug 23 '11 at 14:14
1 Answers
0
Sorry looked into BCD and realised it's not an ASCII representation of a numeric. I would convert the string into an U8 (using String To Byte Array), and feed that into a for-loop and multiply that with a constant array, this array would be [1000, 100, 10, 1], and summate all the elements of the resulting product, that should give you the numeric data of the string.

Ton Plomp
- 3,020
- 1
- 18
- 35