1
我試圖使用Xilinx pg060浮點內核。通過查看所提供的圖表,例如上面的時序圖和演示測試平臺(對於像我這樣缺乏經驗的人來說,這非常容易混淆!),我創建了一個簡單的程序,它將兩個數字相乘。Xilinx浮點內核 - 錯誤的'X'值?
乍一看,我以爲我做了一件非常糟糕的事情,因爲結果充滿了未知的'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;
關於你最後一個問題:所以你看到一個簡單的32位FP乘法需要10個週期。也許你可以在沒有AXI接口的情況下創建FP單元。也可以啓用pipeling,因此每個週期計算一個結果,但延遲時間大於10個週期。 – Paebbels
非常感謝 - 會考慮它!你知道一個顯示簡單流水線的資源/模板/例子嗎? – davidhood2
[DS816](http://www.xilinx.com/support/documentation/ip_documentation/floating_point/v6_0/ds816_floating_point.pdf)=流水線中描述了非阻塞模式。 – Paebbels