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 ...
随机推荐
- meta标签详解:源http://blog.csdn.net/kongjiea/article/details/17092413
一.大众机型常用meta标签name的设置 1.name之viewport <meta name="viewport" content=""> 说明 ...
- JBOSS EAP6.2.0的下载安装、环境变量配置以及部署
JBOSS EAP6.2.0的下载安装.环境变量配置以及部署 JBoss是纯Java的EJB(企业JavaBean)server. 第一步:下载安装 1.进入官网http://www.jboss.or ...
- JQuery打印
jquery.jqprint-0.3.js JQuery提供的局部打印功能: <input type="button" value="打印" onclic ...
- 【原创】leetCodeOj --- Sliding Window Maximum 解题报告
天,这题我已经没有底气高呼“水”了... 题目的地址: https://leetcode.com/problems/sliding-window-maximum/ 题目内容: Given an arr ...
- 玩转html5(五)---月球绕着地球转,地球绕着太阳转(canvas实现,同样可以动哦)
关于运动速度的参数与真实速度有点差距,大家可以自行调整 <!DOCTYPE html> <html> <head> <meta http-equiv=&quo ...
- 设计师给了px显着的单位,Android要设置多少开发商dip、dp、sp?
此链接 http://blog.csdn.net/xiaodongrush/article/details/29560431 1. 要开发一款Android APP,设计师和开发要约定哪些事情? ...
- C++11:强类型枚举(enum)
// C++11之前的enum类型是继承C的,不温不火: // C++11对enum动刀了,加强了类型检查,推出强类型enum类型,眼前一亮 // 使用过QT 的都知道,早就应该这么做了,用的非常爽! ...
- [Linux]scp 命令远程复制
这些天来干预系统之前没有接触,建立使用用途良好的发展环境 scp命令,那么如何使用查询以下信息. scp是secure copy的缩写.主要用来linux系统之间的文件和文件夹的远程拷贝 能够非常ea ...
- 在Apk应用程序内,查找某个Activity。
转载请注明出处:http://blog.csdn.net/droyon/article/details/39933677 Intent intent = new Intent(Intent.ACTIO ...
- hdu 5091 Beam Cannon(扫描线段树)
题目链接:hdu 5091 Beam Cannon 题目大意:给定N个点,如今要有一个W∗H的矩形,问说最多能圈住多少个点. 解题思路:线段的扫描线,如果有点(x,y),那么(x,y)~(x+W,y+ ...