User guide
24-11
SystemVerilog Testbench Constructs
$display("-----Start of Program ----------------");
s.hextoa(h);
$display("Ascii of hex value 'hfa1 is %s",s);
s.octtoa(o);
$display("Ascii of octal value 'o172 is %s",s);
s.bintoa(b);
$display("Ascii of binary value 'b101010 is %s",s);
s = "12.3456";
r = s.atoreal;
$display("Real value of ascii string \"12.3456\" is
%f", r);
s = "";
s.realtoa(r);
$display("Ascii of real value 12.3456 is %s",s);
$display("-------- End of Program ----------------");
endtask
initial
t1();
endprogram
The output of this program is:
start of Program --------------------
Ascii of hex value 'hfa1 is fa1
Ascii of octal value 'o172 is 172
Ascii of binary value 'b101010 is 101010
Real value of ascii string "12.3456" is 12.345600
Ascii of real value 12.3456 is 12.3456
-------- End of Program ----------------------