FILE IO

Guest
I'm trying to write data from a port to a file in binary format. This
is my code.

integer v_hand;
integer vcount;

initial
begin
v_hand = $fopen("vid_test.es", "w");
vcount = 0;
forever @(posedge Clk)
if (VS_Valid)
begin
vcount = vcount + 1;
if (vcount == 16) vcount = 0;
$fwrite(vhand, "%x%c", VS_Data, (vcount == 0) ? "\n" : " ");
end
end

This writes the code in a hex \ characters as opposed to hex \ binary

Any suggestions

PJ
 
oneonchip@gmail.com wrote:
$fwrite(vhand, "%x%c", VS_Data, (vcount == 0) ? "\n" : " ");

This writes the code in a hex \ characters as opposed to hex \ binary
It is not entirely clear what you are trying to do. It sounds like you
are trying to write out your data as raw binary, rather than formatting
it. For that you would use %u, for unformatted. But why would you be
writing newlines or spaces as separators in a raw binary file?
 
<oneonchip@gmail.com> a écrit dans le message de news:
1158591590.811743.164720@i42g2000cwa.googlegroups.com...
I'm trying to write data from a port to a file in binary format. This
is my code.

integer v_hand;
integer vcount;

initial
begin
v_hand = $fopen("vid_test.es", "w");
vcount = 0;
forever @(posedge Clk)
if (VS_Valid)
begin
vcount = vcount + 1;
if (vcount == 16) vcount = 0;
$fwrite(vhand, "%x%c", VS_Data, (vcount == 0) ? "\n" : " ");
end
end

This writes the code in a hex \ characters as opposed to hex \ binary

Any suggestions

PJ
You probably want to use the %u instead of %x in the $fwrite format
specification string.
Serge
 
use %z if you want your 'x' & 'z' to be replicated as well.

HTH,
Naren.
TooMuch Semiconductor Solutions Pvt. Ltd.,
Specialising on Verification Services & Solutions.
 

Welcome to EDABoard.com

Sponsor

Back
Top