首页 > 其他 > 详细

Verilog之$sreadmemb

时间:2015-03-12 19:09:37      阅读:297      评论:0      收藏:0      [点我收藏+]

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 [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

 

Verilog之$sreadmemb

原文:http://www.cnblogs.com/mengdie/p/4333169.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!