Forum Discussion
Altera_Forum
Honored Contributor
14 years agosfixed to ufixed conversition
Hi all; I have learn about ufixed and sfixed operation. I want to convert -0.129 to sfixed using the code below and its has no problem; signal n1: ufixed (4 downto -4); ... out_A <= ...
Altera_Forum
Honored Contributor
14 years agoI write the code below and its work;
------------------------------------------------------------- Library ieee; USE ieee.std_logic_1164.all; use ieee.numeric_std.all; library ieee_proposed; use ieee_proposed.fixed_pkg.all; ENTITY try IS PORT( y : IN sfixed(4 downto -4); Clock : IN STD_LOGIC; alphaEstOut : OUT ufixed(5 downto -4)); END try; ARCHITECTURE Behavior OF try IS SIGNAL aa : sfixed(y'high +1 downto y'low); BEGIN PROCESS(Clock) BEGIN IF rising_edge(Clock) THEN aa<=abs(y); alphaEstOut<=ufixed(aa); END IF; END PROCESS; END Behavior;