最近FPGA需要用到大量的矩陣運算,需要使用多個shift_RAM對數據進行緩存,考慮到資源消耗問題,做相關記錄。
一、LUTRAM和 BRAM在資源使用上的區別?
LUTRAM 和 BRAM最主要的卻別在於 LUTRAM是使用的沒有綜合的LUT單元生成的動態RAM,在Design中使用
多少,綜合后就會消耗多少RAM。而BRAM他是塊RAM,在FPGA中的位置和大小是固定的,在例化一個BRAM后,
即使只是占用到該RAM的一小部分,而綜合后,同樣會消耗一整塊RAM的資源。
二、shift_RAM消耗分布式RAM(LUTRAM)還是BRAM (Block RAM)?
1)查看shift_ram官方手冊(pg122), 消耗的為LUTs
2)綜合驗證,為了驗證,我綜合了36個 數據位寬為10bit,深度為640bit的shift_RAM
`timescale 1ns / 1ps ////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 2020/07/15 10:51:34 // Design Name: // Module Name: shift_ram // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // Revision: // Revision 0.01 - File Created // Additional Comments: // ////////////////////////////////////////////////////////////////////////////////// module shift_ram( input clk , input [9:0] din , output [9:0] dout ); wire [9:0] c0; wire [9:0] c1; wire [9:0] c2; wire [9:0] c3; wire [9:0] c4; wire [9:0] c5; wire [9:0] c6; wire [9:0] c7; wire [9:0] c8; c_shift_ram_0 u0( .D (din), .CLK (clk), .Q (c0) ); c_shift_ram_0 u1( .D (c0), .CLK (clk), .Q (c1) ); c_shift_ram_0 u2( .D (c1), .CLK (clk), .Q (c2) ); c_shift_ram_0 u3( .D (c2), .CLK (clk), .Q (c3) ); c_shift_ram_0 u4( .D (c3), .CLK (clk), .Q (c4) ); c_shift_ram_0 u5( .D (c4), .CLK (clk), .Q (c5) ); c_shift_ram_0 u6( .D (c5), .CLK (clk), .Q (c6) ); c_shift_ram_0 u7( .D (c6), .CLK (clk), .Q (c7) ); c_shift_ram_0 u8( .D (c7), .CLK (clk), .Q (c8) ); c_shift_ram_0 u9( .D (c8), .CLK (clk), .Q (dout) ); endmodule
`timescale 1ns / 1ps
////////////////////////////////////////////////////////////////////////////////// // Company: // Engineer: // // Create Date: 2020/07/15 10:59:53 // Design Name: // Module Name: shift_tam_top // Project Name: // Target Devices: // Tool Versions: // Description: // // Dependencies: // // Revision: // Revision 0.01 - File Created // Additional Comments: // ////////////////////////////////////////////////////////////////////////////////// module shift_tam_top( input clk , input [39:0] din , output [39:0] dout ); wire [9:0] dout0; wire [9:0] dout1; wire [9:0] dout2; wire [9:0] dout3; assign dout = {dout0,dout1,dout2,dout3}; shift_ram u0( .clk (clk) , .din (din[9:0]) , .dout (dout0) ); shift_ram u1( .clk (clk) , .din (din[19:10]) , .dout (dout1) ); shift_ram u2( .clk (clk) , .din (din[29:20]) , .dout (dout2) ); shift_ram u3( .clk (clk) , .din (din[39:30]) , .dout (dout3) ); endmodule
最后看資源消耗綜合報告:從報告中可以看出,主要消耗的還是LUTRAM資源,沒有使用到BRAM的資源。