一、综述

参考ug473.pdf

常用Memory 资源:

在IP核中,Block memory(distributed memory为CLB中的资源):

通常选用Native,而不用AXI接口:

Block RAM可配置单端口RAM、伪双端口RAM、双端口RAM、单端口ROM、双端口ROM、FIFO。

各个模式调用时可承受的最高频率,参考pg058.pdf

二、主要功能

学习资源: http://www.asic-world.com/examples/verilog/memories.html

  A-RAM/ROM

主要功能:

每一个Block RAM都可配置为1个36Kb的BRAM或1个36Kb的FIFO;同时也可以将其配置为2个单独的18Kb的BRAM或1个18KbBRAM + 1个18Kb的BRAM。

为什么是18k而不是16k(2的整次幂)?因为每8bit一个校验位。2*8 + 2 =18bit。

结论:无论是单端口RAM、伪双端口RAM还是双端口RAM,他们都只有一块Memory

Single-port RAM:

同步示例:

module ram_sp_sr_sw (
clk , // Clock Input
address , // Address Input
data , // Data bi-directional
cs , // Chip Select
we , // Write Enable/Read Enable
oe // Output Enable
); parameter DATA_WIDTH = 8 ;
parameter ADDR_WIDTH = 8 ;
parameter RAM_DEPTH = 1 << ADDR_WIDTH; //--------------Input Ports-----------------------
input clk ;
input [ADDR_WIDTH-1:0] address ;
input cs ;
input we ;
input oe ; //--------------Inout Ports-----------------------
inout [DATA_WIDTH-1:0] data ; //--------------Internal variables----------------
reg [DATA_WIDTH-1:0] data_out ;
reg [DATA_WIDTH-1:0] mem [0:RAM_DEPTH-1];
reg oe_r; //--------------Code Starts Here------------------ // Tri-State Buffer control
// output : When we = 0, oe = 1, cs = 1
assign data = (cs && oe && !we) ? data_out : 8'bz; // Memory Write Block
// Write Operation : When we = 1, cs = 1
always @ (posedge clk)
begin : MEM_WRITE
if ( cs && we ) begin
mem[address] = data;
end
end // Memory Read Block
// Read Operation : When we = 0, oe = 1, cs = 1
always @ (posedge clk)
begin : MEM_READ
if (cs && !we && oe) begin
data_out = mem[address];
oe_r = 1;
end else begin
oe_r = 0;
end
end endmodule // End of Module ram_sp_sr_sw

异步(异步读、同步写)示例:

module ram_sp_ar_sw (
clk , // Clock Input
address , // Address Input
data , // Data bi-directional
cs , // Chip Select
we , // Write Enable/Read Enable
oe // Output Enable
); parameter DATA_WIDTH = 8 ;
parameter ADDR_WIDTH = 8 ;
parameter RAM_DEPTH = 1 << ADDR_WIDTH; //--------------Input Ports-----------------------
input clk ;
input [ADDR_WIDTH-1:0] address ;
input cs ;
input we ;
input oe ; //--------------Inout Ports-----------------------
inout [DATA_WIDTH-1:0] data ; //--------------Internal variables----------------
reg [DATA_WIDTH-1:0] data_out ;
reg [DATA_WIDTH-1:0] mem [0:RAM_DEPTH-1]; //--------------Code Starts Here------------------ // Tri-State Buffer control
// output : When we = 0, oe = 1, cs = 1
assign data = (cs && oe && !we) ? data_out : 8'bz; // Memory Write Block
// Write Operation : When we = 1, cs = 1
always @ (posedge clk)
begin : MEM_WRITE
if ( cs && we ) begin
mem[address] = data;
end
end // Memory Read Block
// Read Operation : When we = 0, oe = 1, cs = 1
always @ (address or cs or we or oe)
begin : MEM_READ
if (cs && !we && oe) begin
data_out = mem[address];
end
end endmodule // End of Module ram_sp_ar_sw

  对应电路:

可以看出2^8 = 256由4个64拼接拼接而成:

这里其实调用的是CLB中SliceM下的Distributed RAM资源:

  B-FIFO

FIFO的能力:

FIFO的IP核使用,具体可参考:pg057.pdf

FIFO可调用shift reg、distributed RAM、Block RAM、BulitIn FIFO,关于使用,xilinx论坛有相关说法:

Q:

From PG057 (Fifo generator) I understand FIFO's can be implemented in 4 ways, using :

  • block RAM
  • distributed RAM
  • shift register
  • built-in FIFO  (using FIFO18 / FIFO36)

is there any simple document / app note / overview describing on what basis you typically decide between the 4  implementations. What are the main tradeoffs, advantages, ... of each underlying memory type used?

I can imagine a few, but not sure if these are correct and complete :

  • block RAM is interesting for large, deep fifo's
  • distributed RAM is interesting for smaller fifo's
  • shift register is interesting for smaller fifo's, with short word width
  • built-in FIFO allow for the fastest fifo's

but that's just intuition ... so any corrections or further insights are welcome here!

A:

Its based your application , requirement and available resources in your target FPGA. The most of the points you mention correct. I would recommend you to refer target FPGA resource guide LUTs have lowest access time, FIFO18/FIFO36 good timing performance but require effort in design migration, BRAM very good for scalable memory requirement . You can also check about URAM/ultraram available in ultrascale devices

三、IP核调用

  A-simple dual RAM 

参考IP_bram笔记

这里涉及到位宽的计算,以6通道,160MHz采样率,12bit有效位AD举例,现在需要转化为:240MHz的FPGA工作时钟。

12bit*6*160/240 = 48bit

