No shortcuts. Work for it.

Category: Uncategorized

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.

Input hex file format (filename.dat):


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.

2-bit Signal Generator (NCO) in Verilog

Recently started using version control BitBucket and I must say sharing code is definitely easier.

So here is the link to the code that generates sin and cos signals according to the required frequency.

It is 2 bit only because the range of values is between [-1,1].

If you are looking for something in the range of [0,1], that would make it a 1 bit NCO which is even easier (you just have to ignore the LSB). Focus only on sin[1] or cos[1].

This module is great if you have to quickly test something like demodulators etc.

If you figure there are issues or even found a simpler way please feel free to share them.

Alright, I’m onto figuring out the next task, atan in verilog!

P.S. I’m also going to make sharing the code easier on the blog… will try to embed it here.

© 2018

Theme by Anders NorenUp ↑