我尝试使用 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;