Search code examples
verilogsystem-veriloghdlvivadotest-bench

Vivado 2016.2 Simulator doesn't support System Verilog $cast or $sformatf


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?


Solution

  • 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.