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: 7466a4d9a913
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: 85ecb900dfd9
Choose a head ref
  • 3 commits
  • 4 files changed
  • 1 contributor

Commits on May 7, 2016

  1. Copy the full SHA
    d365ce8 View commit details
  2. Copy the full SHA
    18b6718 View commit details
  3. Copy the full SHA
    85ecb90 View commit details
Showing with 45 additions and 64 deletions.
  1. +3 −2 artiq/examples/master/repository/coredevice_examples/photon_histogram.py
  2. +41 −54 artiq/runtime/liblwip/liteethif.c
  3. +0 −4 artiq/runtime/liblwip/liteethif.h
  4. +1 −4 artiq/runtime/main.c
Original file line number Diff line number Diff line change
@@ -13,8 +13,8 @@ def build(self):
self.setattr_device("bdd_sw")
self.setattr_device("pmt")

self.setattr_argument("nbins", NumberValue(100))
self.setattr_argument("repeats", NumberValue(100))
self.setattr_argument("nbins", NumberValue(100, ndecimals=0, step=1))
self.setattr_argument("repeats", NumberValue(100, ndecimals=0, step=1))

self.setattr_dataset("cool_f", 230*MHz)
self.setattr_dataset("detect_f", 220*MHz)
@@ -54,6 +54,7 @@ def run(self):
total = 0

for i in range(self.repeats):
delay(0.5*ms)
n = self.cool_detect()
if n >= self.nbins:
n = self.nbins - 1
95 changes: 41 additions & 54 deletions artiq/runtime/liblwip/liteethif.c
Original file line number Diff line number Diff line change
@@ -15,9 +15,6 @@
#include <hw/flags.h>
#include <hw/ethmac_mem.h>

static unsigned int rxslot;
static unsigned int rxlen;
static char *rxbuffer;
static char *rxbuffer0;
static char *rxbuffer1;
static unsigned int txslot;
@@ -29,31 +26,6 @@ static char *txbuffer1;
#define IFNAME0 'e'
#define IFNAME1 't'

static void liteeth_low_level_init(struct netif *netif)
{
int i;

netif->hwaddr_len = 6;
for(i=0;i<netif->hwaddr_len;i++)
netif->hwaddr[i] = macadr[i];
netif->mtu = 1514;
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP;

ethmac_sram_reader_ev_pending_write(ETHMAC_EV_SRAM_READER);
ethmac_sram_writer_ev_pending_write(ETHMAC_EV_SRAM_WRITER);

rxbuffer0 = (char *)ETHMAC_RX0_BASE;
rxbuffer1 = (char *)ETHMAC_RX1_BASE;
txbuffer0 = (char *)ETHMAC_TX0_BASE;
txbuffer1 = (char *)ETHMAC_TX1_BASE;

rxslot = 0;
txslot = 0;

rxbuffer = rxbuffer0;
txbuffer = txbuffer0;
}

static err_t liteeth_low_level_output(struct netif *netif, struct pbuf *p)
{
struct pbuf *q;
@@ -86,26 +58,36 @@ static err_t liteeth_low_level_output(struct netif *netif, struct pbuf *p)

static struct pbuf *liteeth_low_level_input(struct netif *netif)
{
unsigned int rxslot;
unsigned int rxlen;
char *rxbuffer;
struct pbuf *p, *q;

rxslot = ethmac_sram_writer_slot_read();
rxlen = ethmac_sram_writer_length_read();
if(rxslot)
rxbuffer = rxbuffer1;
else
rxbuffer = rxbuffer0;

p = pbuf_alloc(PBUF_RAW, rxlen, PBUF_POOL);
q = p;
while(q) {
memcpy(q->payload, rxbuffer, q->len);
rxbuffer += q->len;
if(q->tot_len != q->len)
q = q->next;
else
q = NULL;
p = NULL;

if(ethmac_sram_writer_ev_pending_read() & ETHMAC_EV_SRAM_WRITER) {
rxslot = ethmac_sram_writer_slot_read();
rxlen = ethmac_sram_writer_length_read();
/* dest MAC + source MAC + 802.1Q + ethertype + payload (MTU) */
if(rxlen <= (netif->mtu + 18)) {
if(rxslot)
rxbuffer = rxbuffer1;
else
rxbuffer = rxbuffer0;

p = pbuf_alloc(PBUF_RAW, rxlen, PBUF_POOL);
q = p;
while(q) {
memcpy(q->payload, rxbuffer, q->len);
rxbuffer += q->len;
if(q->tot_len != q->len)
q = q->next;
else
q = NULL;
}
}
ethmac_sram_writer_ev_pending_write(ETHMAC_EV_SRAM_WRITER);
}

return p;
}

@@ -119,23 +101,28 @@ void liteeth_input(struct netif *netif)

err_t liteeth_init(struct netif *netif)
{
struct liteethif *liteethif;

liteethif = mem_malloc(sizeof(struct liteethif));
if(liteethif == NULL)
return ERR_MEM;
netif->state = liteethif;
int i;

netif->hwaddr_len = 6;
for(i=0;i<netif->hwaddr_len;i++)
netif->hwaddr[i] = macadr[i];
netif->name[0] = IFNAME0;
netif->name[1] = IFNAME1;
netif->output = etharp_output;
netif->linkoutput = liteeth_low_level_output;
netif->mtu = 1514;
netif->mtu = 1500;
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP;

liteethif->ethaddr = (struct eth_addr *)&(netif->hwaddr[0]);
ethmac_sram_reader_ev_pending_write(ETHMAC_EV_SRAM_READER);
ethmac_sram_writer_ev_pending_write(ETHMAC_EV_SRAM_WRITER);

rxbuffer0 = (char *)ETHMAC_RX0_BASE;
rxbuffer1 = (char *)ETHMAC_RX1_BASE;
txbuffer0 = (char *)ETHMAC_TX0_BASE;
txbuffer1 = (char *)ETHMAC_TX1_BASE;

liteeth_low_level_init(netif);
txslot = 0;
txbuffer = txbuffer0;

return ERR_OK;
}
4 changes: 0 additions & 4 deletions artiq/runtime/liblwip/liteethif.h
Original file line number Diff line number Diff line change
@@ -7,10 +7,6 @@

extern unsigned char macadr[];

struct liteethif {
struct eth_addr *ethaddr;
};

void liteeth_input(struct netif *netif);
err_t liteeth_init(struct netif *netif);

5 changes: 1 addition & 4 deletions artiq/runtime/main.c
Original file line number Diff line number Diff line change
@@ -56,10 +56,7 @@ static void lwip_service(void)
{
sys_check_timeouts();
#ifdef CSR_ETHMAC_BASE
if(ethmac_sram_writer_ev_pending_read() & ETHMAC_EV_SRAM_WRITER) {
liteeth_input(&netif);
ethmac_sram_writer_ev_pending_write(ETHMAC_EV_SRAM_WRITER);
}
liteeth_input(&netif);
#else
if(uart_read_nonblock()) {
u8_t c;