Accumulator.v

This module sum samples into an accumulator for a powr-of-two number of samples. Input and output bit widths are specified, with the msb of the output aligned with the top of the accumulator. Accumulator precision bits are specified, which are lsbs of the accumulator that participate in the accumulation but are discarded at the end of the cycle. An enable input controls on what clock cycles samples are added, and an output signals that the cycle is complete. The accumulator output may be optionally registered.

Accumulator block diagram

Ports | Parameters | Notes | Example

Ports

clkinputThe clock input.
resetinputReset input, which clears the accumulator and resets the module's state to the idle state.
eninputThe enable input. An addition to the accumulator occurs when this signal is high.
goinputA pulse on this port initiates an accumulation cycle. It may also be a multi-bit trigger, as this input is routed to a Trigger module.
ininputThe data input port of w1 bits width.
outoutputThe output port of w2 bits width.
busyoutputThis output indicates that an accumulation cycle is in progress.
doneoutput   Asserts a single-clock pulse indicating that an accumulation cycle has completed and data are valid.

Parameters

Bit alignments

The figure to the right illustrates the meanings of the bit-width parameters.

w1The bit width of the input port (default 16).
w2The bit width of the output port (default 16).
oflThe number of overflow bits (default 10). The number of accumulation clocks is tied to this parameter: cycles = 2ofl.
apb   The number of accumulator precision bits (default 5). These bits on the lsb end of the accumulator participate in the addition of samples, but are discarded at the end of the cycle. This is done to preserve precision of the output.
gbThe number of bits in the go vector, which may be a multi-level trigger. The default is one bit.

Notes

Example instantiation:

wire	[23:0]	counter;
wire		t3, t2, t1, t0;
wire	[31:0]	result;
TripStack #(.dw(24), .tw(3), .cw(5)) ts (
	.clk(clk),	.reset(reset),			.next(next),
	.t(counter),	.trigs({t3, t2, t1, t0}),	.out(result)
);