我正在尝试用 VHDL 编写一个寄存器文件。该文件包含 16 个 64 位寄存器。每个周期,读取两个寄存器并写入一个寄存器(假设写入已启用)。应该有一个数据旁路(转发),以便如果我们在单个周期中读取和写入同一寄存器/从同一寄存器写入,则刚刚写入的值直接转发到输出。
我的想法是在时钟的上升沿写入并在时钟的下降沿读取,以便在一个周期内完成。但是,我的设计不起作用(不是我期望的那样,因为我不相信在检查上升沿的if块中检查下降沿会按预期工作)。
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.NUMERIC_STD.ALL;
entity register_file is
port
(
outA : out std_logic_vector(63 downto 0);
outB : out std_logic_vector(63 downto 0);
input : in std_logic_vector(63 downto 0);
writeEnable : in std_logic;
regASel : in std_logic_vector(5 downto 0);
regBSel : in std_logic_vector(5 downto 0);
writeRegSel : in std_logic_vector(5 downto 0);
clk : in std_logic
);
end register_file;
architecture behavioral of register_file is
type registerFile is array(0 to 15) of std_logic_vector(63 downto 0);
signal registers : registerFile;
begin
regFile: process(clk)
begin
if rising_edge(clk) then
if(writeEnable = '1') then
registers(to_integer(unsigned(writeRegSel))) <= input;
end if;
if falling_edge(clk) then
outA <= registers(to_integer(unsigned(regASel)));
outB <= registers(to_integer(unsigned(regBSel)));
end if;
end if;
if falling_edge(clk) then
outA <= registers(to_integer(unsigned(regASel)));
outB <= registers(to_integer(unsigned(regBSel)));
end if;
end process;
end behavioral;
任何帮助,将不胜感激。