Verilog中的关于文件操作的函数和任务
来源:互联网 发布:springboot源码分析 编辑:程序博客网 时间:2024/05/24 06:51
2012-09-03 21:32:14
标签:verilog $fdisplay $fwrite
原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://lihaichuan.blog.51cto.com/498079/981084
$fopen(“filename”) 打开文件
$fdisplay(handle1,p1,p2, …pn) 写文件
$fclose(handle1) 关闭文件
$fdisplay(handle1,p1,p2, …pn) 写文件
$fclose(handle1) 关闭文件
1、打开文件
任务$fopen(“filename”)返回值为一个被称为多通道描述符的32位值,多通道描述符只有一位被设置成1。标准输出通道符其最低位设置成1,其余位为0,即00000000000000000000000000000001 ,即通道0用于在命令框中或者仿真软件中进行输出
标准输出一直是开放的。以后调用$fopen的每一次都打开一个新的通道,并且依次返回第1位、第2为等(有第0位)直到第30位,第31位保留,依次称为通道1,通道2等。
通道号与多通道符中被设置为1的位相对应。
如果不存在打开的文件,就会创建此文件。
如:
Integer handle1,handle2,handle3;
Initial begin
handle1=$fopen(“file1.txt”); //handle1的值为00000000000000000000000000000010
handle2=$fopen(“file2.txt”); //handle2的值为00000000000000000000000000000100
handle3=$fopen(“file3.txt”); //handle3的值为00000000000000000000000000001000
end
多通道描述符的优点可以有选择的同时写多个文件
2、写文件
系统任务 $fdisplay $fmonitor $fwrite $fstobe 都用于写文件。这些任务与常规系统任务$display $monitor 等类似,但是它们提供了写文件功能。
如:
Integer handle1,handle2,handle3;
Integer desc1,desc2,desc3;
Initial begin
handle1=$fopen(“file1.txt”); //handle1的值为00000000000000000000000000000010
handle2=$fopen(“file2.txt”); //handle2的值为00000000000000000000000000000100
handle3=$fopen(“file3.txt”); //handle3的值为00000000000000000000000000001000
desc1=handle1 | 1; //按位或,desc1=32’h0000_0003
$fdisplay(desc1,”handle1 ”);//将字符串 handle1写到file1.txt和标准输出中。
desc2=handle2 | handle 1; //按位或,desc1=32’h0000_0006
$fdisplay(desc1,”handle1 ”);//将字符串 handle1写到file1.txt和file1.txt中。
desc3=handle3;
$fdisplay(handle3,”handle1”);//将字符串 handle1写到file3.txt中。
end
3、关闭文件
如: $fclose(handle1); 文件一旦关闭就不能写入。
0 0
- Verilog中的关于文件操作的函数和任务
- Verilog中的函数和任务
- Verilog HDL的任务和函数
- Verilog HDL的任务和函数
- Verilog 中与文件操作相关的系统任务与系统函数
- verilog系统任务对文件的读写操作
- .verilog系统任务读写文件$fopen和$fdisplay的使用
- [verilog读书笔记]8.任务和函数
- Verilog中的$display和$write任务
- verilog 中任务与函数的区别
- Verilog中testbench的设计,文件读取和写入操作
- Verilog中任务(task)和函数(function)
- Verilog系统任务和函数(Tasks and Functions)
- verilog中几种常用的位操作函数
- 关于文件操作中的close()和flush()
- Verilog中的函数
- verilog中的repeat的用法和例子
- verilog中的while的用法和例子
- 【工程数学】若干种解高次方程的算法
- flas和js的交互(聊天室的另一种解决方案)
- Docker安全性(一)——Docker容器真的安全吗?
- libstdc++.so.6: cannot open shared object file: No such file or directory
- git报错:error: The requested URL returned error: 403 Forbidden while accessing https://github.com/summ
- Verilog中的关于文件操作的函数和任务
- java多线程使用集合那点事
- app调试笔记
- 上传文件之获取拍照照片和本地图库
- Android高手进阶——Adapter深入理解与优化
- 计算机实际上是如何工作的
- WebService详解
- 轮廓跟踪
- MATLAB常用函数