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: e0cd45b1bab3
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: e263b6352713
Choose a head ref
  • 3 commits
  • 10 files changed
  • 1 contributor

Commits on Sep 26, 2014

  1. minor cleanups

    sbourdeauducq committed Sep 26, 2014
    Copy the full SHA
    dd6de24 View commit details
  2. Copy the full SHA
    af0cd90 View commit details
  3. Copy the full SHA
    e263b63 View commit details
Showing with 45 additions and 23 deletions.
  1. +6 −4 artiq/devices/corecom_serial.py
  2. +3 −2 artiq/language/core.py
  3. +1 −5 artiq/transforms/lower_units.py
  4. +23 −7 soc/artiqlib/rtio/core.py
  5. +3 −1 soc/runtime/corecom_serial.c
  6. +3 −0 soc/runtime/dds.c
  7. +2 −0 soc/runtime/rtio.c
  8. +1 −1 soc/targets/artiq.py
  9. +1 −1 test/full_stack.py
  10. +2 −2 test/py2llvm.py
10 changes: 6 additions & 4 deletions artiq/devices/corecom_serial.py
Original file line number Diff line number Diff line change
@@ -3,9 +3,9 @@
import struct
import zlib
from enum import Enum
from fractions import Fraction
import logging

from artiq.language import units
from artiq.language import core as core_language
from artiq.devices.runtime import Environment
from artiq.devices import runtime_exceptions
@@ -123,9 +123,11 @@ def get_runtime_env(self):
runtime_id += chr(reply)
if runtime_id != "AROR":
raise UnsupportedDevice("Unsupported runtime ID: "+runtime_id)
(ref_period, ) = struct.unpack(">l", _read_exactly(self.port, 4))
logger.debug("Environment ref_period: {}".format(ref_period))
return Environment(ref_period*units.ps)
(ref_freq_i, ref_freq_fn, ref_freq_fd) = struct.unpack(
">lBB", _read_exactly(self.port, 6))
ref_period = 1/(ref_freq_i + Fraction(ref_freq_fn, ref_freq_fd))
logger.debug("environment ref_period: {}".format(ref_period))
return Environment(ref_period)

