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 ...
随机推荐
- 使用Xamarin在Visual Studio中开发Android应用
原文:使用Xamarin在Visual Studio中开发Android应用 本文使用的环境是Windows 8 Visual Studio 2012.2 1.下载Xamarin http://xam ...
- 【C语言探险】 第四课的第二部分:串
内容简单介绍 1.课程大纲 2.第二部分第四课: 字符串 3.第二部分第五课预告: 预处理 课程大纲 我们的课程分为四大部分,每个部分结束后都会有练习题,并会发布答案.还会带大家用C语言编写三个游戏. ...
- Drupal 7 模 .info 文件描述
Drupal使用.info文件以节省话题(theme)和模块(modules)基本数据(metadata). 编码:推荐使用UTF-8.这是一个没有BOM(Byte Order Mark). 下面是一 ...
- Add/Remove listview web part in publish site via powershell
1. Here is the code: Add WebPart in Publish Site Example : AddWebPartPublish http://localhost " ...
- Java贪吃蛇游戏
package snake.game; import java.awt.CardLayout; import java.awt.Color; import java.awt.Graphics; i ...
- Java面试题集(136-150)
摘要:目,尽管仅仅有15道题目.可是包括的信息量还是非常大的,非常多题目背后的解题思路和算法是非常值得玩味的. 136.给出以下的二叉树先序.中序.后序遍历的序列? 答:先序序列:ABDEGHCF.中 ...
- 牟大哥:《App自我促销》连载2
直立人迁移走
[谋哥每天一干货,第六十九篇] 前篇说到声音在远古时代.是一个奇妙的东西,它可以非常快地把信息传播到其它地方,突破了短距离. 然而能人的后代直立人学会了直立行走,他们開始走出非洲,到达遥远的中东.中国 ...
- 【Python项目】配合爱漫画爬取漫画脚本而设计的GUI漫画阅读器 (一)
博客园的第一个坑,想想都有点小激动 =3= 首先是那个爬虫的地址: [原创]最近写的一个比较hack的小爬虫 选择工具: 以前用过Qt,那么选pyqt4也就是情理之中了. 明确需求: 0.首先,要读取 ...
- 数据结构之计算器的实现(JAVA)(四)
原理: 1.将中序表达式变化兴许表达式 2.当前字符为数字,将该数字放入栈中 3.当前字符为操作符,从栈中取出两个树,依据操作符来运算,将运算结果放入到栈中 4.反复,直到将字符操作完.此时栈中仅仅剩 ...
- unity3d简单的相机跟随及视野旋转缩放
1.实现相机跟随主角运动 一种简单的方法是把Camera直接拖到Player下面作为Player的子物体,另一种方法是取得Camera与Player的偏移向量,并据此设置Camera位置,便能实现简单 ...