zoukankan      html  css  js  c++  java
  • Verilog之$sreadmemb

    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. 

     1 module testmemory;
     2     reg [7:0] memory [9:0];
     3     integer   index;
     4 
     5     initial 
     6    begin
     7         $readmemb("mem.dat", memory);
     8         
     9         for(index = 0; index < 10; index = index + 1)
    10         $display("memory[%d] = %b", index[4:0], memory[index]);
    11      end
    12 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

     

  • 相关阅读:
    数据库表结构变动发邮件脚本
    .net程序打包部署
    无法登陆GitHub解决方法
    netbeans 打包生成 jar
    第一次值班
    RHEL6 纯命令行文本界面下安装桌面
    C语言中格式化输出,四舍五入类型问题
    I'm up to my ears
    How to boot ubuntu in text mode instead of graphical(X) mode
    the IP routing table under linux@school
  • 原文地址:https://www.cnblogs.com/mengdie/p/4333169.html
Copyright © 2011-2022 走看看