【发布时间】:2017-04-03 14:52:27
【问题描述】:
每次我模拟下面的代码时,我的输出都是未定义的,我不知道为什么。我在代码和模拟中都有数字库。如果有人可以帮助让我知道。模拟中的输入也变为 00000..000,而不是 15 和 3 的输入。
模块代码:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
USE ieee.numeric_std.ALL;
entity EXPONENT_FUNCTION is
Port ( A : in STD_LOGIC_VECTOR (23 downto 0);
B : in STD_LOGIC_VECTOR (23 downto 0);
O : out STD_LOGIC_VECTOR (47 downto 0));
end EXPONENT_FUNCTION;
architecture Behavioral of EXPONENT_FUNCTION is
signal AIN, BIN, F : integer;
signal u : std_logic_vector (47 downto 0);
begin
AIN <= to_integer(signed (A));
BIN <= to_integer(signed (B));
F <= ((AIN)**(BIN));
u <= std_logic_vector(to_signed(F, 48));
O <= u;
end Behavioral;
模拟代码:
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.numeric_std.ALL;
ENTITY EXPONENT_TEST IS
END EXPONENT_TEST;
ARCHITECTURE behavior OF EXPONENT_TEST IS
COMPONENT EXPONENT_FUNCTION
PORT(
A : IN std_logic_vector(23 downto 0);
B : IN std_logic_vector(23 downto 0);
O : OUT std_logic_vector(47 downto 0)
);
END COMPONENT;
signal A : std_logic_vector(23 downto 0) := (others => '0');
signal B : std_logic_vector(23 downto 0) := (others => '0');
signal O : std_logic_vector(47 downto 0);
BEGIN
uut: EXPONENT_FUNCTION PORT MAP (
A => A,
B => B,
O => O
);
stim_proc: process
begin
A <= "000000000000000000001111";
B <= "000000000000000000000011";
wait for 100 ns;
wait;
end process;
END;
【问题讨论】:
-
如果你自己模拟上面的代码,它的输出将是不确定的,因为没有任何东西在驱动输入。您需要在问题中包含测试平台的代码。 (见MCVE)。
-
我已经用模拟代码更新了它