2013-10-03 105 views
0

我想在1個週期(組合電路)中將VHDL中的兩個數字(16位二進制)分開。分子是一個整數。分母是一個浮點數。結果應該是浮動的。我用什麼算法來執行除法。VHDL中的分區(int/float)

請幫忙

+1

你需要做的劃分在一個週期內,或完成每個週期劃分的?許多浮點分隔器都是流水線的,所以它們可以在每個週期產生一個結果,而不會使週期時間足夠長,以便在一個週期內進行分割。 –

+0

你的時鐘週期有多長? –

回答

0

我不認爲這是可能的。是否有任何理由需要在1個時鐘週期內完成?關閉的唯一方法是使用查找表,但是必須犧牲輸出的一些精度。

+0

它是我的項目的一部分,我需要在它的每個步驟中執行劃分。所以我不能給更多的時間分裂。 – Maximus

+0

你在使用什麼時鐘頻率? – Russell

1

這裏是一個實體,你想要做什麼(如果我理解正確的問題):

library ieee; 
use ieee.numeric_std.all; 
use ieee.float_pkg.all; 

entity integer_by_float_division is 
    port (
     numerator: in signed(15 downto 0); 
     denominator: in signed(15 downto 0); 
     result: out float(6 downto -9) 
    ); 
end; 

architecture rtl of integer_by_float_division is 
    subtype float16 is float(6 downto -9); 
    signal numerator_float: float16; 
    signal denominator_float: float16; 
begin 
    numerator_float <= to_float(numerator, numerator_float); 
    denominator_float <= to_float(denominator, denominator_float); 
    result <= numerator_float/denominator_float; 
end; 
+0

我認爲當他們說「float」時,OP意味着「IEEE754單精度」,所以分母和out可能需要'float32' –