convert hex string to bit vector in system verilog

Guest
Hi,

Could anyone help me to get the hex value stored in the string back?
Please see the example code below

Thanks
Dev

string e;
e = "07";
logic [31:0] b;

b = e; // i would like to have equalent hexadecimal value
"00000000000000000000000000000111"

but the value of b it returns is "00000000000000000000000000110111"
 
On Oct 15, 1:13 pm, goodev...@gmail.com wrote:
Hi,

Could anyone help me to get the hex value stored in the string back?
Please see the example code below

Thanks
Dev

string e;
e = "07";
logic [31:0] b;

b = e;     // i would like to have equalent hexadecimal value
"00000000000000000000000000000111"

but the value of b it returns is "00000000000000000000000000110111"

Use the atio() method, try adding my 'c' binary to your example.

string e;
logic [31:0] b;
logic [31:0] c;

e = "07";
b = e; // i would like to have equalent hexadecimal value
c = e.atoi(); // and you will with the atoi() method.

- Mark
 

Welcome to EDABoard.com

Sponsor

Back
Top