Initialising Memories
The file_name and memory_nameare memory_start and memory_finish are optional, it missed out they default to the start index of the named memory and the end of the named memory respectively.
Memories can be stored in a file in the format shown below, the address is specified as @< address>, where the address is in hexadecimal.
@003
00000011
00000100
00000101
00000110
00000111
00001000
00001001
With the above file it can be seen if the memory is large it would become very tedious to work out the address of a specific byte, so it is normally a good idea to use milestones along the memory file, so a larger file may look something like the following:
@003
00000011
00000100
00000101
@006
00000110
00000111
@008
00001000
00001001
or if the data is contiguous, omit the address entirely.
Now that a memory file exists to access it, it has to be initialised for memory reading. This can be done by the following.
module testmemory;
reg [7:0] memory [9:0];
integer index; initial begin
$readmemb("mem.dat", memory); for(index = 0; index < 10; index = index + 1)
$display("memory[%d] = %b", index[4:0], memory[index]);
end
endmodule // testmemory
with the file mem.data as
1000_0001
1000_0010
0000_0000
0000_0001
0000_0010
0000_0011
0000_0100
0000_0101
0000_0110
0000_0000
EXERCISE
Store the above data in a file and run the above programme
Consider and understand the following code (run it to check):
module fileDemo;
integer handle, channels, index, rand;
reg [7:0] memory [15:0];
initial begin
handle = $fopen("mem.dat");
channels = handle | 1;
$display("Generating contents of file mem.dat");
$fdisplay(channels, "@2");
for(index = 0; index < 14; index = index + 1) begin
rand = $random;
$fdisplay(channels, "%b", rand[12:5]);
end
$fclose(handle);
$readmemb("mem.dat", memory);
$display("\nContents of memory array");
for(index = 0; index < 16; index = index + 1)
$displayb(memory[index]);
end
endmodule // fileDemo
Initialising Memories的更多相关文章
- (转) Written Memories: Understanding, Deriving and Extending the LSTM
R2RT Written Memories: Understanding, Deriving and Extending the LSTM Tue 26 July 2016 When I was ...
- 2018 Multi-University Training Contest 4 Problem K. Expression in Memories 【模拟】
任意门:http://acm.hdu.edu.cn/showproblem.php?pid=6342 Problem K. Expression in Memories Time Limit: 200 ...
- HDU6342-2018ACM暑假多校联合训练4-1011-Problem K. Expression in Memories
Problem K. Expression in Memories Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262 ...
- PatentTips - Wear Leveling for Erasable Memories
BACKGROUND Erasable memories may have erasable elements that can become unreliable after a predeterm ...
- Multi-processor having shared memory, private cache memories, and invalidate queues having valid bits and flush bits for serializing transactions
Multi-processor systems are often implemented using a common system bus as the communication mechani ...
- 杭电多校第四场 Problem K. Expression in Memories 思维模拟
Problem K. Expression in Memories Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262 ...
- SDM439平台出现部分机型SD卡不能识别mmc1: error -110 whilst initialising SD card【学习笔记】
SDM439平台出现部分机型SD卡不能识别mmc1: error -110 whilst initialising SD card 打印了如下的log: - ::>[ after ms - :: ...
- SD卡报错“error -110 whilst initialising SD card”
目前开发遇到了某些SD卡和TI的SOC芯片的驱动不协调的地方,具体表现为: uboot 阶段初始化mmc dev 1 没有任何串口信息输出,无法读写mmc Kernel阶段报错”SD卡初始化失败 er ...
- About memories in ASIC FPGA
1. Write first | Read First | No Change区别在于:en & wr的时候,dout是什么,三种case对应于: dout = din; dout = mem ...
随机推荐
- ubuntu上搭建工作环境
版本号ubuntu desktop, v12.4, v13.10. 长处: 1)绚丽易用的可视化环境: 2)丰富的可用package.在这点上比centos强太多.后者更新较慢: 不足: 1)在笔记本 ...
- adodb.RecordSet的属性和方法
为了更精确地跟踪数据,要用RecordSet组件创建包括数据的游标,游标就是储存在内存中的数据: rs = Server.CreateObject("ADODB.RecordSet" ...
- uva 10192 Vacation(最长公共子)
uva 10192 Vacation The Problem You are planning to take some rest and to go out on vacation, but you ...
- Linux新手命令
给老婆写了一份速成培训教材--最经常使用的命令及解释.当然每一个人工作内容不同,经常使用命令也不同,这仅仅是我的个人经验,并且要考虑到接受者的基础. ls:列出文件夹下的内容,类似于dos下的dir. ...
- 安卓的sqlite增删改
基于安卓的sqlite增删改,笔记学习: 1.使用LinearLayout 布局生成,增删改的页面如图 代码布局如下: <LinearLayout xmlns:android="htt ...
- FTP文件操作之下载文件
前面写了采用ftp上传文件,有了上传怎么能够没有下载呢?如果只有上传没有下载,那上传了也没啥用了.所以今天就跟大家一起学习学习使用ftp下载文件. 知道了怎么上传,那么下载也就变得很简单了,上传是把文 ...
- 安全扫描工具-AppScan
AppScan主要作用是对页面进行安全扫描的工具
- Linux 编程学习笔记----过程管理和项目发展(在)
转载请注明出处,http://blog.csdn.net/suool/article/details/38406211,谢谢. Linux进程存储结构和进程结构 可运行文件结构 例如以下图: 能够看出 ...
- mysql语句在node.js中的写法
总结一下mysql语句在node.js中的各种写法,参考了npm网站mysql模块给的实例. 查询 select //1 db.query('select * from tuanshang_users ...
- NServiceBus开发
使用NServiceBus开发分布式应用 系列主题:基于消息的软件架构模型演变 NServiceBus 是一个.Net平台下开源的消息服务框架,这类产品有时也被称作ESB(Enterprise Ser ...