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: 52fe66ee4de2
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: 4c6387929b15
Choose a head ref
  • 3 commits
  • 11 files changed
  • 1 contributor

Commits on Apr 17, 2015

  1. Copy the full SHA
    c1ece33 View commit details
  2. Copy the full SHA
    91cd79a View commit details
  3. Copy the full SHA
    4c63879 View commit details
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "soc/runtime/lwip"]
path = soc/runtime/lwip
url = git://git.savannah.nongnu.org/lwip.git
10 changes: 6 additions & 4 deletions doc/manual/getting_started.rst
Original file line number Diff line number Diff line change
@@ -46,11 +46,14 @@ Modify the code as follows: ::

@kernel
def run(self):
if input_led_state():
s = input_led_state()
self.core.recover_underflow()
if s:
self.led.on()
else:
self.led.off()


You can then turn the LED off and on by entering 0 or 1 at the prompt that appears: ::

$ artiq_run.py led.py
@@ -60,6 +63,8 @@ You can then turn the LED off and on by entering 0 or 1 at the prompt that appea

What happens is the ARTIQ compiler notices that the ``input_led_state`` function does not have a ``@kernel`` decorator and thus must be executed on the host. When the core device calls it, it sends a request to the host to execute it. The host displays the prompt, collects user input, and sends the result back to the core device, which sets the LED state accordingly.

The ``recover_underflow`` call is necessary to waive the real-time requirements of the LED state change (as the ``input_led_state`` function can take an arbitrarily long time). This will become clearer later as we explain timing control.

Algorithmic features
--------------------

@@ -109,18 +114,15 @@ Try reducing the period of the generated waveform until the CPU cannot keep up w
class Tutorial(Experiment, AutoDB):
class DBKeys:
core = Device()
led = Device()
ttl0 = Device()

@kernel
def run(self):
self.led.off()
try:
for i in range(1000000):
self.ttl0.pulse(...)
delay(...)
except RTIOUnderflow:
self.led.on()
print_underflow()

Parallel and sequential blocks
5 changes: 4 additions & 1 deletion soc/runtime/Makefile
Original file line number Diff line number Diff line change
@@ -40,7 +40,8 @@ runtime.elf: $(OBJECTS) libs
$(OBJECTS) \
-L$(MSCDIR)/software/libbase \
-L$(MSCDIR)/software/libcompiler-rt \
-lbase -lcompiler-rt
-Lliblwip \
-lbase -lcompiler-rt -llwip
@chmod -x $@

ksupport.elf: $(OBJECTS_KSUPPORT)
@@ -71,8 +72,10 @@ main.o: main.c
libs:
$(MAKE) -C $(MSCDIR)/software/libcompiler-rt
$(MAKE) -C $(MSCDIR)/software/libbase
$(MAKE) -C liblwip

clean:
$(MAKE) -C liblwip clean
$(RM) $(OBJECTS) $(OBJECTS:.o=.d) $(OBJECTS_KSUPPORT) $(OBJECTS_KSUPPORT:.o=.d)
$(RM) runtime.elf runtime.bin runtime.fbi .*~ *~
$(RM) service_table.h ksupport.elf ksupport.bin
56 changes: 56 additions & 0 deletions soc/runtime/liblwip/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
include $(MSCDIR)/software/common.mak

LWIPDIR=../lwip/src

CFLAGS += $(CPPFLAGS) -I. \
-I$(LWIPDIR)/include \
-I$(LWIPDIR)/include/ipv4

# COREFILES, CORE4FILES: The minimum set of files needed for lwIP.
COREOBJS=$(LWIPDIR)/core/mem.o \
$(LWIPDIR)/core/memp.o \
$(LWIPDIR)/core/netif.o \
$(LWIPDIR)/core/pbuf.o \
$(LWIPDIR)/core/raw.o \
$(LWIPDIR)/core/stats.o \
$(LWIPDIR)/core/sys.o \
$(LWIPDIR)/core/tcp.o \
$(LWIPDIR)/core/tcp_in.o \
$(LWIPDIR)/core/tcp_out.o \
$(LWIPDIR)/core/udp.o \
$(LWIPDIR)/core/dhcp.o \
$(LWIPDIR)/core/inet_chksum.o \
$(LWIPDIR)/core/timers.o \
$(LWIPDIR)/core/init.o

