A
Anon Anon
Guest
I am trying to use the Xilinx floating-point IP, provided as part of the
ISE Foundation V8.1 to produce an entity that determines the smallest
element from an array of floating-point numbers. The entity uses the
Xilinx less-than comparator, which takes two inputs (a and b) and
returns a '1' if a < b or '0' otherwise. Unfortunately, I am getting
some strange (and incorrect) results.
This may be down to an error in the IP, or an error in my VHDL - since I
am quite new to this area. The code is shown below - if anybody can see
the flaw could they please advise?
Many thanks!
=== SNIP ========================
entity float_min_array is
generic(len : integer);
port (
clk : in std_logic;
start : in std_logic := '0';
floats : in FLOAT_ARRAY;
index : out integer := -1;
finished : out std_logic := '0');
end float_min_array;
architecture Behavioral of float_min_array is
signal a: std_logic_VECTOR(63 downto 0);
signal b: std_logic_VECTOR(63 downto 0);
signal operation_nd: std_logic;
signal operation_rfd: std_logic;
signal result: std_logic_VECTOR(0 downto 0);
signal rdy: std_logic;
signal dummy : integer;
-- the Xilinx floating point comparator
component flessthan IS
port (
a: IN std_logic_VECTOR(63 downto 0);
b: IN std_logic_VECTOR(63 downto 0);
operation_nd: IN std_logic;
operation_rfd: OUT std_logic;
clk: IN std_logic;
result: OUT std_logic_VECTOR(0 downto 0);
rdy: OUT std_logic);
END component flessthan;
begin
process (clk)
type entity_state is (wait_rfd, is_rfd, wait_rdy, done);
variable state : entity_state := wait_rfd;
variable lowest, i : integer := floats'LOW(1);
begin
if rising_edge(clk) then
case state is
when wait_rfd =>
if start = '1' and
operation_rfd = '1' then
lowest := i;
index <= lowest;
state := is_rfd;
end if;
when is_rfd =>
if (i < floats'LENGTH) then
assert operation_rfd='1'
report "Not ready for data!";
i := i + 1;
dummy <= i; -- for debugging only!
a <= floats(i);
b <= floats(lowest);
operation_nd <= '1';
state := wait_rdy;
else
state := done;
end if;
when wait_rdy =>
if rdy = '1' then
if result(0) = '1' then
lowest := i;
index <= lowest;
end if;
-- operation_nd <= '0';
-- result(0) <= '0';
state := is_rfd;
end if;
when done =>
finished <= '1';
end case;
end if;
end process;
FM:flessthan PORT MAP(a,b,operation_nd,operation_rfd,clk,result,rdy);
end Behavioral;
=== SNIP ========================
ISE Foundation V8.1 to produce an entity that determines the smallest
element from an array of floating-point numbers. The entity uses the
Xilinx less-than comparator, which takes two inputs (a and b) and
returns a '1' if a < b or '0' otherwise. Unfortunately, I am getting
some strange (and incorrect) results.
This may be down to an error in the IP, or an error in my VHDL - since I
am quite new to this area. The code is shown below - if anybody can see
the flaw could they please advise?
Many thanks!
=== SNIP ========================
entity float_min_array is
generic(len : integer);
port (
clk : in std_logic;
start : in std_logic := '0';
floats : in FLOAT_ARRAY;
index : out integer := -1;
finished : out std_logic := '0');
end float_min_array;
architecture Behavioral of float_min_array is
signal a: std_logic_VECTOR(63 downto 0);
signal b: std_logic_VECTOR(63 downto 0);
signal operation_nd: std_logic;
signal operation_rfd: std_logic;
signal result: std_logic_VECTOR(0 downto 0);
signal rdy: std_logic;
signal dummy : integer;
-- the Xilinx floating point comparator
component flessthan IS
port (
a: IN std_logic_VECTOR(63 downto 0);
b: IN std_logic_VECTOR(63 downto 0);
operation_nd: IN std_logic;
operation_rfd: OUT std_logic;
clk: IN std_logic;
result: OUT std_logic_VECTOR(0 downto 0);
rdy: OUT std_logic);
END component flessthan;
begin
process (clk)
type entity_state is (wait_rfd, is_rfd, wait_rdy, done);
variable state : entity_state := wait_rfd;
variable lowest, i : integer := floats'LOW(1);
begin
if rising_edge(clk) then
case state is
when wait_rfd =>
if start = '1' and
operation_rfd = '1' then
lowest := i;
index <= lowest;
state := is_rfd;
end if;
when is_rfd =>
if (i < floats'LENGTH) then
assert operation_rfd='1'
report "Not ready for data!";
i := i + 1;
dummy <= i; -- for debugging only!
a <= floats(i);
b <= floats(lowest);
operation_nd <= '1';
state := wait_rdy;
else
state := done;
end if;
when wait_rdy =>
if rdy = '1' then
if result(0) = '1' then
lowest := i;
index <= lowest;
end if;
-- operation_nd <= '0';
-- result(0) <= '0';
state := is_rfd;
end if;
when done =>
finished <= '1';
end case;
end if;
end process;
FM:flessthan PORT MAP(a,b,operation_nd,operation_rfd,clk,result,rdy);
end Behavioral;
=== SNIP ========================