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: d38014b07ddc
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: 0416da8634ab
Choose a head ref
  • 2 commits
  • 5 files changed
  • 1 contributor

Commits on Mar 12, 2015

  1. Copy the full SHA
    3122623 View commit details
  2. Copy the full SHA
    0416da8 View commit details
Showing with 92 additions and 80 deletions.
  1. +1 −1 artiq/gateware/rtio/core.py
  2. +0 −15 soc/runtime/dds.c
  3. +16 −0 soc/runtime/dds.h
  4. +74 −64 soc/runtime/test_mode.c
  5. +1 −0 soc/targets/artiq_ppro.py
2 changes: 1 addition & 1 deletion artiq/gateware/rtio/core.py
Original file line number Diff line number Diff line change
@@ -294,7 +294,7 @@ def __init__(self, rbus, counter, fine_ts_width, fifo_depth):


class RTIO(Module, AutoCSR):
def __init__(self, phy, clk_freq, counter_width=32,
def __init__(self, phy, clk_freq, counter_width=63,
ofifo_depth=64, ififo_depth=64,
guard_io_cycles=20):
fine_ts_width = get_fine_ts_width(phy.rbus)
15 changes: 0 additions & 15 deletions soc/runtime/dds.c
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
#include <generated/csr.h>
#include <hw/common.h>
#include <stdio.h>

#include "rtio.h"
#include "dds.h"

#define DDS_FTW0 0x0a
#define DDS_FTW1 0x0b
#define DDS_FTW2 0x0c
#define DDS_FTW3 0x0d
#define DDS_POW0 0x0e
#define DDS_POW1 0x0f
#define DDS_GPIO 0x41

#define DDS_READ(addr) \
MMPTR(0xb0000000 + (addr)*4)

#define DDS_WRITE(addr, data) \
MMPTR(0xb0000000 + (addr)*4) = data

void dds_init(void)
{
int i;
16 changes: 16 additions & 0 deletions soc/runtime/dds.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
#ifndef __DDS_H
#define __DDS_H

#include <hw/common.h>

#define DDS_READ(addr) \
MMPTR(0xb0000000 + (addr)*4)

#define DDS_WRITE(addr, data) \
MMPTR(0xb0000000 + (addr)*4) = data

#define DDS_FTW0 0x0a
#define DDS_FTW1 0x0b
#define DDS_FTW2 0x0c
#define DDS_FTW3 0x0d
#define DDS_POW0 0x0e
#define DDS_POW1 0x0f
#define DDS_GPIO 0x41

void dds_init(void);
void dds_phase_clear_en(int channel, int phase_clear_en);
void dds_program(long long int timestamp, int channel,
138 changes: 74 additions & 64 deletions soc/runtime/test_mode.c
Original file line number Diff line number Diff line change
@@ -8,6 +8,8 @@
#include <console.h>

#include "test_mode.h"
#include "rtio.h"
#include "dds.h"

static void leds(char *value)
{
@@ -28,22 +30,13 @@ static void leds(char *value)
leds_out_write(value2);
}

#if 0
static void inputs(void)
{
int inp;

inp = test_inputs_in_read();
printf("0x%02x\n", inp);
}

static void ttlout(char *value)
static void clksrc(char *value)
{
char *c;
unsigned int value2;

if(*value == 0) {
printf("ttlout <value>\n");
printf("clksrc <value>\n");
return;
}

@@ -53,19 +46,34 @@ static void ttlout(char *value)
return;
}

test_ttl_oe_write(0x3);
test_ttl_o_write(value2);
rtiocrg_clock_sel_write(value2);
}

static void ttlin(void)
static void ttlout(char *n, char *value)
{
test_ttl_oe_write(0x0);
printf("0x%04x\n", test_ttl_i_read());
}
char *c;
unsigned int n2, value2;

if((*n == 0)||(*value == 0)) {
printf("ttlout <n> <value>\n");
return;
}

n2 = strtoul(n, &c, 0);
if(*c != 0) {
printf("incorrect channel\n");
return;
}
value2 = strtoul(value, &c, 0);
if(*c != 0) {
printf("incorrect value\n");
return;
}

#define DDS_REG(x) MMPTR(0xb0000000 + 4*(x))
#define DDS_FUD DDS_REG(64)
#define DDS_GPIO DDS_REG(65)
rtio_init();
rtio_oe(n2, 1);
rtio_set(rtio_get_counter() + 8000, n2, value2);
}

static void ddssel(char *n)
{
@@ -79,11 +87,11 @@ static void ddssel(char *n)

n2 = strtoul(n, &c, 0);
if(*c != 0) {
printf("incorrect number\n");
printf("incorrect channel\n");
return;
}

DDS_GPIO = n2;
DDS_WRITE(DDS_GPIO, n2);
}

static void ddsw(char *addr, char *value)
@@ -107,7 +115,7 @@ static void ddsw(char *addr, char *value)
return;
}