CORE4OBJS=$(LWIPDIR)/core/ipv4/icmp.o \
$(LWIPDIR)/core/ipv4/ip4.o \
$(LWIPDIR)/core/ipv4/ip4_addr.o \
$(LWIPDIR)/core/ipv4/ip_frag.o

# NETIFOBJS: Files implementing various generic network interface functions.
NETIFOBJS=$(LWIPDIR)/netif/etharp.o \
netif/liteethif.o

# LWIPOBJS: All the above.
LWIPOBJS=$(COREOBJS) $(CORE4OBJS) $(NETIFOBJS)
OBJS_LIB+=$(LWIPOBJS)

LWIPLIB=liblwip.a

all: $(LWIPLIB)

.PHONY: all compile clean

%.o: %.c
$(compile-dep)

%.o: %.S
$(assemble)

clean:
rm -f $(LWIPOBJS) $(LWIPOBJS:.o=.d) $(LWIPLIB)

liblwip.a: $(LWIPOBJS)
$(AR) clr liblwip.a $(LWIPOBJS)
$(RANLIB) liblwip.a
60 changes: 60 additions & 0 deletions soc/runtime/liblwip/arch/cc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// This file is Copyright (c) 2015 Florent Kermarrec <florent@enjoy-digital.fr>
// LiteETH lwIP port for ARTIQ
// License: BSD

#ifndef __ARCH_CC_H__
#define __ARCH_CC_H__

/* Include some files for defining library routines */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#define BYTE_ORDER BIG_ENDIAN

/* Define generic types */
typedef unsigned char u8_t;
typedef signed char s8_t;
typedef unsigned short u16_t;
typedef signed short s16_t;
typedef unsigned long u32_t;
typedef signed long s32_t;

typedef u32_t mem_ptr_t;

/* Define (sn)printf formatters for these types */
#define U8_F "c"
#define S8_F "c"
#define X8_F "x"
#define U16_F "u"
#define S16_F "d"
#define X16_F "x"
#define U32_F "u"
#define S32_F "d"
#define X32_F "x"

/* Compiler hints for packing structures */
#define PACK_STRUCT_FIELD(x) x
#define PACK_STRUCT_STRUCT __attribute__((packed))
#define PACK_STRUCT_BEGIN
#define PACK_STRUCT_END

/* prototypes for printf() and abort() */
#include <stdio.h>
#include <stdlib.h>
#include "console.h"
#define pp_printf printf

/* Definitions for ASSERT/DIAG */
#ifdef LWIP_NOASSERT
#define LWIP_PLATFORM_ASSERT(x)
#else
#define LWIP_PLATFORM_ASSERT(x) do {pp_printf("Assertion \"%s\" failed at line %d in %s\n", \
x, __LINE__, __FILE__); } while(0)
#endif

#ifdef LWIP_DEBUG
#define LWIP_PLATFORM_DIAG(x) do {pp_printf x;} while(0)
#endif

#endif /* __ARCH_CC_H__ */
11 changes: 11 additions & 0 deletions soc/runtime/liblwip/arch/perf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// This file is Copyright (c) 2015 Florent Kermarrec <florent@enjoy-digital.fr>
// LiteETH lwIP port for ARTIQ
// License: BSD

#ifndef __ARCH_PERF_H__
#define __ARCH_PERF_H__

#define PERF_START /* null definition */
#define PERF_STOP(x) /* null definition */

#endif /* __ARCH_PERF_H__ */
20 changes: 20 additions & 0 deletions soc/runtime/liblwip/arch/sys_arch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// This file is Copyright (c) 2015 Florent Kermarrec <florent@enjoy-digital.fr>
// LiteETH lwIP port for ARTIQ
// License: BSD

#ifndef __ARCH_SYS_ARCH_H__
#define __ARCH_SYS_ARCH_H__

#define SYS_MBOX_NULL NULL
#define SYS_SEM_NULL NULL

typedef void * sys_prot_t;

typedef void * sys_sem_t;

typedef void * sys_mbox_t;

typedef void * sys_thread_t;

#endif /* __ARCH_SYS_ARCH_H__ */

Loading