利用VHDL读写file文件
library ieee;
use std.textio.all;
use ieee.std_logic_textio.all;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity testin is
end entity testin;
architecture rtl of testin is
begin
process is
file file_out1,filein: text; --定义text类型的文件句柄;
variable fstatus1,fstatus2:FILE_OPEN_STATUS; --定义文件状态指示变量;
variable count:integer:=5; --定义integer型写入数据;
variable stringdata:string(5 downto 1):="whwnh";--定义string型写入数据;
variable vectordata:bit_vector(5 downto 0):="001000";--定义bit_vector型的写入数据;
variable value:std_logic_vector(3 downto 0):="1111";--定义std_logic_vector型的写入数据;
variable BUF,BUF1:LINE;
begin
file_open(fstatus1,file_out1,"datain.txt",write_mode); --打开文件“datain.txt"
write(file_out1,string'("the first parameter is=")); --通过write()函数直接向文件中写入对应类型数据。
readline(input,buf); --从控制台输入字符串输入文件;
write(buf,count);
writeline(file_out1,buf); --向文件中输入integer类型
wait for 20 ns;
write(buf,string'("the second parameter is="));
write(buf,value);
writeline(file_out1,buf);
wait for 20 ns; --向文件中输入std_logic_vector类型数据;
write(buf,string'("the third parameter is="));
write(buf,vectordata);
writeline(file_out1,buf);
wait for 20 ns; --向文件中输入bit_vector类型数据;
write(buf,string'("the forth parameter is="));
write(buf,stringdata); --向文件中输入string类型数据。
writeline(file_out1,buf);
write(file_out1,string'("end of file"));
file_close(file_out1);
wait for 100 ns; --关闭文件
file_open(fstatus1,file_out1,"datain.txt",read_mode); --以读取模式打开文件
readline(file_out1,buf); --读取文件数据并输出到控制台界面。
writeline(output,buf);
file_close(file_out1);
wait for 100 ns;
file_open(fstatus1,filein,"STD_INPUT",read_mode); --以控制台作为文件输入
file_open(fstatus2,file_out1,"STD_OUTPUT",write_mode); --以控制台作为文件输出
readline(filein,BUF);
writeline(file_out1,BUF);
wait;
end process;
end rtl;
利用VHDL读写file文件的更多相关文章
- (数据科学学习手札63)利用pandas读写HDF5文件
一.简介 HDF5(Hierarchical Data Formal)是用于存储大规模数值数据的较为理想的存储格式,文件后缀名为h5,存储读取速度非常快,且可在文件内部按照明确的层次存储数据,同一个H ...
- 利用java读写Excel文件
一.读取Excel文件内容 java 代码 public static String readExcel(File file){ StringBuffer sb = new StringBuffer( ...
- 利用Lua读写本地文件
缘由 今天在使用Lua编写脚本时,需要用到读写文件的操作,很久没有使用Lua了,特写下此文来备忘一下. 简介 Lua对文件的操作与C对文件的操作基本一致,不管是参数还是方法.Lua中可以直接通过全局方 ...
- C# WPF 利用NPOI读写Excel文件
https://blog.csdn.net/a312024054/article/details/70139172 [各种样式] https://www.cnblogs.com/xwgli/archi ...
- c# 利用动态库DllImport("kernel32")读写ini文件(提供Dmo下载)
c# 利用动态库DllImport("kernel32")读写ini文件 自从读了设计模式,真的会改变一个程序员的习惯.我觉得嘛,经验也可以从一个人的习惯看得出来,看他的代码编写习 ...
- 利用JavaCSV API来读写csv文件
http://blog.csdn.net/loongshawn/article/details/53423121 http://javacsv.sourceforge.net/ 转载请注明来源-作者@ ...
- java中的File文件读写操作
之前有好几次碰到文件操作方面的问题,大都由于时间太赶而没有好好花时间去细致的研究研究.每次都是在百度或者博客或者论坛里面參照着大牛们写的步骤照搬过来,之后再次碰到又忘记了.刚好今天比較清闲.于是就在网 ...
- 30天C#基础巩固------集合,File(文件操作 ),Encoding处理字符集
一:泛型 关于泛型我自己也不是很好的理解,但是具体的运用还是可以的,可以这样的理解,我们定义一个数组,但是不知道将来它是保存什么类型的值,很是矛盾,这个时候泛型就出现了,它可以解决这个场景,li ...
- 利用Delphi的File Of Type创建并管理属于你自己的数据库
http://www.360doc.com/content/16/1128/19/28222077_610249962.shtml 利用Delphi的File Of Type创建并管理属于你自己的数据 ...
随机推荐
- UIScrollView基本使用
- (void)viewDidLoad { [super viewDidLoad]; scrollView = [[UIScrollView alloc] initWithFrame:CGRectMa ...
- OC——NSString和NSMutableString
int main(int argc, const char * argv[]) { @autoreleasepool { //----------------NSString------------- ...
- java集合类遍历删除方法测试以及使用场景记录
package test0; import java.util.List; import java.util.Map; import java.util.Map.Entry; import java. ...
- Python Challenge
0. 2的38次方 print 2**38 ##apply the result to the url 1. 看图是要right shift两位, 切片即可. import string intab ...
- 一维树状数组(HD1166)
#define _CRT_SECURE_NO_WARNINGS #include<iostream> #include<string.h> using namespace st ...
- Amazon MWS 上传数据 (二) 构造请求
上一篇文章提到了Amazon 上传数据有三个步骤,但是每个步骤都需要构造服务和构造请求,服务是一样的,请求各不相同:这个很容易理解,这三个步骤都需要和Amazon服务器交互,所以他们的服务构造是一样的 ...
- SQL Server 改变数据库的名字
方法 1: alter database modiry name = new_database_name; ---------------------------------------------- ...
- LINUX用户管理——/etc/passwd文件详解
输入vi /etc/passwd 可以查看此文件的内容 .本机内容如下: [root@localhost ~]# vi /etc/passwdroot:x:0:0:root:/root:/bin/ ...
- jQuery学习-事件之绑定事件(三)
在上一篇<jQuery学习-事件之绑定事件(二)>我们了解了jQuery的dispatch方法,今天我们来学习下handlers 方法: handlers: function( event ...
- Linux下对字符串进行MD5加密
Linux下对字符串进行MD5加密 比如要用MD5在linux下加密字符串“test",可以使用命令:$ echo -n test|md5sum098f6bcd4621d373cade4e8 ...