From 18641b84110051fcf381e04fa6eaf47cc14c16f2 Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Tue, 30 Dec 2008 19:37:56 +0000 Subject: [PATCH] - uses ieee_proposed.fixed_pkg git-svn-id: http://moon:8086/svn/vhdl/trunk@177 cc03376c-175c-47c8-b038-4cd826a8556b --- lib/filter/sim/tb_fir_iterative.fdo | 5 ++++- lib/filter/sim/tb_fir_parallel.fdo | 5 ++++- lib/filter/sim/tb_fir_stage.fdo | 5 ++++- lib/filter/src/filter_pkg.vhd | 8 -------- lib/filter/src/fir_iterative.vhd | 12 +++++++++--- lib/filter/src/fir_iterative_pkg.vhd | 11 +++++++++-- lib/filter/src/fir_parallel.vhd | 9 ++++++++- lib/filter/src/fir_parallel_pkg.vhd | 9 ++++++++- lib/filter/src/fir_stage.vhd | 11 +++++++++-- lib/filter/src/fir_stage_pkg.vhd | 28 ++++------------------------ lib/filter/src/tb_fir_iterative.vhd | 6 +++++- lib/filter/src/tb_fir_parallel.vhd | 6 +++++- lib/filter/src/tb_fir_stage.vhd | 8 ++++++-- 13 files changed, 75 insertions(+), 48 deletions(-) diff --git a/lib/filter/sim/tb_fir_iterative.fdo b/lib/filter/sim/tb_fir_iterative.fdo index d4f35ff..67743e2 100644 --- a/lib/filter/sim/tb_fir_iterative.fdo +++ b/lib/filter/sim/tb_fir_iterative.fdo @@ -1,5 +1,8 @@ +vmap ieee_proposed ../../../Common/sim/ieee_proposed + vlib work -vcom -explicit -93 "../../../lib/fixed/fixed_pkg_c.vhd" +vcom -explicit -93 "../../../lib/misc/utils_pkg.vhd" +vcom -explicit -93 "../../../lib/fixed/fixed_util_pkg.vhd" vcom -explicit -93 "../../../lib/PCK_FIO-2002.7/PCK_FIO_1993.vhd" vcom -explicit -93 "../../../lib/PCK_FIO-2002.7/PCK_FIO_1993_BODY.vhd" vcom -explicit -93 "../src/filter_pkg.vhd" diff --git a/lib/filter/sim/tb_fir_parallel.fdo b/lib/filter/sim/tb_fir_parallel.fdo index 9e15809..97e3660 100644 --- a/lib/filter/sim/tb_fir_parallel.fdo +++ b/lib/filter/sim/tb_fir_parallel.fdo @@ -1,5 +1,8 @@ +vmap ieee_proposed ../../../Common/sim/ieee_proposed + vlib work -vcom -explicit -93 "../../../lib/fixed/fixed_pkg_c.vhd" +vcom -explicit -93 "../../../lib/misc/utils_pkg.vhd" +vcom -explicit -93 "../../../lib/fixed/fixed_util_pkg.vhd" vcom -explicit -93 "../../../lib/PCK_FIO-2002.7/PCK_FIO_1993.vhd" vcom -explicit -93 "../../../lib/PCK_FIO-2002.7/PCK_FIO_1993_BODY.vhd" vcom -explicit -93 "../src/filter_pkg.vhd" diff --git a/lib/filter/sim/tb_fir_stage.fdo b/lib/filter/sim/tb_fir_stage.fdo index 9b4379d..f248a63 100644 --- a/lib/filter/sim/tb_fir_stage.fdo +++ b/lib/filter/sim/tb_fir_stage.fdo @@ -1,5 +1,8 @@ +vmap ieee_proposed ../../../Common/sim/ieee_proposed + vlib work -vcom -explicit -93 "../../../lib/fixed/fixed_pkg_c.vhd" +vcom -explicit -93 "../../../lib/misc/utils_pkg.vhd" +vcom -explicit -93 "../../../lib/fixed/fixed_util_pkg.vhd" vcom -explicit -93 "../../../lib/PCK_FIO-2002.7/PCK_FIO_1993.vhd" vcom -explicit -93 "../../../lib/PCK_FIO-2002.7/PCK_FIO_1993_BODY.vhd" vcom -explicit -93 "../src/filter_pkg.vhd" diff --git a/lib/filter/src/filter_pkg.vhd b/lib/filter/src/filter_pkg.vhd index 22be814..1341ed0 100644 --- a/lib/filter/src/filter_pkg.vhd +++ b/lib/filter/src/filter_pkg.vhd @@ -22,7 +22,6 @@ package filter_pkg is function FilterMean (x : real_array_t) return real; function FilterScale (x : real_array_t; scale : real) return real_array_t; function FilterTestCoef (N : positive) return real_array_t; - function NextPowerOfTwo(x : real) return natural; end; -- package filter_pkg; @@ -216,12 +215,5 @@ package body filter_pkg is end FilterMean; - ------------------------------------------------------------------------------- - function NextPowerOfTwo(x : real) return natural is - begin - return integer(ceil(log2(x))); - - end NextPowerOfTwo; - ------------------------------------------------------------------------------- end; -- package filter_pkg; diff --git a/lib/filter/src/fir_iterative.vhd b/lib/filter/src/fir_iterative.vhd index 24805fd..45133ff 100644 --- a/lib/filter/src/fir_iterative.vhd +++ b/lib/filter/src/fir_iterative.vhd @@ -21,7 +21,13 @@ library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.MATH_REAL.ALL; USE ieee.numeric_std.ALL; -use work.fixed_pkg.all; + +library ieee_proposed; +use ieee_proposed.math_utility_pkg.all; +use ieee_proposed.fixed_pkg.all; + +library work; +use work.fixed_util_pkg.all; use work.fir_stage_pkg.all; use work.fir_iterative_pkg.all; @@ -121,7 +127,7 @@ architecture Behavioral of fir_iterative is begin h_addr_out <= to_unsigned(h_addr, h_addr_bits); - x_stage <= resize(xmem_dout, x_stage, false, false); + x_stage <= resize(xmem_dout, x_stage, fixed_wrap, fixed_truncate); ---------------------------------------- process (clk) @@ -144,7 +150,7 @@ begin if srst = '1' then y_dout <= to_sfixed(0, sproto(nbits_out, nbits_out_frac)); elsif y_reg_valid = '1' then - y_dout <= resize(y_out_reg, sproto(nbits_out, nbits_out_frac), rounding, saturating); + y_dout <= resize(y_out_reg, sproto(nbits_out, nbits_out_frac), fixed_wrap, fixed_round); y_dout_valid <= '1'; end if; end if; diff --git a/lib/filter/src/fir_iterative_pkg.vhd b/lib/filter/src/fir_iterative_pkg.vhd index 3d71626..c00d0cf 100644 --- a/lib/filter/src/fir_iterative_pkg.vhd +++ b/lib/filter/src/fir_iterative_pkg.vhd @@ -3,7 +3,14 @@ library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.MATH_REAL.ALL; use ieee.numeric_std.all; -use work.fixed_pkg.all; + +library ieee_proposed; +use ieee_proposed.math_utility_pkg.all; +use ieee_proposed.fixed_pkg.all; + +library work; +use work.utils_pkg.all; +use work.fixed_util_pkg.all; use work.filter_pkg.all; ------------------------------------------------------------------------------- @@ -22,7 +29,7 @@ package body fir_iterative_pkg is function taps_nbits(ntaps : integer; mode : fir_iterative_mode_t) return integer is variable res : integer; begin - res := NextPowerOfTwo(real(ntaps_addr(ntaps, mode))); + res := integer(NextPowerOfTwo(real(ntaps_addr(ntaps, mode)))); return res; end taps_nbits; diff --git a/lib/filter/src/fir_parallel.vhd b/lib/filter/src/fir_parallel.vhd index 8cb969b..73a1da1 100644 --- a/lib/filter/src/fir_parallel.vhd +++ b/lib/filter/src/fir_parallel.vhd @@ -21,7 +21,14 @@ library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.MATH_REAL.ALL; USE ieee.numeric_std.ALL; -use work.fixed_pkg.all; + +library ieee_proposed; +use ieee_proposed.math_utility_pkg.all; +use ieee_proposed.fixed_pkg.all; + +library work; +use work.utils_pkg.all; +use work.fixed_util_pkg.all; use work.fir_stage_pkg.all; use work.fir_parallel_pkg.all; diff --git a/lib/filter/src/fir_parallel_pkg.vhd b/lib/filter/src/fir_parallel_pkg.vhd index 4b293e3..1925ae7 100644 --- a/lib/filter/src/fir_parallel_pkg.vhd +++ b/lib/filter/src/fir_parallel_pkg.vhd @@ -2,7 +2,14 @@ library IEEE; use IEEE.STD_LOGIC_1164.ALL; use ieee.numeric_std.all; -use work.fixed_pkg.all; + +library ieee_proposed; +use ieee_proposed.math_utility_pkg.all; +use ieee_proposed.fixed_pkg.all; + +library work; +use work.utils_pkg.all; +use work.fixed_util_pkg.all; use work.filter_pkg.all; use work.fir_stage_pkg.all; diff --git a/lib/filter/src/fir_stage.vhd b/lib/filter/src/fir_stage.vhd index c8c4a7c..8001b7a 100644 --- a/lib/filter/src/fir_stage.vhd +++ b/lib/filter/src/fir_stage.vhd @@ -21,7 +21,14 @@ library IEEE; use IEEE.STD_LOGIC_1164.ALL; use IEEE.MATH_REAL.ALL; USE ieee.numeric_std.ALL; -use work.fixed_pkg.all; + +library ieee_proposed; +use ieee_proposed.math_utility_pkg.all; +use ieee_proposed.fixed_pkg.all; + +library work; +use work.utils_pkg.all; +use work.fixed_util_pkg.all; use work.fir_stage_pkg.all; ---- Uncomment the following library declaration if instantiating @@ -132,7 +139,7 @@ begin proc_out_reg: process(srst, clk, p_valid, prod, yin) variable yout : sfixed(sproto(nbits_out, nbits_out_frac)'high downto sproto(nbits_out, nbits_out_frac)'low); begin - yout := resize(yin + prod, yout, rounding, saturating); + yout := resize(yin + prod, yout, fixed_wrap, fixed_truncate); -- if rising_edge(clk) then -- if srst = '1' or y_out_clr = '1' then -- y_out <= to_sfixed(0, yout); diff --git a/lib/filter/src/fir_stage_pkg.vhd b/lib/filter/src/fir_stage_pkg.vhd index 8bccba2..c6408b8 100644 --- a/lib/filter/src/fir_stage_pkg.vhd +++ b/lib/filter/src/fir_stage_pkg.vhd @@ -2,37 +2,17 @@ library IEEE; use IEEE.STD_LOGIC_1164.ALL; use ieee.numeric_std.all; -use work.fixed_pkg.all; + +library ieee_proposed; +use ieee_proposed.math_utility_pkg.all; +use ieee_proposed.fixed_pkg.all; package fir_stage_pkg is type fir_stage_mode_t is (transposed, systolic); - ------------------------------------------------------------- - -- 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; - end; -- package fir_stage_pkg; package body fir_stage_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; - end; -- package fir_stage_pkg; diff --git a/lib/filter/src/tb_fir_iterative.vhd b/lib/filter/src/tb_fir_iterative.vhd index 2621a05..b1a6fd9 100644 --- a/lib/filter/src/tb_fir_iterative.vhd +++ b/lib/filter/src/tb_fir_iterative.vhd @@ -17,8 +17,12 @@ use IEEE.MATH_REAL.ALL; USE ieee.numeric_std.ALL; use std.textio.all; -- Imports the standard textio package. +library ieee_proposed; +use ieee_proposed.math_utility_pkg.all; +use ieee_proposed.fixed_pkg.all; + library work; -use work.fixed_pkg.all; +use work.fixed_util_pkg.all; use work.filter_pkg.all; use work.fir_stage_pkg.all; use work.fir_iterative_pkg.all; diff --git a/lib/filter/src/tb_fir_parallel.vhd b/lib/filter/src/tb_fir_parallel.vhd index 51aca29..361df0a 100644 --- a/lib/filter/src/tb_fir_parallel.vhd +++ b/lib/filter/src/tb_fir_parallel.vhd @@ -17,8 +17,12 @@ use IEEE.MATH_REAL.ALL; USE ieee.numeric_std.ALL; use std.textio.all; -- Imports the standard textio package. +library ieee_proposed; +use ieee_proposed.math_utility_pkg.all; +use ieee_proposed.fixed_pkg.all; + library work; -use work.fixed_pkg.all; +use work.fixed_util_pkg.all; use work.fir_stage_pkg.all; use work.fir_parallel_pkg.all; use work.filter_pkg.all; diff --git a/lib/filter/src/tb_fir_stage.vhd b/lib/filter/src/tb_fir_stage.vhd index d676fb8..74ae167 100644 --- a/lib/filter/src/tb_fir_stage.vhd +++ b/lib/filter/src/tb_fir_stage.vhd @@ -17,8 +17,12 @@ use IEEE.MATH_REAL.ALL; USE ieee.numeric_std.ALL; use std.textio.all; -- Imports the standard textio package. +library ieee_proposed; +use ieee_proposed.math_utility_pkg.all; +use ieee_proposed.fixed_pkg.all; + library work; -use work.fixed_pkg.all; +use work.fixed_util_pkg.all; use work.fir_stage_pkg.all; use work.filter_pkg.all; @@ -101,7 +105,7 @@ ARCHITECTURE behavior OF tb_fir_stage IS variable res : stages_t(x_real'range); begin for i in x_real'range loop - res(i) := to_sfixed(x_real(i), res(i), true, true); + res(i) := to_sfixed(x_real(i), res(i), fixed_wrap, fixed_round); end loop; return res;