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
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
entity arith_scaler is
  generic (
    MULS : T_POSVEC := (0 => 1);  -- The set of multipliers to choose from in scaling operations.
    DIVS : T_POSVEC := (0 => 1)   -- The set of divisors to choose from in scaling operations.
  );
  port (
    clk  : in std_logic;
    rst  : in std_logic;
    
    start : in  std_logic;          -- Start of Computation
    arg  : in std_logic_vector;     -- Fixed-point value to be scaled
    msel  : in  std_logic_vector(log2ceil(MULS'length)-1 downto 0) := (others => '0');
    dsel  : in  std_logic_vector(log2ceil(DIVS'length)-1 downto 0) := (others => '0');
    
    done  : out std_logic;          -- Completion
    res   : out std_logic_vector    -- Result
  );
end entity arith_scaler;