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: a303293e8f8a
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: 2449348f3142
Choose a head ref
  • 3 commits
  • 5 files changed
  • 1 contributor

Commits on Oct 13, 2014

  1. py2llvm/ast_body: pep8

    sbourdeauducq committed Oct 13, 2014
    Copy the full SHA
    594b3dd View commit details

Commits on Oct 14, 2014

  1. Copy the full SHA
    7d48ef2 View commit details
  2. Copy the full SHA
    2449348 View commit details
Showing with 58 additions and 59 deletions.
  1. +3 −1 artiq/devices/runtime.py
  2. +9 −6 artiq/py2llvm/ast_body.py
  3. +5 −52 soc/runtime/dds.c
  4. +38 −0 soc/runtime/rtio.c
  5. +3 −0 soc/runtime/rtio.h
4 changes: 3 additions & 1 deletion artiq/devices/runtime.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from fractions import Fraction

from llvm import core as lc
from llvm import target as lt
@@ -138,7 +139,8 @@ def _debug_dump_obj(obj):
class Environment(LinkInterface):
def __init__(self, ref_period):
self.ref_period = ref_period
self.initial_time = 4000
# allow 1ms for all initial DDS programming
self.initial_time = int(Fraction(1, 1000)/self.ref_period)

def emit_object(self):
tm = lt.TargetMachine.new(triple="or1k", cpu="generic")
15 changes: 9 additions & 6 deletions artiq/py2llvm/ast_body.py
Original file line number Diff line number Diff line change
@@ -150,14 +150,13 @@ def _visit_expr_BoolOp(self, node):

return result


def _visit_expr_Compare(self, node):
comparisons = []
old_comparator = self.visit_expression(node.left)
for op, comparator_a in zip(node.ops, node.comparators):
comparator = self.visit_expression(comparator_a)
comparison = _ast_cmps[type(op)](old_comparator, comparator,
self.builder)
self.builder)
comparisons.append(comparison)
old_comparator = comparator
r = comparisons[0]
@@ -367,7 +366,8 @@ def _visit_stmt_Pass(self, node):

def _visit_stmt_Raise(self, node):
if self._active_exception_stack:
finally_block, propagate, propagate_eid = self._active_exception_stack[-1]
finally_block, propagate, propagate_eid = (
self._active_exception_stack[-1])
self.builder.store(lc.Constant.int(lc.Type.int(1), 1), propagate)
if node.exc is not None:
eid = lc.Constant.int(lc.Type.int(), node.exc.args[0].n)
@@ -377,7 +377,8 @@ def _visit_stmt_Raise(self, node):
eid = lc.Constant.int(lc.Type.int(), node.exc.args[0].n)
self.env.build_raise(self.builder, eid)

def _handle_exception(self, function, finally_block, propagate, propagate_eid, handlers):
def _handle_exception(self, function, finally_block,
propagate, propagate_eid, handlers):
eid = self.env.build_getid(self.builder)
self._active_exception_stack.append(
(finally_block, propagate, propagate_eid))
@@ -422,9 +423,11 @@ def _visit_stmt_Try(self, node):
exc_block = function.append_basic_block("try_exc")
finally_block = function.append_basic_block("try_finally")

propagate = self.builder.alloca(lc.Type.int(1), name="propagate")
propagate = self.builder.alloca(lc.Type.int(1),
name="propagate")
self.builder.store(lc.Constant.int(lc.Type.int(1), 0), propagate)
propagate_eid = self.builder.alloca(lc.Type.int(), name="propagate_eid")
propagate_eid = self.builder.alloca(lc.Type.int(),
name="propagate_eid")
exception_occured = self.env.build_catch(self.builder)
self.builder.cbranch(exception_occured, exc_block, noexc_block)

57 changes: 5 additions & 52 deletions soc/runtime/dds.c
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
#include <hw/common.h>
#include <stdio.h>

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

#define DDS_FTW0 0x0a
@@ -17,53 +17,6 @@
#define DDS_WRITE(addr, data) \
MMPTR(0xb0000000 + (addr)*4) = data

