From: Adam Krolnik (adamk@cyrix.com)
Date: Sun Oct 25 1998 - 20:16:20 PST
Good morning Tom:
You wrote, "We don't believe it's a good idea to have different rules for $swrite
and $fwrite."
reg [32*8:1] string;
initial begin
string = "Hello Tom, this is a test";
$display(string);
end
Tom, what does this produce? How do you get what is really needed?
>$fwrite("file.out","%d format string", var, "%d another format string", var);
You did not note the implicit nature of $fwrite is to write arguments without
a corresponding format string in decimal formatting.
>If I instead want to change this to a $swrite, then I've got to rewrite the
>entire task
>$swrite(stringvar,"%d format string %d another format string", var, var);
>instead of just changing the name and filename:
>$swrite(stringvar,"%d format string", var, "%d another format string", var);
Not unreasonable - but you are still expecting 'var' to be formatted to decimal!
You said, "We're also not entirely sold on the notion that users will actually use a
string variable to specify a format string. Can you give an example of
where this functionality would be used?"
Here is the example I want to work and why one should have $swrite.
task report_error;
input [256*8:1] message;
begin
$display("ERROR %0d: %0s", $stime);
<more stuff>
end
endtask
begin
...
$swrite(string, err_msg[`THIS_ERR], address, exp_data, receive_data);
report_error(string);
...
end
In this example, 'err_msg' is an array that holds the error messages (with
format specifiers.) I want to use this "format string" to create an
error message that I pass to a task. I can't do this with $display or any
other system task. The definition of the second parameter as intepreted
as a string gets over the $display() problem I exhitibed above. The existance
of $swrite() is simply because the functionality of $display is rather large
to ask users to rewrite it if the want $swrite functionality.
We already have $fscanf and $swrite is the opposite of this.
If we want to support your example, then one needs to have the second argument
always intepreted as a string (still) and 3 more system tasks: $swriteb, $swriteo,
$swriteh to switch the implicit default. I really don't like the shorthand
syntax (implicit format specification) for $swrite().
Adam Krolnik
Verification Engineer
Cyrix - NSC.
Richardson TX. 75085
This archive was generated by hypermail 2.1.4
: Mon Jul 08 2002 - 12:53:00 PDT
and
sponsored by Boyd Technology, Inc.