cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Observer
Observer
132 Views
Registered: ‎11-19-2017

XSIM $fwrite() and $fwriteb() system task

Hello,

It seems that %u format of XSIM $fwrite() and $fwriteb() does not work properly.

What I expected that 'fileA' and 'fileB' should contains as follows.

0000000 11 22 33 44 0a
0000005

I tried to check $fwite() and $fwritb() using following code and it seems not work correctly.

Is there any way around?

 

[top.v]

// put 32-bit value to file using $write() and $writeb()

module top();
integer idx;
integer fdA, fdB;
reg [31:0] data;
initial begin
   data = 32'h44_33_22_11;
   $display("%H", data);

   fdA = $fopen("fileA", "wb");
   $fwrite(fdA, "%u\n", data);
   $fclose(fdA);

   fdB = $fopen("fileB", "wb");
   $fwriteb(fdB, "%u\n", data);
   $fclose(fdB);
end
endmodule

 

[xsim results]

# xsim {top_sim} -autoloadwcfg -runall
Vivado Simulator 2019.2
Time resolution is 1 ps
run -all
44332211
exit

 

[fileA and fileB]

$ od -t x1 fileA

0000000 30 31 30 30 30 31 30 30 30 30 31 31 30 30 31 31
0000020 30 30 31 30 30 30 31 30 30 30 30 31 30 30 30 31
0000040 0a
0000041

$ od -t x1 fileB
0000000 30 31 30 30 30 31 30 30 30 30 31 31 30 30 31 31
0000020 30 30 31 30 30 30 31 30 30 30 30 31 30 30 30 31
0000040 0a
0000041

0 Kudos
1 Reply
Highlighted
Xilinx Employee
Xilinx Employee
118 Views
Registered: ‎06-10-2020

Thank you for the testcase, this is a bug in Vivado simulator. We will fix in our next release.

0 Kudos