forked from M-Labs/artiq
dds: phase computation fixes
This commit is contained in:
parent
b8bb3d8ca7
commit
03fe71228b
@ -55,26 +55,26 @@ static void dds_set_one(long long int now, long long int ref_time, int channel,
|
||||
{
|
||||
DDS_WRITE(DDS_GPIO, channel);
|
||||
|
||||
if(phase_mode == PHASE_MODE_CONTINUOUS)
|
||||
/* Do not clear phase accumulator on FUD */
|
||||
DDS_WRITE(0x02, 0x00);
|
||||
else
|
||||
/* Clear phase accumulator on FUD */
|
||||
DDS_WRITE(0x02, 0x40);
|
||||
|
||||
DDS_WRITE(DDS_FTW0, ftw & 0xff);
|
||||
DDS_WRITE(DDS_FTW1, (ftw >> 8) & 0xff);
|
||||
DDS_WRITE(DDS_FTW2, (ftw >> 16) & 0xff);
|
||||
DDS_WRITE(DDS_FTW3, (ftw >> 24) & 0xff);
|
||||
|
||||
/* We assume that the RTIO clock is DDS SYNCLK */
|
||||
if(phase_mode == PHASE_MODE_TRACKING)
|
||||
pow += (ref_time >> RTIO_FINE_TS_WIDTH)*ftw >> 18;
|
||||
if(phase_mode != PHASE_MODE_CONTINUOUS) {
|
||||
/* We need the RTIO fine timestamp clock to be phase-locked
|
||||
* to DDS SYNCLK, and divided by an integer DDS_RTIO_CLK_RATIO.
|
||||
*/
|
||||
if(phase_mode == PHASE_MODE_CONTINUOUS) {
|
||||
/* Do not clear phase accumulator on FUD */
|
||||
DDS_WRITE(0x02, 0x00);
|
||||
} else {
|
||||
long long int fud_time;
|
||||
|
||||
/* Clear phase accumulator on FUD */
|
||||
DDS_WRITE(0x02, 0x40);
|
||||
fud_time = now + 2*DURATION_WRITE;
|
||||
pow -= ((ref_time - fud_time) >> RTIO_FINE_TS_WIDTH)*ftw >> 18;
|
||||
pow -= (ref_time - fud_time)*DDS_RTIO_CLK_RATIO*ftw >> 18;
|
||||
if(phase_mode == PHASE_MODE_TRACKING)
|
||||
pow += ref_time*DDS_RTIO_CLK_RATIO*ftw >> 18;
|
||||
}
|
||||
|
||||
DDS_WRITE(DDS_POW0, pow & 0xff);
|
||||
|
@ -93,6 +93,7 @@ class NIST_QC1(MiniSoC, AMPSoC):
|
||||
self.submodules.rtio = rtio.RTIO(rtio_channels,
|
||||
clk_freq=125000000)
|
||||
self.add_constant("RTIO_FINE_TS_WIDTH", self.rtio.fine_ts_width)
|
||||
self.add_constant("DDS_RTIO_CLK_RATIO", 8 >> self.rtio.fine_ts_width)
|
||||
self.submodules.rtio_moninj = rtio.MonInj(rtio_channels)
|
||||
|
||||
if isinstance(platform.toolchain, XilinxVivadoToolchain):
|
||||
|
@ -128,6 +128,7 @@ trce -v 12 -fastpaths -tsi {build_name}.tsi -o {build_name}.twr {build_name}.ncd
|
||||
self.submodules.rtio = rtio.RTIO(rtio_channels,
|
||||
clk_freq=125000000)
|
||||
self.add_constant("RTIO_FINE_TS_WIDTH", self.rtio.fine_ts_width)
|
||||
self.add_constant("DDS_RTIO_CLK_RATIO", 8 >> self.rtio.fine_ts_width)
|
||||
self.submodules.rtio_mon = rtio.MonInj(rtio_channels)
|
||||
|
||||
# CPU connections
|
||||
|
Loading…
Reference in New Issue
Block a user