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. Ubuntu 组态 Tomcat而每天的错误解决

    统环境:Ubuntu 14.10 安装版本号:apache-tomcat-7.0.54.tar.gz 安装步骤: 1.下载 Tomcat 下载 apache-tomcat-7.0.54.tar.gz ...

  2. ES6箭头函数和它的作用域

    原文来自我的前端博客: http://www.hacke2.cn/arrow-functions-and-their-scope/ http://es6rocks.com/2014/10/arrow- ...

  3. mac_Mac环境下怎样编写HTML代码?

    在Mac环境下,使用默认的文本编辑器编写的HTML的源代码, 使用不同的浏览器打开后,依旧还是显示源代码 推荐使用UltraEdit,问题就迎刃而解了

  4. uva 10192 Vacation(最长公共子)

    uva 10192 Vacation The Problem You are planning to take some rest and to go out on vacation, but you ...

  5. [Windows Phone] 以多国语言做为开发前提 (1)

    原文:[Windows Phone] 以多国语言做为开发前提 (1) ? 前言 在先前 TechDays 2013 的课程 [开发 Windows Phone 商务应用程式就是这麽快] 中,其中一个部 ...

  6. svn加入新的文件夹

    方法一: 1.在远程server上生成新的文件夹 svn mkdir http://svn.xxx.com/svn/mobile/strategy/assistant/branches/talk -m ...

  7. c# 获取某个对象的[公有属性]的名称,类型,值

    /// <summary> /// 获取某个对象的[公有属性]的名称,类型,值 /// </summary> /// <typeparam name="T&qu ...

  8. IntelliJ IDEA 问题总结之中的一个 —— jar包、assets、maven、git

    因为工作须要,这几天開始弃用eclipse,换idea.用了几天,idea确实有些地方比較方便.可是麻烦也是不少.并且网上相应的资料并没有eclipse那么多,非常多都是自己琢磨解决的,所以想弄个帖子 ...

  9. 文件翻译002片:Process Monitor帮助文档(Part 2)

    [筛选亮点] Process Monitor提供了一些方式来配置筛选器和高亮显示.         筛选器的包括与排除 您能够在筛选器中指定事件的属性,这样就能够令Process Monitor仅显示 ...

  10. Mac OS X Yosemite安装Hadoop 2.6记录

    整个安装过程分为四部分: 一.  安装Homebrew 二.  ssh localhost 三. 安装Hadoop已经进行配置文件设置 (伪分布式) 四. 执行栗子 一. 安装Homebrew 採用H ...