【发布时间】:2018-04-25 18:10:48
【问题描述】:
我正在使用 fgetc 读取文件。文件读取从偏移量开始。最后我看到 8'hFF 被附加在文件末尾。我期待文件中有 6 个字节,但在其中看到 7 个字节。我不确定为什么会这样。有什么想法吗?
下面是我的代码:
module file_read();
integer fd,fd1,file_char,status;
logic [7:0] captured_data;
initial begin
fd = $fopen("input_file", "rb");
fd1 =$fopen("write_file","w");
status=$fseek(fd,1872,0);
assert (status);
// while ($fgetc(fd) != `EOF) begin
while (!$feof(fd)) begin
file_char=$fgetc(fd);
$display("file char is %h",file_char);
end
end // initial begin
以下是文件内容(十六进制): input_file的最后一行(文件总大小=1878):
0000750: 0000 1567 d48d ...g..
写文件: 0000000: 0000 1567 d48d ff ...g...
谢谢!
【问题讨论】:
标签: system-verilog fgetc