Tuesday 31 December 2013

Decimal to Binary/Hex Converter and VHDL Utility

This blog post implements an online numerical base converter, converting a list of floating point numbers from decimal to either binary or hexadecimal.

Enter (possibly floating point) decimal numbers in the text area below, one number per line - there must be no newline after the last number. You can enter either signed or unsigned numbers - to enable unsigned conversion, please check the checkbox which enables unsigned conversion (leaving this unchecked results in signed conversion). Alternatively you can load in a single column text file. Also fill in the number of unsigned integer bits and fractional bits, so that that resulting bitwidth will be (intbits + fracbits + 1), where intbits is the number of unsigned integer bits and fracbits is the number of fractional bits, for signed conversion. For unsigned conversion, the bitwidth will be (intbits + fracbits). Note that when converting to hexadecimal, if the bitwidth is not an integer multiple of 4, it will be rounded up to the nearest integer multiple of 4.

The number of integer bits and fractional bits must be set to accomodate the range of the input values.

As the decimal inputs can be floating point, you can select an appropriate rounding rule using the dropdown menu below.

There is the option of omitting the binary point, by leaving the appropriate checkbox below unchecked.

There is a final checkbox below that could come in handy for those who use VHDL (like I do, in my role as an FPGA Design Engineer). Checking this will result in a declaration of a signal type as an array of type std_logic_vector, and initialisation on declaration of a signal with the binary outputs. You can replace the strings <SIGNAL TYPE NAME> and <SIGNAL NAME> with a type name and signal name of your choice, after copying and pasting to your source code.



Enter number of unsigned integer bits: Enter number of fractional bits:





Input (decimal numbers)
Output (bin/hex or optional VHDL declaration)






Number of data samples is ..

No comments:

Post a Comment