Convert a hex, int, binary data type to string


#1

SystemVerilog string methods allow you to convert int, hex, binary or real data type to a string.

The example below with output should tell you what exactly each method does.

/* Output: itoa 1024 */
s.itoa(1024);
$display("itoa %s", s);

/* Output: hextoa 400 */
s.hextoa(1024);
$display("hextoa %s", s);

/* Output: bintoa 10000000000 */
s.bintoa(1024);
$display("bintoa %s", s);

/* Output: octtoa 2000 */
s.octtoa(1024);
$display("octtoa %s", s);

/* Output: realtoa 1024.5 */
s.realtoa(1024.5);
$display("realtoa %s", s);

Output:

itoa 1024
hextoa 400
bintoa 10000000000
octtoa 2000
realtoa 1024.5