九江论坛网

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 1178|回复: 1
打印 上一主题 下一主题

文件操作语句$fopen仿真打不开文件 [复制链接]

Rank: 7Rank: 7Rank: 7

跳转到指定楼层
楼主
发表于 2020-3-9 16:52:11 |只看该作者 |倒序浏览
欢迎来到九江论坛网--江西九江市生活交流社区! 请记住我们的网址 www.ganzw.com
    文章简介:////////////////////////////////////////////////////////////////////////



`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的同目錄下


分享到: QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
分享分享0 收藏收藏0

使用道具 举报

Rank: 7Rank: 7Rank: 7

沙发
发表于 2020-3-9 16:52:14 |只看该作者
欢迎来到九江论坛网--江西九江市生活交流社区! 请记住我们的网址 www.ganzw.com
应该放在执行仿真的目录。

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

联系我们|九江论坛网

GMT+8, 2024-5-17 12:00 , Processed in 1.156250 second(s), 11 queries .

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部