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
clk | input | The clock input. |
go | input | A pulse initiates the computation. |
rf1 | input | The first I/Q data stream input. Its width is given by the mwidth parameter. |
rf2 | input | The second I/Q data stream input. Its width is given by the mwidth parameter. |
offset | input | A phase offset that is added to the phase difference. Its width is given by the pwidth parameter. |
mag1 | output | The 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. |
mag2 | output | The 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. |
phase1 | output | The 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. |
phase2 | output | 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. |
phase | output | The 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. |
valid | output | A pulse that when asserted indicates that a Cordic conversion has completed and data are valid. It is simultaneous with the done pulse. |
done | output | When 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. |
mwidth | 15 | Bit widths of the rf1 and rf2 inputs, and the mag1 and mag2 outputs. |
pwidth | 14 | Bit widths of the offset input, and the phase1, phase2, and phase outputs. |
msbs | 4 | The 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. |
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) );
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.