Let's start with decimal to binary:
The function will return the number of bits asked by the user. Of course, this function cannot handle X or Z values supported by Verilog. It worked for me.
For hex to binary and octal to binary conversions, I decided to use simple macros because it turned out to be the fastest code I tried. It does not look elegant, but that is not a concern for me.
First define the macros:
In these macros, HEX and OCT are characters, and STRING is an std::string. I used these macros in the following way:
No comments:
Post a Comment