#define RTIO_FUD_CHANNEL 4

static void fud_sync(void)
{
rtio_chan_sel_write(RTIO_FUD_CHANNEL);
while(rtio_o_level_read() != 0);
}

static void fud(long long int fud_time)
{
int r;
long long int fud_end_time;
static long long int previous_fud_end_time;

r = rtio_reset_counter_read();
if(r)
previous_fud_end_time = 0;
rtio_reset_counter_write(0);

rtio_chan_sel_write(RTIO_FUD_CHANNEL);
if(fud_time < 0) {
rtio_counter_update_write(1);
fud_time = rtio_counter_read() + 4000;
}
fud_end_time = fud_time + 3*8;
if(fud_time < previous_fud_end_time)
exception_raise(EID_RTIO_SEQUENCE_ERROR);
previous_fud_end_time = fud_end_time;

rtio_o_timestamp_write(fud_time);
rtio_o_value_write(1);
rtio_o_we_write(1);
rtio_o_timestamp_write(fud_end_time);
rtio_o_value_write(0);
rtio_o_we_write(1);
if(rtio_o_error_read()) {
rtio_reset_logic_write(1);
rtio_reset_logic_write(0);
exception_raise(EID_RTIO_UNDERFLOW);
}

if(r) {
fud_sync();
rtio_reset_counter_write(1);
}
}

void dds_init(void)
{
int i;
@@ -75,18 +28,18 @@ void dds_init(void)
DDS_WRITE(0x01, 0x00);
DDS_WRITE(0x02, 0x00);
DDS_WRITE(0x03, 0x00);
fud(-1);
fud_sync();
rtio_fud(-1);
rtio_fud_sync();
}
}

void dds_program(int channel, int ftw, long long int fud_time)
{
fud_sync();
rtio_fud_sync();
DDS_WRITE(DDS_GPIO, channel);
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);
fud(fud_time);
rtio_fud(fud_time);
}
38 changes: 38 additions & 0 deletions soc/runtime/rtio.c
Original file line number Diff line number Diff line change
@@ -3,8 +3,11 @@
#include "exceptions.h"
#include "rtio.h"

long long int previous_fud_end_time;

void rtio_init(void)
{
previous_fud_end_time = 0;
rtio_reset_counter_write(1);
rtio_reset_logic_write(1);
rtio_reset_logic_write(0);
@@ -64,3 +67,38 @@ long long int rtio_get(int channel)
}
return -1;
}

#define RTIO_FUD_CHANNEL 4

void rtio_fud_sync(void)
{
rtio_sync(RTIO_FUD_CHANNEL);
}

void rtio_fud(long long int fud_time)
{
long long int fud_end_time;

rtio_reset_counter_write(0);
rtio_chan_sel_write(RTIO_FUD_CHANNEL);
if(fud_time < 0) {
rtio_counter_update_write(1);
fud_time = rtio_counter_read() + 4000;
}
fud_end_time = fud_time + 3*8;
if(fud_time < previous_fud_end_time)
exception_raise(EID_RTIO_SEQUENCE_ERROR);
previous_fud_end_time = fud_end_time;

rtio_o_timestamp_write(fud_time);
rtio_o_value_write(1);
rtio_o_we_write(1);
rtio_o_timestamp_write(fud_end_time);
rtio_o_value_write(0);
rtio_o_we_write(1);
if(rtio_o_error_read()) {
rtio_reset_logic_write(1);
rtio_reset_logic_write(0);
exception_raise(EID_RTIO_UNDERFLOW);
}
}
3 changes: 3 additions & 0 deletions soc/runtime/rtio.h
Original file line number Diff line number Diff line change
@@ -8,4 +8,7 @@ void rtio_replace(long long int timestamp, int channel, int value);
void rtio_sync(int channel);
long long int rtio_get(int channel);

void rtio_fud_sync(void);
void rtio_fud(long long int fud_time);

#endif /* __RTIO_H */