位宽由12*6 = 72bit转化为48bit,:

  • Port-A为写数据,width:位宽12*6 = 72bit,depth = 160
  • Port-B为读数据,width:48bit,depth = 240

但Port-B的width只能是:72bit/(2^n),n = 0, ±1, ±2, ...,因此通常都是二次转化

Step1:72*160 = 48*240 < x * 240,x = 72*2^n >48,此处n = 0;x工作在240MHz。

Step2:x * M = 48 * N,M、N都是整数。M = 1,N = 2,完成转化。

总结步骤:160Mhz 72bit转化为 240Mhz 72bit;240Mhz写1拍(M = 1),每2(N = 2)拍读取一次数据。
IP核调用格式:
按输入端口,调用IP即可
bm_tb bram_int(
.addra(addra),
...
)
未勾选primitive output register:

勾选primitive output register:

可见该选项延迟了1拍

  B-FIFO

主要参考:

关于IP核参数设置,可参考FIFO generator笔记

与BRAM同样的例子,很多时候数据时钟域转换用dual-port RAM而不用FIFO,说是前者含地址,存在时延变量取数方便,但改为FIFO实现其实也可以,后者含有计数功能,同样可以进行定位。

从读使能给出,到数据输出,经过6个周期,计算:

基础003_V7-Memory Resources的更多相关文章

  1. Understanding Virtual Memory

    Understanding Virtual Memory by Norm Murray and Neil Horman Introduction Definitions The Life of a P ...

  2. DTrace to Troubleshoot Java Native Memory Problems

    How to Use DTrace to Troubleshoot Java Native Memory Problems on Oracle Solaris 11 Hands-On Labs of ...

  3. Spring Boot Memory Performance

    The Performance Zone is brought to you in partnership with New Relic. Quickly learn how to use Docke ...

  4. 再谈.net的堆和栈---.NET Memory Management Basics

    .NET Memory Management Basics .NET memory management is designed so that the programmer is freed fro ...

  5. Allowing GPU memory growth

    By default, TensorFlow maps nearly all of the GPU memory of all GPUs (subject to CUDA_VISIBLE_DEVICE ...

  6. CUDA ---- Memory Model

    Memory kernel性能高低是不能单纯的从warp的执行上来解释的.比如之前博文涉及到的,将block的维度设置为warp大小的一半会导致load efficiency降低,这个问题无法用war ...

  7. Memory Leak Detection in C++

    原文链接:http://www.linuxjournal.com/article/6556?page=0,0 An earlier article [“Memory Leak Detection in ...

  8. System and method for parallel execution of memory transactions using multiple memory models, including SSO, TSO, PSO and RMO

    A data processor supports the use of multiple memory models by computer programs. At a device extern ...

  9. Move resources allocated using unmanaged interface to managed devm interface

    转载:http://blog.csdn.net/swingboard/article/details/27207497   So today let’s talk about devm functio ...

  10. Find out when memory leaks are a concern and how to prevent them

    Handling memory leaks in Java programs Find out when memory leaks are a concern and how to prevent t ...

随机推荐

  1. JSP与Servlet之间的关系事例说明

    Servlet Servlet 没有 main 方法,不能够独立的运行,它的运行需要容器的支持,Tomcat 是最常用的 JSP/Servlet 容器.Servlet 运行在 Servlet 容器中, ...

  2. Spark的运行模式(1)--Local和Standalone

    Spark一共有5种运行模式:Local,Standalone,Yarn-Cluster,Yarn-Client和Mesos. 1. Local Local模式即单机模式,如果在命令语句中不加任何配置 ...

  3. SpringMVC学习笔记一:基本概念,执行流程与开发步骤

    转载请注明原文地址:http://www.cnblogs.com/ygj0930/p/6831328.html  一:基本概念 DispatcherServlet:前端控制器,负责把请求分发处理. H ...

  4. mingw 构建 Geos

    简述 在做某个小程序时候用到了QT,而用的Qt是mingw版本的,所以使用mingw构建了一下geos库. 1.准备工作 首先需要先安装好mingw,这里直接使用http://www.mingw-w6 ...

  5. 转 Linux下Nginx+PHP+MySQL配置

    Nginx是一个高性能的HTTP和反向代理服务器,同时还是IMAP/POP3/SMTP代理服务器,该程序由俄罗斯Rambler.ru 站点开发,Nginx因为性能稳定.低系统资源消耗而闻名,近几年Ng ...

  6. Fix: Windows Script Host access is disabled on this machine

    If you receive this Windows Script Host access is disabled on this machine, Contact your administrat ...

  7. 信息列表中的ContentObserver、CONTENT_URI等

    1. 注册ContentObserver时Sms.Inbox.CONTENT_URI应改成Sms.CONTENT_URI. getContentResolver().registerContentOb ...

  8. ios中Pldatabase的用法

    将PLDATABASE加入到工程 下载PLDatabase 的dmg文件 将PLDatabase的framework复制到工程根目录在工程中加入该framework使用该framework进行数据库操 ...

  9. web安全之渗透测试

    本次渗透测试使用工具列表如下: 漏洞扫描器 (主机/Web) 绿盟RAS漏洞扫描器 商用 端口扫描器 NMAP 开源 网络抓包 Fiddler 开源 暴力破解工具 Hydra 开源 数据库注入工具 S ...

  10. NYOJ----蛇形填数

    蛇形填数 时间限制:3000 ms  |  内存限制:65535 KB 难度:3   描述 在n*n方陈里填入1,2,...,n*n,要求填成蛇形.例如n=4时方陈为: 10 11 12 1 9 16 ...