Initial import

git-svn-id: http://moon:8086/svn/vhdl/trunk@5 cc03376c-175c-47c8-b038-4cd826a8556b
This commit is contained in:
2008-08-23 08:20:30 +00:00
parent bfbeba5129
commit d3bd08bb52
160 changed files with 56260 additions and 0 deletions
+62
View File
@@ -0,0 +1,62 @@
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use ieee.numeric_std.all;
use work.fixed_pkg.all;
package mix_pkg is
-------------------------------------------------------------
-- Constructor helpers
-- Use: variable v8u6 : ufixed_t(ufixed(8,6)'range);
function uproto (nbits : integer; nbits_frac : integer) return ufixed;
-- Use: variable v8s6 : sfixed_t(sfixed(8,6)'range);
function sproto (nbits : integer; nbits_frac : integer) return sfixed;
function to_unsigned (src : ufixed) return UNSIGNED;
function to_signed (src : sfixed) return SIGNED;
-------------------------------------------------------------------------------
end; -- package mix_cpx_pkg;
package body mix_pkg is
-------------------------------------------------------------
-- Constuctor helpers
function uproto (nbits : integer; nbits_frac : integer) return ufixed is
constant result : ufixed (nbits-nbits_frac-1 downto -nbits_frac) := (others => '0');
begin
return result(nbits-nbits_frac-1 downto -nbits_frac);
end uproto;
-------------------------------------------------------------
function sproto (nbits : integer; nbits_frac : integer) return sfixed is
constant result : sfixed (nbits-nbits_frac downto -nbits_frac+1) := (others => '0');
begin
return result(nbits-nbits_frac downto -nbits_frac+1);
end sproto;
-------------------------------------------------------------
function to_unsigned (src : ufixed) return UNSIGNED is
subtype t is UNSIGNED(src'high - src'low downto 0);
variable slv : t;
begin
slv := t(src);
return UNSIGNED(to_X01(std_logic_vector(slv)));
end function to_unsigned;
-------------------------------------------------------------
function to_signed (src : sfixed) return SIGNED is
subtype t is SIGNED(src'high - src'low downto 0);
variable slv : t;
begin
slv := t(src);
return SIGNED(to_X01(std_logic_vector(slv)));
end function to_signed;
-------------------------------------------------------------------------------
end; -- package mix_pkg;