九江论坛网
标题:
文件操作语句$fopen仿真打不开文件
[打印本页]
作者:
常欢
时间:
2020-3-9 16:52:11
标题:
文件操作语句$fopen仿真打不开文件
文章简介:////////////////////////////////////////////////////////////////////////
`timescale 1ns / 1ps
`define NULL 0
////////////////////////////////////////////////////////////////////////////////
// Company:
// Engineer:
//
// Create Date: 14:06:57 09/30/2018
// Design Name: system
// Module Name: D:/Xilinx/exercise/system/system_display.v
// Project Name: system
// Target Device:
// Tool versions:
// Description:
//
// verilog Test Fixture created by ISE for module: system
//
// Dependencies:
//
// Revision:
// Revision 0.01 - File Created
// Additional Comments:
//
////////////////////////////////////////////////////////////////////////////////
module system_display;
integer fp_r;
integer fp_w;
integer flag;
reg[3:0] bin;
reg [15:0] data_in;
reg [15:0] cnt = 10;
initial
begin:file_fscanf//å—åç§
fp_r = $fopen("data_in.txt","r");
fp_w = $fopen("data_out.txt","w");
if(fp_r == `NULL)//ERROR
disable file_fscanf;
if(fp_w == `NULL)//ERROR
disable file_fscanf;
while(cnt>0)begin
flag = $fscanf(fp_r,"%d",data_in);
cnt = cnt -1;
$write("%d",data_in,",");
$fwrite(fp_w,"%d\n",data_in);
#5;
end
$fclose(fp_r);
$fclose(fp_w);
end
endmodule
仿真结果如下:显示无法打开文件,其中我把data_in.txt与data_out.txt文件放在system_display.v的同目錄下
作者:
若放弃
时间:
2020-3-9 16:52:14
应该放在执行仿真的目录。
欢迎光临 九江论坛网 (http://www.ganzw.com/)
Powered by Discuz! X2