RAM建模和初始化
2016-01-27 21:48
197 查看
冯诺依曼提出的存储计算,计算存储,因此,几乎所有的CPU和ASIC都会使用存储器,它们的类型很多,包括异步RAM、同步RAM、ZBT RAM、DDR DRAM、ROM等。由于大部分的异步RAM和SRAM都是晶圆代工厂定制的,一次需要修改成适合于FPGA结构的Verilog等效模型。FPGA的综合工具会将这些模型推译出FPGA芯片特有的嵌入式RAM。RAM的特点是一拍写入,两拍读出。所有RAM的设计都是在速度和容量直接的折中。
RAM的Verilog建模:
方式1:
方式2:
这两种方式建模的区别在于关键路径不同,方式1的关键路径在输入,方式2的关键路径在输出。
RAM的初始化
用Verilog建模的RAM可以采用$readmemh()和$readmemb()函数初始储存器。
参考文献:
[1]Evgeni Stavinov. 第53则 存储器的建模. FPGA 高手设计实战正经100则. 电子工业出版社. 2013, 10.
[2] Single Port RAM Synchronous Read/Write .
http://www.asic-world.com/examples/verilog/ram_sp_sr_sw.html. 2016,01,27.
[3] Dual Port RAM Synchronous Read/Write.
http://www.asic-world.com/examples/verilog/ram_dp_sr_sw.html . 2016,01,27.
[4] ROM, EPROM, EEPROM.
http://www.asic-world.com/examples/verilog/rom_eprom_eeprom.html
[5] Memory Modeling. http://www.asic-world.com/verilog/memory_fsm1.html
[6] $readmemb和$readmemh. http://lihaichuan.blog.51cto.com/498079/1198970
[7] opencores.org/or1k/OR1K:Community_Portal.
RAM的Verilog建模:
方式1:
////////////////////////////////////////////////////////////////////// //// Generic Single-Port Synchronous RAM //// ////////////////////////////////////////////////////////////////////// module or1200_spram_128x32( // Generic synchronous single-port RAM interface clk, rst, ce, we, oe, addr, di, doq ); // // Default address and data buses width // parameter aw = 7; parameter dw = 32; // // Generic synchronous single-port RAM interface // input clk; // Clock input rst; // Reset input ce; // Chip enable input input we; // Write enable input input oe; // Output enable input input [aw-1:0] addr; // address bus inputs input [dw-1:0] di; // input data bus output [dw-1:0] doq; // output data bus // // Generic single-port synchronous RAM model // Generic RAM's registers and wires // reg [dw-1:0] mem [(1<<aw)-1:0]; // RAM content reg [aw-1:0] addr_reg; // RAM address register // // Data output drivers // assign doq = (oe) ? mem[addr_reg] : {dw{1'b0}}; // // RAM address register // always @(posedge clk or posedge rst) if (rst == 1'b1) addr_reg <= {aw{1'b0}}; else if (ce) addr_reg <= addr; // // RAM write // always @(posedge clk) if (ce && we) mem[addr] <= di; endmodule
方式2:
module bram_inference( input clk, input [15:0] mem_din, input [9:0] mem_addr, input mem_we, output reg [15:0] mem_dout ); reg [15:0] ram [0:1023]; always (posedge clk) begin if(mem_we) ram[mem_addr] <= mem_din; mem_dout <= ram[mem_addr]; end endmodule
这两种方式建模的区别在于关键路径不同,方式1的关键路径在输入,方式2的关键路径在输出。
RAM的初始化
用Verilog建模的RAM可以采用$readmemh()和$readmemb()函数初始储存器。
参考文献:
[1]Evgeni Stavinov. 第53则 存储器的建模. FPGA 高手设计实战正经100则. 电子工业出版社. 2013, 10.
[2] Single Port RAM Synchronous Read/Write .
http://www.asic-world.com/examples/verilog/ram_sp_sr_sw.html. 2016,01,27.
[3] Dual Port RAM Synchronous Read/Write.
http://www.asic-world.com/examples/verilog/ram_dp_sr_sw.html . 2016,01,27.
[4] ROM, EPROM, EEPROM.
http://www.asic-world.com/examples/verilog/rom_eprom_eeprom.html
[5] Memory Modeling. http://www.asic-world.com/verilog/memory_fsm1.html
[6] $readmemb和$readmemh. http://lihaichuan.blog.51cto.com/498079/1198970
[7] opencores.org/or1k/OR1K:Community_Portal.
相关文章推荐
- R6010错误:Press Retry to debug the application
- centos7 防火墙firewalld
- mysql for linux 安装
- HDU 1198 - Farm Irrigation
- 16-1-27---JDBC复习(01)
- 安装python
- hdu5613 Baby Ming and Binary image
- 线程(thread)
- UISlider的基本使用方法
- 理解innodb的锁(record,gap,Next-Key lock)
- LeetCode83——Remove Duplicates from Sorted List
- hdu5612Baby Ming and Matrix games 搜索
- 浅析Sql Server参数化查询
- Android常用jar包中 StringUtils的说明
- IceGrid负载均衡部署 z
- JVM总结(二):JVM的内存分配策略
- 刷题
- 第十章数组和指针 p267
- 傅里叶级数的理解
- 用简单的C语言实现多任务轮流切换(模拟操作系统线程机制)