Hi all,
i'm trying to design a floating point adder using advantage pro and i
simulating it using modelsim
attached my code
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_arith.all;
ENTITY fp_adder IS
-- Declarations
port(a,b: in std_logic_vector(31 downto 0);
c: out std_logic_vector(31 downto 0)
);
END fp_adder ;
-- hds interface_end
ARCHITECTURE adder OF fp_adder IS
--declaration of sign
signal sa,sb,sc: std_logic;
--declaration of exponent
signal tea,teb: std_logic_vector(7 downto 0);
signal ea,eb,ec: unsigned(7 downto 0);
--declaration of mantissa
signal tma,tmb: std_logic_vector(22 downto 0);
signal ma,mb,mc: unsigned(22 downto 0);
BEGIN
--asignement of sign signals
sa <= a(31);
sb <= b(31);
--assignement of exponent signals
tea <= std_logic_vector(a(30 downto 23));
teb <= std_logic_vector(b(30 downto 23));
ea <= unsigned(tea);
eb <= unsigned(teb);
--assignement of mantissa signals
tma <= std_logic_vector(a(22 downto 0));
tmb <= std_logic_vector(b(22 downto 0));
ma <= unsigned(tma);
mb <= unsigned(tmb);
------------------------------------------------------------------------------------------------------
process(ea,eb,ec,ma,mb,mc,sa,sb,sc)
begin
if(ea > eb)then loop
eb <= eb+1;
mb <= '0'& mb(22 downto 1);
exit when ea=eb;
end loop;
mc <= ma+mb;
ec <= ea;
sc <= sa xor sb;
elsif(eb > ea) then loop
ea <= ea+1;
ma <= '0'& ma(22 downto 1);
exit when ea=eb;
end loop;
mc <= ma+mb;
ec <= ea;
sc <= sa xor sb;
else
mc <= ma+mb;
ec <= ea;
sc <= sa xor sb;
end if;
end process;
c(22 downto 0) <= std_logic_vector(mc);
c(30 downto 23) <= std_logic_vector(ec);
c(31) <= sc;
END adder;
and i found a problem which i couldn't recognize it
there is no error in compiling the code
but at simulation the o/p is UUUUUUUUUUUUUUUUUUUU
and there is some warnings at modelsim command window
this is the error massage
# ** Warning: There is an 'U'|'X'|'W'|'Z'|'-' in an arithmetic operand, the result will be 'X'(es).
# Time: 0 ns Iteration: 0 Instance: /fp_adder
# ** Warning: There is an 'U'|'X'|'W'|'Z'|'-' in an arithmetic operand, the result will be 'X'(es).
# Time: 0 ns Iteration: 0 Instance: /fp_adder
# ** Warning: There is an 'U'|'X'|'W'|'Z'|'-' in an arithmetic operand, the result will be 'X'(es).
# Time: 0 ns Iteration: 0 Instance: /fp_adder
# ** Warning: There is an 'U'|'X'|'W'|'Z'|'-' in an arithmetic operand, the result will be 'X'(es).
# Time: 0 ns Iteration: 0 Instance: /fp_adder
# ** Warning: There is an 'U'|'X'|'W'|'Z'|'-' in an arithmetic operand, the result will be 'X'(es).
# Time: 0 ns Iteration: 0 Instance: /fp_adder
# ** Warning: There is an 'U'|'X'|'W'|'Z'|'-' in an arithmetic operand, the result will be 'X'(es).
# Time: 0 ns Iteration: 0 Instance: /fp_adder
# ** Warning: There is an 'U'|'X'|'W'|'Z'|'-' in an arithmetic operand, the result will be 'X'(es).
# Time: 0 ns Iteration: 1 Instance: /fp_adder
# ** Warning: There is an 'U'|'X'|'W'|'Z'|'-' in an arithmetic operand, the result will be 'X'(es).
# Time: 0 ns Iteration: 1 Instance: /fp_adder
# ** Warning: There is an 'U'|'X'|'W'|'Z'|'-' in an arithmetic operand, the result will be 'X'(es).
# Time: 0 ns Iteration: 1 Instance: /fp_adder
# ** Warning: There is an 'U'|'X'|'W'|'Z'|'-' in an arithmetic operand, the result will be 'X'(es).
# Time: 0 ns Iteration: 1 Instance: /fp_adder
# ** Warning: There is an 'U'|'X'|'W'|'Z'|'-' in an arithmetic operand, the result will be 'X'(es).
# Time: 0 ns Iteration: 1 Instance: /fp_adder
# ** Warning: There is an 'U'|'X'|'W'|'Z'|'-' in an arithmetic operand, the result will be 'X'(es).
# Time: 0 ns Iteration: 1 Instance: /fp_adder
# ** Warning: There is an 'U'|'X'|'W'|'Z'|'-' in an arithmetic operand, the result will be 'X'(es).
# Time: 0 ns Iteration: 2 Instance: /fp_adder
# ** Warning: There is an 'U'|'X'|'W'|'Z'|'-' in an arithmetic operand, the result will be 'X'(es).
# Time: 0 ns Iteration: 2 Instance: /fp_adder
# ** Warning: There is an 'U'|'X'|'W'|'Z'|'-' in an arithmetic operand, the result will be 'X'(es).
# Time: 0 ns Iteration: 2 Instance: /fp_adder
# ** Warning: There is an 'U'|'X'|'W'|'Z'|'-' in an arithmetic operand, the result will be 'X'(es).
# Time: 0 ns Iteration: 2 Instance: /fp_adder
# ** Warning: There is an 'U'|'X'|'W'|'Z'|'-' in an arithmetic operand, the result will be 'X'(es).
# Time: 0 ns Iteration: 2 Instance: /fp_adder
# ** Warning: There is an 'U'|'X'|'W'|'Z'|'-' in an arithmetic operand, the result will be 'X'(es).
# Time: 0 ns Iteration: 2 Instance: /fp_adder
could anyone help me to solve this error
is my design synthesizable?
this the new vhdl code after add a default value for all internal
signals
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_arith.all;
ENTITY fp_adder IS-- Declarationsport(a,b: instd_logic_vector(31downto0);
c: outstd_logic_vector(31downto0)
);
END fp_adder ;
-- hds interface_endARCHITECTURE adder OF fp_adder IS--declaration of sign signal sa,sb,sc: std_logic:= '0';
--declaration of exponentsignal tea,teb: std_logic_vector(7downto0):= (others=>'0');
signal ea,eb,ec: unsigned(7downto0):= (others=>'0');
--declaration of mantissasignal tma,tmb: std_logic_vector(22downto0):= (others=>'0');
signal ma,mb,mc: unsigned(22downto0):= (others=>'0');
BEGIN--asignement of sign signals
sa <= a(31);
sb <= b(31);
--assignement of exponent signals
tea <= std_logic_vector(a(30downto23));
teb <= std_logic_vector(b(30downto23));
ea <= unsigned(tea);
eb <= unsigned(teb);
--assignement of mantissa signals
tma <= std_logic_vector(a(22downto0));
tmb <= std_logic_vector(b(22downto0));
ma <= unsigned(tma);
mb <= unsigned(tmb);
------------------------------------------------------------------------------------------------------process(ea,eb,ec,ma,mb,mc,sa,sb,sc)
beginif(ea > eb)thenloop
eb <= eb+1;
mb <= '0'& mb(22downto1);
exitwhen ea=eb;
endloop;
mc <= ma+mb;
ec <= ea;
sc <= sa xor sb;
elsif(eb > ea) thenloop
ea <= ea+1;
ma <= '0'& ma(22downto1);
exitwhen ea=eb;
endloop;
mc <= ma+mb;
ec <= ea;
sc <= sa xor sb;
else
mc <= ma+mb;
ec <= ea;
sc <= sa xor sb;
endif;
endprocess;
c(22downto0) <= std_logic_vector(mc);
c(30downto23) <= std_logic_vector(ec);
c(31) <= sc;
END adder;
i try to test my desig my put
a =.25 "00000000101000000000000000000000"
b =.25 "00000000101000000000000000000000"
so
sa=0
sb=0
sc=0
tea=000000001
teb=000000001
ea=0000000X --i can't understand why?
eb=0000000X --i can't understand why?
tma=01000000000000000000000
tmb=01000000000000000000000
ma=0X000000000000000000000 --i can't understand why?
mb=0X000000000000000000000 --i can't understand why?
mc=XXXXXXXXXXXXXXXXXXXXXXX but i expect to be ="10000000000000000000000"
plz can you explain why there's unknown bits?
Try type conversion without temporary signals, like here:
--assignement of exponent signals
ea <= unsigned(a(30downto23));
eb <= unsigned(b(30downto23));
--assignement of mantissa signals
ma <= unsigned(a(22downto0));
mb <= unsigned(b(22downto0));
Duke
P.S.: I suggest to use records:
type float_t isrecord
s: std_logic;
e: unsigned(7downto0);
m: unsigned(22downto0);
endrecord;
There are some fundamental problems in your code. Is this supposed to be
a clocked or combinatorial adder? Because at the moment it is neither.
You have signals that are not assigned in every branch, signals that are
assigned their previous values, loops with non-constant exit conditions
- all that will blow up when you try to synthesize it. I suggest you
follow the rules in http://embdev.net/articles/VHDL and look at some
examples.
If you just need a FPAdder, try FloPoCo:
http://www.ens-lyon.fr/LIP/Arenaire/Ware/FloPoCo/
It's VERY advanced, you can customize all parameters such as pipeline
depth, mantissa width, internal representation, ...
What you get is a perfectly synthesizable VHDL entity.
Plus it's free!
@ Andreas Schwarz
thanks for your help but sorry i'm new at vhdl could u explain to me
what's record and how can i use it i'm trying to read about it from vhdl
by example but i understand nothing.
@ Ras Funk
thanks alot for your post but i have to do it by myself coz i'll use it
at my graduation project