Timer.v

On a go trigger pulse, a done pulse is output a programmed interval later. The internal interval counter and a busy signal are available, and the counter may count either up or down. A multi-level trigger may be input (Trigger.v).

Ports

clkinputThe clock input.
intervalinputThe timed interval.
resetinputReset input, which restores the idle state to both the timer itself, and its trigger logic (Trigger.v).
goinputA vector of triggers.
eninputEnable; the state is frozen when not asserted.
busyoutputTimer is running; not asserted while awaiting triggers.
trigstate outputThe state of the trigger.
doneoutputDone; asserted when the interval is counted.
ctroutput The counter, which counts on each enabled clock cycle.

Parameters

width32The bit width of the internal counter; must be large enough to hold interval-1. The width of interval is one greater.
gobits1The number of triggers; see Trigger.v.
direction "up"The direction ctr counts, either "up" or "down".

Notes

Example instantiation:

wire                    tr[1:0];
wire			ctr[11:0];
Timer
    #(.width(12))
    timer_inst (
        .clk(clk), 
        .interval(38),		// need not be a constant, nor constant
        .reset(1'b0), 
        .go({arm, go}), 	// can have one or more triggers (see Trigger.v)
        .en(1'b1),		// need not be constant
        .trigstate(tr),
        .done(done),
        .ctr(ctr)
    );