DDS_REG(addr2) = value2;
DDS_WRITE(addr2, value2);
}

static void ddsr(char *addr)
@@ -126,12 +134,13 @@ static void ddsr(char *addr)
return;
}

printf("0x%02x\n", DDS_REG(addr2));
printf("0x%02x\n", DDS_READ(addr2));
}

static void ddsfud(void)
{
DDS_FUD = 0;
rtio_init();
rtio_fud(rtio_get_counter() + 8000);
}

static void ddsftw(char *n, char *ftw)
@@ -146,7 +155,7 @@ static void ddsftw(char *n, char *ftw)

n2 = strtoul(n, &c, 0);
if(*c != 0) {
printf("incorrect number\n");
printf("incorrect channel\n");
return;
}
ftw2 = strtoul(ftw, &c, 0);
@@ -155,27 +164,30 @@ static void ddsftw(char *n, char *ftw)
return;
}

DDS_GPIO = n2;
DDS_REG(0x0a) = ftw2 & 0xff;
DDS_REG(0x0b) = (ftw2 >> 8) & 0xff;
DDS_REG(0x0c) = (ftw2 >> 16) & 0xff;
DDS_REG(0x0d) = (ftw2 >> 24) & 0xff;
DDS_FUD = 0;
DDS_WRITE(DDS_GPIO, n2);
DDS_WRITE(DDS_FTW0, ftw2 & 0xff);
DDS_WRITE(DDS_FTW1, (ftw2 >> 8) & 0xff);
DDS_WRITE(DDS_FTW2, (ftw2 >> 16) & 0xff);
DDS_WRITE(DDS_FTW3, (ftw2 >> 24) & 0xff);
ddsfud();
}

static void ddsreset(void)
{
DDS_GPIO |= 1 << 7;
DDS_GPIO &= ~(1 << 7);
unsigned int g;

g = DDS_READ(DDS_GPIO);
DDS_WRITE(DDS_GPIO, g | (1 << 7));
DDS_WRITE(DDS_GPIO, g);
}

static void ddsinit(void)
{
ddsreset();
DDS_REG(0x00) = 0x78;
DDS_REG(0x01) = 0x00;
DDS_REG(0x02) = 0x00;
DDS_REG(0x03) = 0x00;
DDS_WRITE(0x00, 0x78);
DDS_WRITE(0x01, 0x00);
DDS_WRITE(0x02, 0x00);
DDS_WRITE(0x03, 0x00);
ddsfud();
}

@@ -188,20 +200,20 @@ static void ddstest_one(unsigned int i)
};
unsigned int f, g, j;

DDS_GPIO = i;
DDS_WRITE(DDS_GPIO, i);
ddsinit();

