【问题标题】:Small change in VHDL register file results in huge difference in total logical elementsVHDL 寄存器文件的微小变化会导致总逻辑元素的巨大差异
【发布时间】:2014-03-13 19:15:07
【问题描述】:

我是 VHDL 新手,我的任务之一是创建一个 8 位寄存器文件。我注意到通过更改一行代码,我可以显着增加或减少逻辑元素的总数。我试图理解为什么这会导致如此重大的变化。

enable 为高电平时,寄存器文件将dataIn 的值存储在selectWrite 的位置。 dataOut 显示存储在selectRead 位置的值。

如果dataOut <= entry(readIndex); 放在process(clock) 内部,则使用的逻辑元素总数为:

Total logical elements: 9/33,216 ( < 1% )
    Total combinatorial functions 9/33,216 ( < 1% )
    Dedicated logic registers 0/33,216 ( 0% )

但是,如果将dataOut &lt;= entry(readIndex); 放在process(clock) 之外,则会使用数千个逻辑元素:

Total logical elements: 2,672/33,216 ( 8% )
    Total combinatorial functions 1,656/33,216 ( 5% )
    Dedicated logic registers 2,048/33,216 ( 6% )

我知道当放置在process(clock) 内部时,dataOut 只会在时钟沿发生变化,而当放置在process(clock) 外部时,dataOut 会发生不可预测的变化。

为什么这种变化会导致使用更多的逻辑元素?

library ieee;
    use ieee.std_logic_1164.all;
    use ieee.numeric_std.all;

entity RegisterFile is
port(
    clock  : in std_logic;
    reset  : in std_logic;
    dataIn : in std_logic_vector(7 downto 0);
    enable : in std_logic;
    selectRead  : in std_logic_vector(7 downto 0);
    selectWrite : in std_logic_vector(7 downto 0);

    dataOut : out std_logic_vector(7 downto 0)
);
end RegisterFile;

architecture RegisterFileArchitecture of RegisterFile is
    type RegisterEntry is array (0 to 255) of std_logic_vector(7 downto 0);
    signal entry : RegisterEntry;
    signal readIndex  : integer;
    signal writeIndex : integer;
begin
    -- Update read/write indices
    readIndex <= to_integer(unsigned(selectRead));
    writeIndex <= to_integer(unsigned(selectWrite));

    process(clock)
    begin
        if (rising_edge(clock)) then
            -- Update selected data
            dataOut <= entry(readIndex);    

            if (reset = '1') then
                entry(writeIndex) <= "00000000";
            elsif (enable = '1') then
                entry(writeIndex) <= dataIn;
            end if; 
        end if;
    end process;
end RegisterFileArchitecture;

【问题讨论】:

  • 同步与异步读取。您可能会在合成报告 (.syr) 中找到有关合成器推断 RAM 以满足不同要求的方式的信息。我猜“较小”的也使用了 RAM 块......
  • 我同意布赖恩的观点......但是,一些合成器将使用 RAM 实现这两个版本(例如 ISE 13.4),因此导致或多或少相同的大小。附加提示:使用范围定义您的索引信号(例如,信号 readIndex :整数范围 0 到 255 := 0),否则 32 位信号用于整数!

标签: vhdl


【解决方案1】:

您需要研究您正在使用的 FPGA 架构。当您要实现大内存时,您很可能希望使用设备专用的 RAM 块,在 Xilinx 中称为 Block RAM。 Block RAM 具有特定的结构——尤其是在时钟边沿与异步(组合)的读取和写入方面。如果您的代码与之匹配,它将使用块 RAM 和很少的其他逻辑。如果您的代码与 Block RAM 不匹配,那么您将使用逻辑单元。

进一步查看您的报告,并查看它在每种情况下报告的有关块 RAM 使用情况的内容。查看 Xilinx 关于 Block RAM 结构的文档。

【讨论】:

    猜你喜欢
    • 2022-01-04
    • 1970-01-01
    • 2013-10-15
    • 1970-01-01
    • 1970-01-01
    • 2021-12-14
    • 2012-11-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多