VHDL 合成具有多个输出的 Block Ram

标签 vhdl fpga

if rising_edge(CLK_100Mhz) then
  if w_ram = '1' then
    for X in 0 to 6 loop
        for Y in 0 to 6 loop
            DataO(X)(Y)(0) <= Memory(X)(Y)(Address);
            DataO(X)(Y)(1) <= Memory(X)(Y)(Address+1);
            DataO(X)(Y)(2) <= Memory(X)(Y)(Address+2);
            DataO(X)(Y)(3) <= Memory(X)(Y)(Address+3);
            Memory(X)(Y)(Address) <= DataI(X)(Y)(0);
        end loop;
    end loop;
  w_ram <= '0';
end if;
end if;

我需要为我的数据密集型项目使用 block ram。对于每个给定的 X、Y,这会用作 1 个输入、4 个输出 block ,还是会为每个给定的 X、Y 创建 4 个 block ?这也行吗?我正在使用 Xilinx Zynq-7000 FPGA。

谢谢。

最佳答案

我猜您希望 Xilinx 综合工具推断出多个非对称 block RAM。 Xilinx 有示例代码来推断一个 RAM,可以在

http://www.xilinx.com/support/documentation/sw_manuals/xilinx13_2/xst_v6s6.pdf

写端口为8位宽,256位深,读端口为32位宽,64位深。这是来自上述链接的代码:

-- Asymmetric port RAM
-- Port A is 256x8-bit write-only
-- Port B is 64x32-bit read-only
--
-- Download: ftp://ftp.xilinx.com/pub/documentation/misc/xstug_examples.zip
-- File: HDL_Coding_Techniques/rams/asymmetric_ram_1a.vhd
--
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;

entity asymmetric_ram_1a is
generic (
    WIDTHA      : integer := 8;
    SIZEA       : integer := 256;
    ADDRWIDTHA  : integer := 8;
    WIDTHB      : integer := 32;
    SIZEB       : integer := 64;
    ADDRWIDTHB  : integer := 6
);
port (
    clkA    : in    std_logic;
    clkB    : in    std_logic;
    weA     : in    std_logic;
    enA     : in    std_logic;
    enB     : in    std_logic;
    addrA   : in    std_logic_vector(ADDRWIDTHA-1 downto 0);
    addrB   : in    std_logic_vector(ADDRWIDTHB-1 downto 0);
    diA     : in    std_logic_vector(WIDTHA-1 downto 0);
    doB     :   out std_logic_vector(WIDTHB-1 downto 0)
);
end asymmetric_ram_1a;

architecture behavioral of asymmetric_ram_1a is

function max(L, R: INTEGER) return INTEGER is
begin
    if L > R then
        return L;
    else
        return R;
    end if;
end;

function min(L, R: INTEGER) return INTEGER is
begin
    if L < R then
        return L;
    else
        return R;
    end if;
end;

constant minWIDTH : integer := min(WIDTHA,WIDTHB);
constant maxWIDTH : integer := max(WIDTHA,WIDTHB);
constant maxSIZE  : integer := max(SIZEA,SIZEB);
constant RATIO    : integer := maxWIDTH / minWIDTH;

type ramType is array (0 to maxSIZE-1) of std_logic_vector(minWIDTH-1 downto 0);
signal ram : ramType := (others => (others => '0'));
signal readB : std_logic_vector(WIDTHB-1 downto 0):= (others => '0');
signal regB : std_logic_vector(WIDTHB-1 downto 0):= (others => '0');

begin
process (clkA)
begin
    if rising_edge(clkA) then
        if enA = '1' then
            if weA = '1' then
                ram(conv_integer(addrA)) <= diA;
            end if;
        end if;
    end if;
end process;

process (clkB)
begin
    if rising_edge(clkB) then
        if enB = '1' then
            readB(minWIDTH-1 downto 0)
            <= ram(conv_integer(addrB&conv_std_logic_vector(0,2)));
            readB(2*minWIDTH-1 downto minWIDTH)
            <= ram(conv_integer(addrB&conv_std_logic_vector(1,2)));
            readB(3*minWIDTH-1 downto 2*minWIDTH)
            <= ram(conv_integer(addrB&conv_std_logic_vector(2,2)));
            readB(4*minWIDTH-1 downto 3*minWIDTH)
            <= ram(conv_integer(addrB&conv_std_logic_vector(3,2)));
        end if;
    regB <= readB;
    end if;
end process;

doB <= regB;

end behavioral;

这是确认 XST 推断出不对称内存的综合报告的摘录。

Synthesizing (advanced) Unit <asymmetric_ram_1a>.
INFO:Xst:3226 - The RAM <Mram_ram> will be implemented as a BLOCK RAM, absorbing the following register(s): <readB> <regB>
    -----------------------------------------------------------------------
    | ram_type           | Block                               |          |
    -----------------------------------------------------------------------
    | Port A                                                              |
    |     aspect ratio   | 256-word x 8-bit                    |          |
    |     mode           | write-first                         |          |
    |     clkA           | connected to signal <clkA>          | rise     |
    |     weA            | connected to signal <weA_0>         | high     |
    |     addrA          | connected to signal <addrA>         |          |
    |     diA            | connected to signal <diA>           |          |
    -----------------------------------------------------------------------
    | optimization       | speed                               |          |
    -----------------------------------------------------------------------
    | Port B                                                              |
    |     aspect ratio   | 64-word x 32-bit                    |          |
    |     mode           | write-first                         |          |
    |     clkB           | connected to signal <clkB>          | rise     |
    |     enB            | connected to signal <enB>           | high     |
    |     addrB          | connected to signal <addrB>         |          |
    |     doB            | connected to signal <doB>           |          |
    -----------------------------------------------------------------------
    | optimization       | speed                               |          |
    -----------------------------------------------------------------------
Unit <asymmetric_ram_1a> synthesized (advanced).

=========================================================================
Advanced HDL Synthesis Report

Macro Statistics
# RAMs                                                 : 1
 256x8:64x32-bit dual-port block RAM                   : 1

请注意,无论综合报告怎么说,端口 B 都是只读的。

关于VHDL 合成具有多个输出的 Block Ram,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29239911/

相关文章:

vhdl - HDL编译器 :432 error on converting std_logic_vector to integer

c# - 在同一台计算机上使用不同编程语言的不同程序之间发送数据的最佳方式是什么?

vhdl - 在 VHDL 中定义和初始化矩阵的最佳方法

c++ - SystemC HLS综合错误

VHDL 初学者 - 这个电路中的时序出了什么问题?

vhdl - 何时使用VHDL库std_logic_unsigned和numeric_std?

vhdl - 'sra' 在 VHDL 中不工作

根据 `report` 语句,VHDL 重新分配整数信号不起作用

"header"文件的 VHDL 标准布局和语法

vhdl - 是否有与Verilog的@(*)等效的VHDL,即自动过程敏感性列表