Divide.v

This module implements unsigned integer division returning a quotient and remainder. The quotient is optionally rounded.

Ports

clkinputThe clock input.
resetinputThe reset input restores the idle state.
goinputA vector of triggers (see Trigger.v).
eninputEnable; the state is frozen when not asserted.
dividendinputNumber to be divided.
divisorinputDoing the dividing.
quotientoutputQuotient.
remainderoutputRemainder.
roundoutputThe remainder is greater than half the divisor.
busyoutputDivision is in progress.
doneoutputDone; asserted when the division is completed and data are valid.
erroroutput    Error; asserted in lieu of done if there was an overflow or the quotient is zero.

Parameters

width116The bit width of the dividend.
width216The bit width of the divisor.
width316The bit width of the quotient and remainder.
rounding"no"Whether to round the quotient ("yes" or "no").

Notes

Example instantiation in Verilog:

wire		[21:0]	dividend;
wire		[ 7:0]	divisor;
wire		[ 9:0]	q;
wire		[ 9:0]	r;

Divide
    #(.width1(22), .width2(8), .width3(10))
    timer_inst (
        .clk(clk), 
        .reset(1'b0), 
        .go(go),
        .en(1'b1),
        .dividend(dividend),	// width1
        .divisor(divisor),	// width2
        .quotient(q),		// width3
        .remainder(r),		// width3
        .round(round),		// one bit
        .done(d),		// when quotient, remainder, and round are valid
        .error(e)		// no done when asserted
    );