1  Memories 

 Memories file format is shown below, the address is specified as @ <address> 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.

2  Syntax:

 $readmemb ("<file_name>", <memory_name>"); 
 $readmemb ("<file_name>", <memory_name>, memory_start"); 
 $readmemb ("<file_name>", <memory_name>, memory_start, memory_finish");

 The memory_start and memory_finish are optional.

3   Example

 Now that a memory file exists to access it, it has to be initialised for memory reading.

 module testmemory;
reg [:] memory [:];
integer index; initial
   begin
$readmemb("mem.dat", memory); for(index = ; index < ; index = index + )
$display("memory[%d] = %b", index[:], 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

Verilog之$sreadmemb的更多相关文章

  1. Verilog学习笔记简单功能实现(二)...............全加器

    先以一位全加器为例:Xi.Yi代表两个加数,Cin是地位进位信号,Cout是向高位的进位信号.列表有:   Xi     Yi    Cin Sum Cout 0 0 0 0 0 0 0 1 1 0 ...

  2. Verilog HDL模型的不同抽象级别

    所谓不同的抽象类别,实际上是指同一个物理电路,可以在不同层次上用Verilog语言来描述.如果只从行为功能的角度来描述某一电路模块,就称作行为模块.如果从电路结构的角度来描述该电路模块,就称作结构模块 ...

  3. Verilog学习笔记基本语法篇(十二)········ 编译预处理

    h Verilog HDL语言和C语言一样也提供编译预处理的功能.在Verilog中为了和一般的语句相区别,这些预处理语句以符号"`"开头,注意,这个字符位于主键盘的左上角,其对应 ...

  4. Verilog学习笔记基本语法篇(十一)········ 常用系统函数

    1)系统任务:$monitor   格式: $monitor(p1,p2,p3...pn); $monitor; $monitoron; $monitoroff; 任务$monitor提供了监控输出列 ...

  5. FPGA作为从机与STM32进行SPI协议通信---Verilog实现 [转]

    一.SPI协议简要介绍 SPI,是英语Serial Peripheral Interface的缩写,顾名思义就是串行外围设备接口.SPI,是一种高速的,全双工,同步的通信总线,并且在芯片的管脚上只占用 ...

  6. 基于Verilog HDL整数乘法器设计与仿真验证

    基于Verilog HDL整数乘法器设计与仿真验证 1.预备知识 整数分为短整数,中整数,长整数,本文只涉及到短整数.短整数:占用一个字节空间,8位,其中最高位为符号位(最高位为1表示为负数,最高位为 ...

  7. system verilog中的跳转操作

    在verilog中,使用disable声明来从执行流程中的某一点跳转到另一点.特别地,disable声明使执行流程跳转到标注名字的声明组末尾,或者一个任务的末尾. verilog中的disable命令 ...

  8. system verilog中的类型转换(type casting)、位宽转换(size casting)和符号转换(sign casting)

    类型转换 verilog中,任何类型的任何数值都用来给任何类型赋值.verilog使用赋值语句自动将一种类型的数值转换为另一种类型. 例如,当一个wire类型赋值给一个reg类型的变量时,wire类型 ...

  9. 一段比较有意思的代码——介绍system verilog中的新增幅值语句

    system verilog中新加了很多幅值语句,虽然都只适用于阻塞幅值,但是在某些场合中非常实用. 下面是一段有意思的代码,覆盖了一些用法. package definitions; typedef ...

随机推荐

  1. poj 2763(LCA + dfs序 +树状数组)

    算是模板题了 可以用dfs序维护点到根的距离 注意些LCA的时候遇到MAXM,要-1 #include<cstdio> #include<algorithm> #include ...

  2. Codeforces 899C - Dividing the numbers

    传送门:http://codeforces.com/contest/899/problem/C 本题是一个数学问题——集合划分. 将集合{1,2,...,n}划分成两个集合,使得两个集合的元素之和的绝 ...

  3. 【习题 4-7 UVA - 509】RAID!

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 如果一行里面某位有>1个x 那么是invalid的. 没有x的话. 可以分析以下(设输入的标准Even为0,然后Odd为1) ...

  4. mybatis使用-helloword(一)

    前言 首先感谢https://my.oschina.net/zudajun/blog/665956(jd上也出书了貌似)  这位作者.让自己能系统的看完和理解第一个框架的源码(其实我反复看了4遍以上, ...

  5. Spring Boot-springbootHelloword(一)

    什么是springboot sprng家族一个全新的框架  简化我们应用程序的创建和开发的过程,使用默认配置简化了我们以前传统的配置 springboot的特性     能够快速创建spring程序 ...

  6. 洛谷 P2813 母舰

    题目描述 在小A的星际大战游戏中,一艘强力的母舰往往决定了一场战争的胜负.一艘母舰的攻击力是普通的MA(Mobile Armor)无法比较的. 对于一艘母舰而言,它是由若干个攻击系统和若干个防御系统组 ...

  7. Ajax json 数据格式

    ajax : 是么是同步 什么事异步 同步现象:客户端发送请求到服务端,当服务端返回响应之前,客户端都处于等待卡死状态. 异步现象:客户端发送请求到服务器端,无论服务器是否返回,客户端都可以随意做其他 ...

  8. HDU 5046

    同样是二分+DLX即可. #include <iostream> #include <cstdio> #include <cstring> #include < ...

  9. 手动搭建HTTP下载站点

    手动搭建HTTP下载站点 index.jsp <%--Listfile.jsp--%> <%@ page import="java.io.File,java.text.Si ...

  10. Ruby 教程

    Ruby 教程 http://www.runoob.com/ruby/ruby-tutorial.html http://guides.rubyonrails.org/getting_started. ...