Divider (divider)

Divides a signed integer by another signed integer.

Design

The mathematical representation of the implementation is given in (133) and (134).

(133)\[q[n] = x[n] / y[n]\]
(134)\[r[n] = x[n] % y[n]\]

In (133) and (134):

  • \(x[n]\) and \(y[n]\) are the input values.

  • \(q[n]\) is the quotient output value, i.e. how many times the y can be subtracted from x.

  • \(r[n]\) is the remainder output value, i.e. what value is left over after y is subtracted from x.

Implementation

The divider is achieved using the non-restoring divider algorithm, with a modification to allow signed values to be used.

The non-restoring divider is the equivalent of long division, but allows the remainder to be negative or positive on the completion of a single bit position.

This primitive is not pipelined, therefore takes data_width_g cycles to undertake the calculation, with an additional clock for input and outputting the data. As this primitive takes multiple clock cycles, valid flags are provided to mark when a calculation is completed.

Interface

Generics

  • data_width_g (integer): Width of the divider.

  • method_g (string): Method of division to used. (Should be one of truncate, or floor)

Ports

  • clk (std_logic), in: Clock. Inputs and outputs registered on rising edge.

  • reset (std_logic), in: Reset. Active high, synchronous with rising edge of clock.

  • clk_en (std_logic), in: Enable. Primitive enabled when high.

  • data_in_valid (std_logic), in : Indicates that the value at numerator and denominator are both valid.

  • data_in_ready (std_logic), out: Indicates that the core is capable of taking input data.

  • numerator (signed, data_width_g), in : Numerator to use in the divider.

  • denominator (signed, data_width_g), in : Denominator to use in the divider.

  • data_valid_out (std_logic), out: Indicates that quotient and remainder are valid.

  • quotient (signed, data_width_g), out: Quotient of the divider

  • remainder (signed, data_width_g), out: Remainder of the divider

Dependencies

The dependencies to other elements in OpenCPI are:

  • None.

There is also a dependency on:

  • ieee.std_logic_1164

  • ieee.numeric_std

Limitations

Limitations of divider are:

  • None.