Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top