日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

基础003_V7-Memory Resources

發布時間:2023/12/15 编程问答 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 基础003_V7-Memory Resources 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

一、綜述

參考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_WRITEif ( cs && we ) beginmem[address] = data;end end// Memory Read Block // Read Operation : When we = 0, oe = 1, cs = 1 always @ (posedge clk) begin : MEM_READif (cs && !we && oe) begindata_out = mem[address];oe_r = 1;end else beginoe_r = 0;end endendmodule // 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_WRITEif ( cs && we ) beginmem[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_READif (cs && !we && oe) begindata_out = mem[address];end endendmodule // 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的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。