def load(self, kcode):
_write_exactly(self.port, struct.pack(
5 changes: 3 additions & 2 deletions artiq/language/core.py
Original file line number Diff line number Diff line change
@@ -330,8 +330,6 @@ def syscall(*args):

_encoded_exceptions = dict()

first_user_eid = 1024


def EncodedException(eid):
"""Represents exceptions on the core device, which are identified
@@ -346,3 +344,6 @@ def __init__(self):
Exception.__init__(self, eid)
_encoded_exceptions[eid] = EncodedException
return EncodedException


first_user_eid = 1024
6 changes: 1 addition & 5 deletions artiq/transforms/lower_units.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import ast

from artiq.transforms.tools import value_to_ast
from artiq.language import units


# TODO:
@@ -41,7 +40,4 @@ def visit_Call(self, node):


def lower_units(func_def, ref_period):
if (not isinstance(ref_period, units.Quantity)
or ref_period.unit is not units.s_unit):
raise units.DimensionError("Reference period not expressed in seconds")
_UnitsLowerer(ref_period.amount).visit(func_def)
_UnitsLowerer(ref_period).visit(func_def)
30 changes: 23 additions & 7 deletions soc/artiqlib/rtio/core.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from fractions import Fraction

from migen.fhdl.std import *
from migen.bank.description import *
from migen.genlib.fifo import SyncFIFO
@@ -138,7 +140,7 @@ def __init__(self, rbus, counter_width, fine_ts_width, fifo_depth):


class RTIO(Module, AutoCSR):
def __init__(self, phy, counter_width=32, ofifo_depth=64, ififo_depth=64):
def __init__(self, phy, clk_freq, counter_width=32, ofifo_depth=64, ififo_depth=64):
fine_ts_width = get_fine_ts_width(phy.rbus)

# Submodules
@@ -173,12 +175,9 @@ def __init__(self, phy, counter_width=32, ofifo_depth=64, ififo_depth=64):
self._r_counter = CSRStatus(counter_width+fine_ts_width)
self._r_counter_update = CSR()

# Counter
self.sync += \
If(self._r_counter_update.re,
self._r_counter.status.eq(Cat(Replicate(0, fine_ts_width),
self.bank_o.counter))
)
self._r_frequency_i = CSRStatus(32)
self._r_frequency_fn = CSRStatus(8)
self._r_frequency_fd = CSRStatus(8)

# OE
oes = []
@@ -217,3 +216,20 @@ def __init__(self, phy, counter_width=32, ofifo_depth=64, ififo_depth=64):
self._r_i_error.status.eq(
Cat(self.bank_i.overflow, self.bank_i.pileup))
]

# Counter
self.sync += \
If(self._r_counter_update.re,
self._r_counter.status.eq(Cat(Replicate(0, fine_ts_width),
self.bank_o.counter))
)

# Frequency
clk_freq = Fraction(clk_freq).limit_denominator(255)
clk_freq_i = int(clk_freq)
clk_freq_f = clk_freq - clk_freq_i
self.comb += [
self._r_frequency_i.status.eq(clk_freq_i),
self._r_frequency_fn.status.eq(clk_freq_f.numerator),
self._r_frequency_fd.status.eq(clk_freq_f.denominator)
]
4 changes: 3 additions & 1 deletion soc/runtime/corecom_serial.c
Original file line number Diff line number Diff line change
@@ -154,7 +154,9 @@ void corecom_serve(object_loader load_object, kernel_runner run_kernel)
if(msgtype == MSGTYPE_REQUEST_IDENT) {
send_char(MSGTYPE_IDENT);
send_int(0x41524f52); /* "AROR" - ARTIQ runtime on OpenRISC */
send_int(1000000000000LL/identifier_frequency_read()); /* RTIO clock period in picoseconds */
send_int(rtio_frequency_i_read());
send_char(rtio_frequency_fn_read());
send_char(rtio_frequency_fd_read());
} else if(msgtype == MSGTYPE_LOAD_OBJECT)
receive_and_load_object(load_object);
else if(msgtype == MSGTYPE_RUN_KERNEL)
3 changes: 3 additions & 0 deletions soc/runtime/dds.c
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
#include <hw/common.h>
#include <stdio.h>

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

#define DDS_FTW0 0x0a
@@ -42,6 +43,8 @@ static void fud(long long int fud_time)
rtio_o_timestamp_write(fud_time+3*8);
rtio_o_value_write(0);
rtio_o_we_write(1);
if(rtio_o_error_read())
exception_raise(EID_RTIO_UNDERFLOW);

if(r) {
fud_sync();
2 changes: 2 additions & 0 deletions soc/runtime/rtio.c
Original file line number Diff line number Diff line change
@@ -32,6 +32,8 @@ void rtio_replace(long long int timestamp, int channel, int value)
rtio_o_timestamp_write(timestamp);
rtio_o_value_write(value);
rtio_o_replace_write(1);
if(rtio_o_error_read())
exception_raise(EID_RTIO_UNDERFLOW);
}

void rtio_sync(int channel)
2 changes: 1 addition & 1 deletion soc/targets/artiq.py
Original file line number Diff line number Diff line change
@@ -61,7 +61,7 @@ def __init__(self, platform, cpu_type="or1k", with_test_gen=False, **kwargs):
rtio_pads,
output_only_pads={rtio_pads[1], rtio_pads[2], rtio_pads[3]},
mini_pads={fud})
self.submodules.rtio = rtio.RTIO(self.rtiophy)
self.submodules.rtio = rtio.RTIO(self.rtiophy, self.clk_freq)

if with_test_gen:
self.submodules.test_gen = _TestGen(platform.request("ttl", 4))
2 changes: 1 addition & 1 deletion test/full_stack.py
Original file line number Diff line number Diff line change
@@ -105,7 +105,7 @@ class _RTIOUnderflow(AutoContext):

@kernel
def run(self):
for i in range(10000):
while True:
delay(25*ns)
self.o.pulse(25*ns)

4 changes: 2 additions & 2 deletions test/py2llvm.py
Original file line number Diff line number Diff line change
@@ -205,8 +205,8 @@ def _test_range():
class CodeGenCase(unittest.TestCase):
def _test_float_arith(self, op):
arith_c = CompiledFunction(arith, {
"op": base_types.VInt(),
"a": base_types.VFloat(), "b": base_types.VFloat()})
"op": base_types.VInt(),
"a": base_types.VFloat(), "b": base_types.VFloat()})
for a in _test_range():
for b in _test_range():
self.assertEqual(arith_c(op, a/2, b/2), arith(op, a/2, b/2))