Module math

This document contains technical documentation for the math module.

math_pkg.vhd

View source code on github.com.

Package with some common mathematical functions.

unsigned_divider.vhd

View source code on github.com.

component unsigned_divider is
  generic (
    dividend_width : positive;
    divisor_width : positive
  );
  port (
    clk : in std_ulogic;
    --# {{}}
    input_ready : out std_ulogic;
    input_valid : in std_ulogic;
    dividend : in u_unsigned;
    divisor : in u_unsigned;
    --# {{}}
    result_ready : in std_ulogic;
    result_valid : out std_ulogic;
    quotient : out u_unsigned;
    remainder : out u_unsigned
  );
end component;

Calculates

dividend / divisor = quotient + remainder / divisor

This is a bit serial divider. Algorithm is the same as long division from elementary school, but with number base two. Latency scales linearly with dividend_width.