VHDL寄存器文件中的微小更改会导致总逻辑元素的巨大差异
我是VHDL新手,我的任务之一是创建一个8位寄存器文件。我注意到,通过更改一行代码,可以显著增加或减少逻辑元素的总数。我试图理解为什么这会导致如此重大的变化 当VHDL寄存器文件中的微小更改会导致总逻辑元素的巨大差异,vhdl,Vhdl,我是VHDL新手,我的任务之一是创建一个8位寄存器文件。我注意到,通过更改一行代码,可以显著增加或减少逻辑元素的总数。我试图理解为什么这会导致如此重大的变化 当enable值较高时,寄存器文件将dataIn的值存储在选择write的位置dataOut显示存储在selectRead位置的值 如果dataOut您需要研究您正在使用的FPGA架构。当您有一个大内存要实现时,您很可能希望使用设备专用的RAM块,在Xilinx中称为块RAM。块RAM有一个特定的结构,特别是在使用时钟边缘与异步(组合)进行
enable
值较高时,寄存器文件将dataIn
的值存储在选择write
的位置dataOut
显示存储在selectRead
位置的值
如果
dataOut您需要研究您正在使用的FPGA架构。当您有一个大内存要实现时,您很可能希望使用设备专用的RAM块,在Xilinx中称为块RAM。块RAM有一个特定的结构,特别是在使用时钟边缘与异步(组合)进行读写方面。如果您的代码与之匹配,它将使用块RAM和很少的其他逻辑。如果您的代码与块RAM不匹配,那么您将使用逻辑单元
进一步查看您的报告,查看它在每种情况下报告的块RAM使用情况。查看Xilinx关于块RAM结构的文档。同步与异步读取。您可能会在合成报告(.syr)中找到有关synth推断RAM以满足不同需求的方式的信息。我猜“较小”的那个也使用了RAM块…我同意Brian的看法。。。然而,一些合成器将使用RAM实现两个版本(例如ISE 13.4),因此大小大致相同。附加提示:使用范围(例如,signal readIndex:Integer range 0到255:=0)定义索引信号,否则32位信号用于Integer!
Total logical elements: 9/33,216 ( < 1% )
Total combinatorial functions 9/33,216 ( < 1% )
Dedicated logic registers 0/33,216 ( 0% )
Total logical elements: 2,672/33,216 ( 8% )
Total combinatorial functions 1,656/33,216 ( 5% )
Dedicated logic registers 2,048/33,216 ( 6% )
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;