//open the file

Initial

Begin

step_file = $fopen("F:/Company/Src/txt/step.v","r");

file_ekxdn =$fopen("F:/Company/Src/txt/ekxdn.v","w");

end

always #5 clk = !clk;

//read data from file

always @ ( posedge clk )//read from the file

begin

if( cnt_test[2:0] == 0 )

begin

$fscanf(step_file,"%d%d",ref01_i,ref01_q);

end

end

//write data to file

wire signed[24:0]  ekxdn_i,ekxdn_q;

always @( posedge clk )

begin

if( cnt_test[2:0] == 3'b111 )

begin

$fwrite(nx_coef_file,"%d%12d\n",nx01_coef_i,nx01_coef_q);

end

end

读写文件的数据格式如下:

以下点要注意:

1、可能由于加密的原因,读不了txt文件,只能读。V的了

2、打开文件的$fopen语句必须放在initial 中才可以

3、必须注意路径中斜杠的方向“/”

4、相对路径的设置(请参考积累中的“相对路径与绝对路径”)

5、如果读入的是有符号数,那么要把数据的类型定义为signed

怎样关闭文件

读到文件结尾自动停止

txt文件格式如下

modelsim读写TXT文件的更多相关文章

  1. [转载]C#读写txt文件的两种方法介绍

    C#读写txt文件的两种方法介绍 by 大龙哥 1.添加命名空间 System.IO; System.Text; 2.文件的读取 (1).使用FileStream类进行文件的读取,并将它转换成char ...

  2. C#读写txt文件的两种方法介绍

    C#读写txt文件的两种方法介绍 1.添加命名空间 System.IO; System.Text; 2.文件的读取 (1).使用FileStream类进行文件的读取,并将它转换成char数组,然后输出 ...

  3. WPF 读写TxT文件

    原文:WPF 读写TxT文件 文/嶽永鹏 WPF 中读取和写入TxT 是经常性的操作,本篇将从详细演示WPF如何读取和写入TxT文件. 首先,TxT文件希望逐行读取,并将每行读取到的数据作为一个数组的 ...

  4. java指定编码的按行读写txt文件(几种读写方式的比较)

    转: java指定编码的按行读写txt文件(几种读写方式的比较) 2018年10月16日 20:40:02 Handoking 阅读数:976  版权声明:本文为博主原创文章,未经博主允许不得转载. ...

  5. python操作txt文件中数据教程[1]-使用python读写txt文件

    python操作txt文件中数据教程[1]-使用python读写txt文件 觉得有用的话,欢迎一起讨论相互学习~Follow Me 原始txt文件 程序实现后结果 程序实现 filename = '. ...

  6. C#读写txt文件的两种方法介绍[转]

    C#读写txt文件的两种方法介绍 1.添加命名空间 System.IO; System.Text; 2.文件的读取 (1).使用FileStream类进行文件的读取,并将它转换成char数组,然后输出 ...

  7. C#读写txt文件的两种方法介绍 v

    C#读写txt文件的两种方法介绍 1.添加命名空间 System.IO; System.Text; 2.文件的读取 (1).使用FileStream类进行文件的读取,并将它转换成char数组,然后输出 ...

  8. UNICODE环境下读写txt文件操作

    内容转载自http://blog.sina.com.cn/s/blog_5d2bad130100t0x9.html UNICODE环境下读写txt文件操作 (2011-07-26 17:40:05) ...

  9. MFC读写.txt文件时进度条显示实时进度

    整体实现方式:先获得文件长度,然后用每次读取的长度,计算出完成的百分比,用百分比的值设置进度条. 一.MFC进度条 Progress Control 相关函数 1. create() --创建Prog ...

随机推荐

  1. 使用JavaScript的XMLHttpRequest发送POST、GET请求以及接收返回值

    使用XMLHttpRequest对象分为4部完成: 1.创建XMLHttpRequest组建 2.设置回调函数 3.初始化XMLHttpRequest组建 4.发送请求 实例代码: [javascri ...

  2. python的线上环境配置

    1.安装python 2.7   http://www.cnblogs.com/strikebone/p/3970512.html 2.安装相关前置工具  pip, Django http://www ...

  3. tensorflow ValueError: Cannot feed value of shape (5000,) for Tensor 'output:0', which has shape '(?, 10)'

    提供的训练数据和定义的模型之间的维度不对应. 在MNIST手写数字识别时,在 mnist = input_data.read_data_sets("MNIST_data/") 中, ...

  4. How to read very large text files fast

    Question Does anyone know the fastest way to read large text files (10Mb) into a string.Readln is ju ...

  5. 吴裕雄 数据挖掘与分析案例实战(14)——Kmeans聚类分析

    # 导入第三方包import pandas as pdimport numpy as np import matplotlib.pyplot as pltfrom sklearn.cluster im ...

  6. kubeadmin 部署(centos 7)

    安装指定版本docker:# yum list docker-ce --showduplicates | sort -ryum install docker-ce-18.06.1.ce-3.el7vi ...

  7. Consul Session

    consul馆提供session机制,可用于构建分布式锁. session作为节点,健康检查和key/value数据之间的绑定层. 它们旨在提供粒度锁定,并受到“The Chubby Lock Ser ...

  8. Dynomite 安装配置

    Dynomite受Dynamo白皮书的启发,是一种用于不同存储引擎和协议的轻量级的分布式的Dynamo层. 目前包括Redis和Memcached. Dynomite支持多数据中心复制,旨在实现高可用 ...

  9. 安装64位的oracle数据库, 使用自带的sqldeveloper

    个人感觉这个东西比plsql要好用, 虽然界面有点丑, 整个使用与plsql也没多大区别, 这里是他的位置C:\oracle_11g\product\11.2.0\dbhome_1\sqldevelo ...

  10. 警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:Weixin' did not find a matching property.

    警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclips ...