TripStack.v

This module is an event recorder that records the source and time stamp of events as they occur. It takes as input a set of logic signals that when active each signals an event, binary enclodes the active input with highest priority, and records that code in a register file (fifo) along with an externally provided clock (time stamp) and sequence number. The fifo is later read out by external logic clocking the next port while reading the out port. Total width of the fifo is 32 bits, while the depth is selectible by a parameter.

Ports | Parameters | Notes | Example | Timing diagram

Ports

clkinputThe clock input.
resetinputReset input. The signal clears the sequence counter and a bit that is set during readout.
nextinputThe signal exposes the next record of the fifo during readout.
tinputAn input recorded along with the encoded trigger and sequence number. This port is not in any way interpreted, but is presumably a counter that when recorded serves as a time stamp.
trigsinputThe trigger inputs that are encoded and recorded in the fifo.
outoutputThe output of the fifo.
countoutputThis is the count of events in the fifo. The fifo is full when this count equals depth. Its bit width is cw.
armedoutput   When asserted, indicates that the module is armed, i.e., capable of capturing events. It is not armed when 1) full, and 2) being read out. It is rearmed by a reset.

Parameters

dw24The bit width of the time (t) port.
tw4The base-two log of the number of triggers in the vector trigs. The number of triggers should be a power of two.
cwtw+1The width of the sequence counter.
stackdepth2cw-1The depth of the fifo. It should be less than 2cw.
detectedge   "no"Normally events are logged on every clock cycle that an input is high. But when detectedge is not "no", an event is recorded only when an input changes to high.

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)
);

Timing diagram (click to enlarge/shrink)