surabhig.com

No shortcuts. Work for it.

Category: Resources

hexadecimal to binary converter

The C-code snippet below is something I wrote to read a hex character from a file and convert each bit into a sample of byte length. Because how my hex file was written I had to decode even characters before the odd ones, you’ll notice in the code. If you need something similar feel free to tweak the code below.

Example:
Input hex file format (filename.dat):

1234

Output file format(filename.bin):

00 01 00 00 01 00 00 00 01 01 00 00 00 00 01 00

If you notice the converter takes the even character first and reads LSB to MSB and then reads the previous odd character (LSB to MSB) and so on…
There are many ways of doing this in C or Python but MATLAB is not one of them! Why? Because it is just too SLOW.
This is a good binary file reader.

Phase Increment Calculator for NCO

This Phase Increment Calculator is built specifically for hardware implementation of a Numerically Controlled Oscillator (NCO).

Specify the desired frequency of the output signal of the NCO, the system (or input) clock frequency and the accumulator bit width, to obtain the accumulator value you should use for the NCO.

Equation:

f_out = [phase_inc/(2N)] * input_clk

Review code: 2-bit Signal Generator (NCO) in Verilog

© 2018 surabhig.com

Theme by Anders NorenUp ↑