PoC.arith.scaler
A flexible scaler for fixed-point values. The scaler is implemented for a set of multiplier and divider values. Each individual scaling operation can arbitrarily select one value from each these sets.
The computation calculates: unsigned(arg) * MULS(msel) / DIVS(dsel)
rounded to the nearest (tie upwards) fixed-point result of the same precision
as arg.
The computation is started by asserting start to high for one cycle. If a
computation is running, it will be restarted. The completion of a calculation
is signaled via done. done is high when no computation is in progress.
The result of the last scaling operation is stable and can be read from
res. The weight of the LSB of res is the same as the LSB of arg.
Make sure to tap a sufficient number of result bits in accordance to the
highest scaling ratio to be used in order to avoid a truncation overflow.
Entity Declaration:
1 generic (
2 MULS : T_POSVEC := (0 => 1); -- The set of multipliers to choose from in scaling operations.
3 DIVS : T_POSVEC := (0 => 1) -- The set of divisors to choose from in scaling operations.
4 );
5 port (
6 clk : in std_logic;
7 rst : in std_logic;
8
9 start : in std_logic; -- Start of Computation
10 arg : in std_logic_vector; -- Fixed-point value to be scaled
11 msel : in std_logic_vector(log2ceil(MULS'length)-1 downto 0) := (others => '0');
12 dsel : in std_logic_vector(log2ceil(DIVS'length)-1 downto 0) := (others => '0');
13
14 done : out std_logic; -- Completion
15 res : out std_logic_vector -- Result
16 );
17end entity;