WRITING A FORMATTED STRING
integer file, r, a, b; reg [80*8:1] string; file = $fopenw("output.log"); r = $sformat(string, "Formatted %d %x", a, b); r = $sprintf(string, "Formatted %d %x", a, b); r = $fprintf(file, "Formatted %d %x", a, b);The functions $sformat and $sprintf writes a formatted string into a Verilog register. The two functions are identical. $fprintf writes a formatted string to a file. It has most, but not the formatting capabilites of C stdio package. The first argument is a register to receive the formatted data, and the second is a format string. Additional arguments may be included.
The supported formats include b, c, d, e, f, g, h, m, o, r, s, and x. %t for printing formatted time is NOT supported yet.

No comments:
Post a Comment