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

previous contents

Initialising Memories的更多相关文章

  1. (转) Written Memories: Understanding, Deriving and Extending the LSTM

    R2RT   Written Memories: Understanding, Deriving and Extending the LSTM Tue 26 July 2016 When I was ...

  2. 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 ...

  3. 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 ...

  4. PatentTips - Wear Leveling for Erasable Memories

    BACKGROUND Erasable memories may have erasable elements that can become unreliable after a predeterm ...

  5. 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 ...

  6. 杭电多校第四场 Problem K. Expression in Memories 思维模拟

    Problem K. Expression in Memories Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262 ...

  7. SDM439平台出现部分机型SD卡不能识别mmc1: error -110 whilst initialising SD card【学习笔记】

    SDM439平台出现部分机型SD卡不能识别mmc1: error -110 whilst initialising SD card 打印了如下的log: - ::>[ after ms - :: ...

  8. SD卡报错“error -110 whilst initialising SD card”

    目前开发遇到了某些SD卡和TI的SOC芯片的驱动不协调的地方,具体表现为: uboot 阶段初始化mmc dev 1 没有任何串口信息输出,无法读写mmc Kernel阶段报错”SD卡初始化失败 er ...

  9. About memories in ASIC FPGA

    1. Write first | Read First | No Change区别在于:en & wr的时候,dout是什么,三种case对应于: dout = din; dout = mem ...

随机推荐

  1. Net程序员学习Linux

    Net程序员学习Linux 本次知识点:Linux系统的多终端切换,linux下的用户,linux远程访问工具使用,linux下重要的目录,命令的组成,通配符,linux的路径问题,文件操作的综合运用 ...

  2. Spring系列

    Spring系列之访问数据库   阅读目录 一.概述 二.JDBC API的最佳实践 三.Spring对ORM的集成 回到顶部 一.概述 Spring的数据访问层是以统一的数据访问异常层体系为核心,结 ...

  3. Android中一个类实现的接口数不能超过七个

    近期一段时间,在开发Android应用程序的过程中,发现Android中一个类实现的接口数超过七个的时候,常常会出现超过第7个之后的接口不能正常使用.

  4. JS伪3D 图形透视效果

    本文地址:http://blog.csdn.net/ei__nino/article/details/9243331 本来是想实现多个圆片的透视效果,对于运算都是测试得出的.不是严谨的数学计算. 使用 ...

  5. js缓冲运动

    缓冲运动 现象:逐渐变慢,最后停止 原理:距离越远,速度越大 速度的计算方式: 1,速度由距离决定 2,速度=(目标值-当前值)/缩放系数 说明:速度为正负数时,也决定了物体移动的方向 示例:div缓 ...

  6. mybaits使用存储过程

    如何使用Mybaits调用数据库存储过程,按以下顺序Oracle案例库: 1.在数据库中创建以下存储过程: create or replace procedure pro_hello(p_result ...

  7. 怎么样cocos2d-x正在使用ECS(实体-包裹-制)建筑方法来开发一款游戏?

    简介 在我的博客,我翻译的几篇文章ECS文章.这些文章都是从Game Development站点.假设你对这个架构方式还不是非常了解的话.欢迎阅读理解 组件-实体-系统和实现 组件-实体-系统. 我发 ...

  8. TinyXml高速入口(一)

    笔者:朱金灿 来源:http://blog.csdn.net/clever101 对于xml文件,眼下我的工作仅仅是集中在配置文件和作为简单的信息文件来用.因此我不太喜欢使用msxml这样的重量级的x ...

  9. Shibboleth

    1.Shibboleth是一个针对SSO的开源项目.Shibboleth项目主要应用在校园内Web资源共享,以及校园间的应用系统的用户身份联合认证.

  10. Alamofire网络库进阶教程

    本章节由CocoaChina翻译组成员星夜暮晨(博客)翻译自raywenderlich:Intermediate Alamofire Tutorial,敬请勘误. 欢迎回到我们的 Alamofire ...