Xilinx 浮点内核 - 错误的 'X' 值?
Xilinx Floating Point Core - Erroneous 'X' values?
我尝试使用 Xilinx pg060 浮点内核。
在浏览了提供的图表后,例如上面的时序图和演示测试台(对于像我这样没有经验的人来说,这很令人困惑!)我创建了一个简单的程序,将两个数字相乘。
乍一看,我以为我做错了什么,因为结果是未知的'X'。
然而,在检查了用户指南中推荐的许多其他内容后,我将每个 'X' 替换为“1”,发现这是正确的结果。
这是 a) 正常还是 b) 我对核心的误用,幸运的是在这种情况下给了我正确的答案?
编辑:这很可能是我的错误 - 为什么会发生这种情况?
非常感谢!
entity FloatMul is
port(SYSCLK : IN STD_LOGIC;
RESET_N : IN STD_LOGIC;
A, B : IN FLOAT32; --input
E : OUT FLOAT32 -- E = A*B
);
end FloatMul;
architecture Behavioral of FloatMul is
type fsm is (load, ready, waiting, results);
signal state : fsm := load; --state machine controller
signal a_val, b_val, prod_val : std_logic := '0'; --valid data flags
signal prod : std_logic_vector(31 downto 0);
component fp_mul
port(
aclk : in std_logic;
s_axis_a_tvalid : in std_logic;
s_axis_a_tdata : in std_logic_vector(31 downto 0);
s_axis_b_tvalid : in std_logic;
s_axis_b_tdata : in std_logic_vector(31 downto 0);
m_axis_result_tvalid : out std_logic;
m_axis_result_tdata : out std_logic_vector(31 downto 0)
);
end component;
begin
fp_core : FP_Mul
PORT MAP(
aclk => SYSCLK,
s_axis_a_tvalid => a_val,
s_axis_a_tdata => std_logic_vector(A), --Data from input
s_axis_b_tvalid => b_val,
s_axis_b_tdata => std_logic_vector(B),
m_axis_result_tvalid => prod_val,
m_axis_result_tdata => prod
);
state_machine : process(SYSCLK)
begin
if rising_edge(SYSCLK) then
case state is
when load => --initial state
state <= ready;
when ready =>
a_val <= '1'; --set flags to ready
b_val <= '1';
state <= waiting;
when waiting =>
if prod_val = '1' then
a_val <= '0'; --when result ready, remove flags
b_val <= '0';
state <= results;
else
state <= waiting; --wait til result ready
end if;
when results =>
E <= float(prod); --cast result to float
state <= load;
end case;
if RESET_N = '0' then --synchronous reset
state <= load;
a_val <= '0';
b_val <= '0';
prod <= (others => '0');
end if;
end if;
end process;
end Behavioral;
Tour testbench 将信号 prod
驱动为零,这是 Xilinx 内核的输出。由于驱动有2个,其中价值驱动无法解决(比如核心驱动1,你的testbench驱动0),结果是'X'.
只需删除 prod <= (others => '0')
行即可!
我尝试使用 Xilinx pg060 浮点内核。
在浏览了提供的图表后,例如上面的时序图和演示测试台(对于像我这样没有经验的人来说,这很令人困惑!)我创建了一个简单的程序,将两个数字相乘。
乍一看,我以为我做错了什么,因为结果是未知的'X'。
然而,在检查了用户指南中推荐的许多其他内容后,我将每个 'X' 替换为“1”,发现这是正确的结果。
这是 a) 正常还是 b) 我对核心的误用,幸运的是在这种情况下给了我正确的答案?
编辑:这很可能是我的错误 - 为什么会发生这种情况?
非常感谢!
entity FloatMul is
port(SYSCLK : IN STD_LOGIC;
RESET_N : IN STD_LOGIC;
A, B : IN FLOAT32; --input
E : OUT FLOAT32 -- E = A*B
);
end FloatMul;
architecture Behavioral of FloatMul is
type fsm is (load, ready, waiting, results);
signal state : fsm := load; --state machine controller
signal a_val, b_val, prod_val : std_logic := '0'; --valid data flags
signal prod : std_logic_vector(31 downto 0);
component fp_mul
port(
aclk : in std_logic;
s_axis_a_tvalid : in std_logic;
s_axis_a_tdata : in std_logic_vector(31 downto 0);
s_axis_b_tvalid : in std_logic;
s_axis_b_tdata : in std_logic_vector(31 downto 0);
m_axis_result_tvalid : out std_logic;
m_axis_result_tdata : out std_logic_vector(31 downto 0)
);
end component;
begin
fp_core : FP_Mul
PORT MAP(
aclk => SYSCLK,
s_axis_a_tvalid => a_val,
s_axis_a_tdata => std_logic_vector(A), --Data from input
s_axis_b_tvalid => b_val,
s_axis_b_tdata => std_logic_vector(B),
m_axis_result_tvalid => prod_val,
m_axis_result_tdata => prod
);
state_machine : process(SYSCLK)
begin
if rising_edge(SYSCLK) then
case state is
when load => --initial state
state <= ready;
when ready =>
a_val <= '1'; --set flags to ready
b_val <= '1';
state <= waiting;
when waiting =>
if prod_val = '1' then
a_val <= '0'; --when result ready, remove flags
b_val <= '0';
state <= results;
else
state <= waiting; --wait til result ready
end if;
when results =>
E <= float(prod); --cast result to float
state <= load;
end case;
if RESET_N = '0' then --synchronous reset
state <= load;
a_val <= '0';
b_val <= '0';
prod <= (others => '0');
end if;
end if;
end process;
end Behavioral;
Tour testbench 将信号 prod
驱动为零,这是 Xilinx 内核的输出。由于驱动有2个,其中价值驱动无法解决(比如核心驱动1,你的testbench驱动0),结果是'X'.
只需删除 prod <= (others => '0')
行即可!