2

Using the Vivado 2016.2 simulator I need to cast an int to a string in System Verilog but $cast and $sformatf are not supported. What other functions or methods are available to me in order to successfully typecast an int to a string?

Bdog
  • 35
  • 1
  • 6

1 Answers1

2

There are the following other ways

string s;
int i;

s.itoa(i); // converts int to decimal string
$swrite(s,"%d",i);
$sformat(s,"%d",i);

If none of those work for you, then you'll need to write a binary to decimal conversion routine yourself.

dave_59
  • 39,096
  • 3
  • 24
  • 63
  • $sformat does the job, though it is a little quirky I can make it work for my needs. Thanks! – Bdog Sep 21 '16 at 18:44