我正在尝试在 vhdl 中为 riscv 编写解码器,但我产生了一个我自己无法弄清楚的错误。为了重现它,我创建了这些文件:
library IEEE;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
library work;
use work.riscv_types.all;
entity test is
port (inst_in : in std_logic_vector(31 downto 0) := (others => '0');
reg_out : out std_logic_vector(4 downto 0) := (others => '0')
);
end test;
architecture behavioral of test is
signal reg : std_logic_vector(4 downto 0) := "00000";
begin
process(inst_in)
begin
reg <= inst_in(4 downto 0);
end process;
reg_out <= reg;
end architecture;
(...)
architecture behavioral of test_TB is
component test
port(
inst_in : in std_logic_vector(31 downto 0);
reg_out : out std_logic_vector(4 downto 0)
);
end component;
signal word_sup : std_logic_vector(31 downto 0) := (others => '1');
signal regout : std_logic_vector(4 downto 0) := "00000";
begin
uut:test
port map(
inst_in => word_sup,
reg_out => regout
);
test_process : process
begin
report "vector value =" & integer'image(to_integer(unsigned(regout)));
report "word_sup =" & integer'image(to_integer(unsigned(word_sup(5 downto 0))));
end process;
end architecture;
我想要发生的是在测试中将指令的最低 5 位放入 reg 然后放入 reg_out。因为“test”中的信号用零初始化,word_sup 用 1 初始化,所以 regout 的整数值应该是 2**5 -1 但它始终保持为inst_in 最低 5 位的初始值
为什么 word_sup 的值不覆盖 inst_in 的值?
如果我生成一个 vcd 文件来查看值 gtkwave 告诉我该文件格式错误,因为它是空的。但我不明白为什么会这样。