PhaseDifference.v

This module computes the difference between the phases of two I/Q data streams and adds an offset. The phases and magnitudes of the individual inputs are available. When the input signals are not above a threshold, however, the phases and magnitudes are not computed. Instead, a done pulse is immediately generated instead of waiting for the Cordic computation to complete, without corresponding valid pulse.

Ports | Parameters | Notes | Example | Simulation

Ports

clkinputThe clock input.
goinputA pulse initiates the computation.
rf1inputThe first I/Q data stream input. Its width is given by the mwidth parameter.
rf2inputThe second I/Q data stream input. Its width is given by the mwidth parameter.
offsetinputA phase offset that is added to the phase difference. Its width is given by the pwidth parameter.
mag1outputThe magnitude of the first data stream as computed by the Cordic module. Its width is given by the mwidth parameter. It is valid on a valid pulse. If either signal is below threshold, however, it is not computed.
mag2outputThe magnitude of the second data stream as computed by the Cordic module. Its width is given by the mwidth parameter. It is valid on a valid pulse. If either signal is below threshold, however, it is not computed.
phase1outputThe phase of the first data stream as computed by the Cordic module. Its width is given by the pwidth parameter. It is valid on a valid pulse. If either signal is below threshold, however, it is not computed.
phase2output   The phase of the second data stream as computed by the Cordic module. Its width is given by the pwidth parameter. It is valid on a valid pulse. If either signal is below threshold, however, it is not computed.
phaseoutputThe difference between phase1 and phase2 plus offset. Its width is given by the pwidth parameter. It is valid on a valid pulse. If either signal is below threshold, however, it is not computed.
validoutputA pulse that when asserted indicates that a Cordic conversion has completed and data are valid. It is simultaneous with the done pulse.
doneoutputWhen both rf inputs were previously above threshold, indicates that a Cordic conversion has completed and the output data are valid. The valid signal is simultaneous. When either rf input was not above threshold, then done immediately pulses without a corresponding valid pulse.

Parameters

mwidth15Bit widths of the rf1 and rf2 inputs, and the mag1 and mag2 outputs.
pwidth14Bit widths of the offset input, and the phase1, phase2, and phase outputs.
msbs4The number of most-significant bits (msbs) of rf1 and rf2 that are tested for below threshold, i.e., if those msbs are all zeros or all ones on one or the other of those inputs, then the inputs are flagged as below threshold, the Cordic computation is bypassed, and the done pulse is generated without a corresponding valid pulse.

Notes

Example instantiation:

localparam	m2 = 15, pw = 13;
wire		[mw-1:0]	mag1, mag2;
wire		[pw-1:0]	phase1, phase2, phase;
wire				valid1, done;
wire				uv1, uv2, uv;
PhaseDifference
	#(.mwidth(mw), .pwidth(pw), .msbs(5))
	pe1 (
		.clk(clk),
		.go(gonow),
		.rf1(rf1),		// multiplex the I and Q parts
		.rf2(rf2),		// flipped vector
		.offset(0),		// no offset
		.uv1(uv1),		.uv2(uv2),		.uv(uv),
		.mag1(mag1),		.mag2(mag2),
		.phase1(phase1),	.phase2(phase2),	.phase(phase),
		.valid(valid1),		.done(done)
	);

Plots (click to shrink/enlarge)

Plot of a simulation. The inputs are vectors increasing in a spiral pattern, the first rotating counter clockwise, and the second clockwise. Magnitudes and phases of each are plotted.

Timing