for(j=0; j<12; j++) {
f = v[j];
DDS_REG(0x0a) = f & 0xff;
DDS_REG(0x0b) = (f >> 8) & 0xff;
DDS_REG(0x0c) = (f >> 16) & 0xff;
DDS_REG(0x0d) = (f >> 24) & 0xff;
DDS_FUD = 0;
g = DDS_REG(0x0a);
g |= DDS_REG(0x0b) << 8;
g |= DDS_REG(0x0c) << 16;
g |= DDS_REG(0x0d) << 24;
DDS_WRITE(0x0a, f & 0xff);
DDS_WRITE(0x0b, (f >> 8) & 0xff);
DDS_WRITE(0x0c, (f >> 16) & 0xff);
DDS_WRITE(0x0d, (f >> 24) & 0xff);
ddsfud();
g = DDS_READ(0x0a);
g |= DDS_READ(0x0b) << 8;
g |= DDS_READ(0x0c) << 16;
g |= DDS_READ(0x0d) << 24;
if(g != f)
printf("readback fail on DDS %d, 0x%08x != 0x%08x\n", i, g, f);
}
@@ -225,25 +237,23 @@ static void ddstest(char *n)
}
}
}
#endif

static void help(void)
{
puts("ARTIQ DDS/TTL Tester");
puts("Available commands:");
puts("help - this message");
puts("inputs - read inputs");
puts("ttlout <n> - output ttl");
puts("ttlin - read ttl");
puts("ddssel <n> - select a dds");
puts("ddsinit - reset, cfr, fud dds");
puts("ddsreset - reset dds");
puts("ddsw <a> <d> - write to dds register");
puts("ddsr <a> - read dds register");
puts("clksrc <n> - select RTIO clock source");
puts("ttlout <n> <v> - output TTL");
puts("ddssel <n> - select a DDS");
puts("ddsinit - reset, config, FUD DDS");
puts("ddsreset - reset DDS");
puts("ddsw <a> <d> - write to DDS register");
puts("ddsr <a> - read DDS register");
puts("ddsfud - pulse FUD");
puts("ddsftw <n> <d> - write FTW");
puts("ddstest <n> - perform test sequence on dds");
puts("leds <n> - set leds");
puts("ddstest <n> - perform test sequence on DDS");
puts("leds <n> - set LEDs");
}

static void readstr(char *s, int size)
@@ -303,10 +313,10 @@ static void do_command(char *c)

if(strcmp(token, "help") == 0) help();
else if(strcmp(token, "leds") == 0) leds(get_token(&c));
/*
else if(strcmp(token, "inputs") == 0) inputs();
else if(strcmp(token, "ttlout") == 0) ttlout(get_token(&c));
else if(strcmp(token, "ttlin") == 0) ttlin();

else if(strcmp(token, "clksrc") == 0) clksrc(get_token(&c));

else if(strcmp(token, "ttlout") == 0) ttlout(get_token(&c), get_token(&c));

else if(strcmp(token, "ddssel") == 0) ddssel(get_token(&c));
else if(strcmp(token, "ddsw") == 0) ddsw(get_token(&c), get_token(&c));
@@ -315,7 +325,7 @@ static void do_command(char *c)
else if(strcmp(token, "ddsinit") == 0) ddsinit();
else if(strcmp(token, "ddsfud") == 0) ddsfud();
else if(strcmp(token, "ddsftw") == 0) ddsftw(get_token(&c), get_token(&c));
else if(strcmp(token, "ddstest") == 0) ddstest(get_token(&c));*/
else if(strcmp(token, "ddstest") == 0) ddstest(get_token(&c));

else if(strcmp(token, "") != 0)
printf("Command not found\n");
1 change: 1 addition & 0 deletions soc/targets/artiq_ppro.py
Original file line number Diff line number Diff line change
@@ -119,6 +119,7 @@ def __init__(self, platform, cpu_type="or1k",
output_only_pads=set(rtio_outs))
self.submodules.rtio = rtio.RTIO(self.rtiophy,
clk_freq=125000000,
counter_width=32,
ififo_depth=512)

rtio_csrs = self.rtio.get_csrs()