【发布时间】:2019-08-09 18:42:38
【问题描述】:
我多年来一直在争论这个问题......为什么要推断一个具有同步读取的单端口 ram 的正确原因是什么。
假设我在 VHDL 中推断内存的接口是:
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity sram1 is
generic(
aw :integer := 8; --address width of memory
dw :integer := 8 --data width of memory
);
port(
--arm clock
aclk :in std_logic;
aclear :in std_logic;
waddr :in std_logic_vector(aw-1 downto 0);
wdata :in std_logic_vector(dw-1 downto 0);
wen :in std_logic;
raddr :in std_logic_vector(aw-1 downto 0);
rdata :out std_logic_vector(dw-1 downto 0)
);
end entity;
是这样吗:1 号门
-- I LIKE THIS ONE
architecture rtl of sram1 is
constant mem_len :integer := 2**aw;
type mem_type is array (0 to mem_len-1) of std_logic_vector(dw-1 downto 0);
signal block_ram : mem_type := (others => (others => '0'));
begin
process(aclk)
begin
if (rising_edge(aclk)) then
if (wen = '1') then
block_ram(to_integer(unsigned(waddr))) <= wdata(dw-1 downto 0);
end if;
-- QUESTION: REGISTERING THE READ DATA (ALL OUTPUT REGISTERED)?
rdata <= block_ram(to_integer(unsigned(raddr)));
end if;
end process;
end architecture;
或者这样:2号门
-- TEXTBOOKS LIKE THIS ONE
architecture rtl of sram1 is
constant mem_len :integer := 2**aw;
type mem_type is array (0 to mem_len-1) of std_logic_vector(dw-1 downto 0);
signal block_ram : mem_type := (others => (others => '0'));
signal raddr_dff : std_logic_vector(aw-1 downto 0);
begin
process(aclk)
begin
if (rising_edge(aclk)) then
if (wen = '1') then
block_ram(to_integer(unsigned(waddr))) <= wdata(dw-1 downto 0);
end if;
-- QUESTION: REGISTERING THE READ ADDRESS?
raddr_dff <= raddr;
end if;
end process;
-- QUESTION: HOT ADDRESS SELECTION OF DATA
rdata <= block_ram(to_integer(unsigned(raddr_dff)));
end architecture;
我是第一个版本的粉丝,因为我认为注册 vhdl 模块的所有输出是一种很好的做法。但是,许多教科书将更高版本列为使用同步读取来推断单端口 ram 的正确方法。
从 Xilinx 或 Altera 综合的角度来看,这真的很重要吗,只要您已经考虑到延迟数据与地址之间的差异(并确定它对您的应用程序无关紧要。)
我的意思是......他们仍然在 FPGA 中为您提供块 ram?对?
或者一个给你 LUTS 和另一个 Block ram?
在 FPGA 中,1 号门或 2 号门哪个会推断出更好的时序和更好的容量?
【问题讨论】: