Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/artiq
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ef96de7d2654
Choose a base ref
...
head repository: m-labs/artiq
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 8082bf14c167
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Jun 21, 2015

  1. dds: all working

    sbourdeauducq committed Jun 21, 2015
    Copy the full SHA
    87ea143 View commit details
  2. Copy the full SHA
    8082bf1 View commit details
Showing with 14 additions and 3 deletions.
  1. +1 −1 artiq/coredevice/dds.py
  2. +13 −2 soc/runtime/dds.c
2 changes: 1 addition & 1 deletion artiq/coredevice/dds.py
Original file line number Diff line number Diff line change
@@ -117,4 +117,4 @@ def set(self, frequency, phase_mode=PHASE_MODE_DEFAULT, phase_offset=0):

syscall("dds_set", time_to_cycles(now()), self.channel,
self.frequency_to_ftw(frequency), round(phase_offset*2**14),
self.phase_mode)
phase_mode)
15 changes: 13 additions & 2 deletions soc/runtime/dds.c
Original file line number Diff line number Diff line change
@@ -3,9 +3,10 @@

#include "exceptions.h"
#include "rtio.h"
#include "log.h"
#include "dds.h"

#define DURATION_WRITE 5
#define DURATION_WRITE (5 << RTIO_FINE_TS_WIDTH)
#define DURATION_INIT (7*DURATION_WRITE) /* not counting FUD */
#define DURATION_PROGRAM (8*DURATION_WRITE) /* not counting FUD */

@@ -50,9 +51,17 @@ void dds_init(long long int timestamp, int channel)
DDS_WRITE(DDS_FUD, 0);
}

static void dds_set_one(long long int now, long long int ref_time, int channel,
/* Compensation to keep phase continuity when switching from absolute or tracking
* to continuous phase mode. */
static unsigned int continuous_phase_comp[DDS_CHANNEL_COUNT];

static void dds_set_one(long long int now, long long int ref_time, unsigned int channel,
unsigned int ftw, unsigned int pow, int phase_mode)
{
if(channel >= DDS_CHANNEL_COUNT) {
log("Attempted to set invalid DDS channel");
return;
}
DDS_WRITE(DDS_GPIO, channel);

DDS_WRITE(DDS_FTW0, ftw & 0xff);
@@ -66,6 +75,7 @@ static void dds_set_one(long long int now, long long int ref_time, int channel,
if(phase_mode == PHASE_MODE_CONTINUOUS) {
/* Do not clear phase accumulator on FUD */
DDS_WRITE(0x02, 0x00);
pow += continuous_phase_comp[channel];
} else {
long long int fud_time;

@@ -75,6 +85,7 @@ static void dds_set_one(long long int now, long long int ref_time, int channel,
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;
continuous_phase_comp[channel] = pow;
}

DDS_WRITE(DDS_POW0, pow & 0xff);