Skip to content

Commit

Permalink
Merge branch 'master' into new-py2llvm
Browse files Browse the repository at this point in the history
whitequark committed Oct 13, 2015
2 parents 32ce33a + ceb18d0 commit bd5b324
Showing 96 changed files with 2,285 additions and 1,170 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@ doc/manual/_build
/dist
/*.egg-info
/.coverage
artiq/test/results
examples/master/results
Output/
/lit-test/libartiq_support/libartiq_support.so
20 changes: 13 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,39 @@
language: python
python:
- '3.4'
- '3.5'
branches:
only:
- master
sudo: false
env:
global:
- BUILD_SOC=1
- secure: "DUk/Ihg8KbbzEgPF0qrHqlxU8e8eET9i/BtzNvFddIGX4HP/P2qz0nk3cVkmjuWhqJXSbC22RdKME9qqPzw6fJwJ6dpJ3OR6dDmSd7rewavq+niwxu52PVa+yK8mL4yf1terM7QQ5tIRf+yUL9qGKrZ2xyvEuRit6d4cFep43Ws="
matrix:
- BUILD_SOC=0
- BUILD_SOC=1
before_install:
- mkdir -p $HOME/.mlabs
- if [ $TRAVIS_PULL_REQUEST != false ]; then BUILD_SOC=0; fi
- if [ $BUILD_SOC -ne 0 ]; then ./.travis/get-xilinx.sh; fi
- . ./.travis/get-toolchain.sh
- . ./.travis/get-anaconda.sh
- source $HOME/miniconda/bin/activate py34
- echo "BUILD_SOC=$BUILD_SOC" >> $HOME/.mlabs/build_settings.sh
- source $HOME/miniconda/bin/activate py35
- conda install -q pip coverage anaconda-client migen cython
- pip install coveralls
install:
- conda build conda/artiq
- conda build --python 3.5 conda/artiq
- conda install -q artiq --use-local
script:
- coverage run --source=artiq setup.py test
- make -C doc/manual html
after_success:
- anaconda -q login --hostname $(hostname) --username $binstar_login --password $binstar_password
- if [ "$TRAVIS_BRANCH" == "master" ]; then anaconda -q upload --user $binstar_login --channel dev --force $HOME/miniconda/conda-bld/linux-64/artiq-*.tar.bz2; fi
- anaconda -q logout
- |
if [ "$TRAVIS_BRANCH" == "master" -a $BUILD_SOC -eq 1 ]; then
anaconda -q login --hostname $(hostname) --username $binstar_login --password $binstar_password
anaconda -q upload --user $binstar_login --channel dev --force $HOME/miniconda/conda-bld/linux-64/artiq-*.tar.bz2
anaconda -q logout
fi
- coveralls
notifications:
email:
2 changes: 1 addition & 1 deletion .travis/get-anaconda.sh
Original file line number Diff line number Diff line change
@@ -9,5 +9,5 @@ conda config --set always_yes yes --set changeps1 no
conda update -q conda
conda info -a
conda install conda-build jinja2
conda create -q -n py34 python=$TRAVIS_PYTHON_VERSION
conda create -q -n py35 python=$TRAVIS_PYTHON_VERSION
conda config --add channels https://conda.anaconda.org/m-labs/channel/dev
5 changes: 2 additions & 3 deletions .travis/get-toolchain.sh
Original file line number Diff line number Diff line change
@@ -19,11 +19,10 @@ do
done

export PATH=$PWD/packages/usr/local/llvm-or1k/bin:$PWD/packages/usr/local/bin:$PWD/packages/usr/bin:$PATH
export LD_LIBRARY_PATH=$PWD/packages/usr/lib/x86_64-linux-gnu:$PWD/packages/usr/local/x86_64-unknown-linux-gnu/or1k-elf/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$PWD/packages/usr/local/llvm-or1k/lib:$PWD/packages/usr/lib/x86_64-linux-gnu:$PWD/packages/usr/local/x86_64-unknown-linux-gnu/or1k-elf/lib:$LD_LIBRARY_PATH

echo "export LD_LIBRARY_PATH=$PWD/packages/usr/lib/x86_64-linux-gnu:$PWD/packages/usr/local/x86_64-unknown-linux-gnu/or1k-elf/lib:\$LD_LIBRARY_PATH" >> $HOME/.mlabs/build_settings.sh
echo "export PATH=$PWD/packages/usr/local/llvm-or1k/bin:$PWD/packages/usr/local/bin:$PWD/packages/usr/bin:\$PATH" >> $HOME/.mlabs/build_settings.sh
echo "export LD_LIBRARY_PATH=$PWD/packages/usr/local/llvm-or1k/lib:$PWD/packages/usr/lib/x86_64-linux-gnu:$PWD/packages/usr/local/x86_64-unknown-linux-gnu/or1k-elf/lib:\$LD_LIBRARY_PATH" >> $HOME/.mlabs/build_settings.sh

or1k-linux-as --version
llc --version
clang --version
2 changes: 1 addition & 1 deletion .travis/get-xilinx.sh
Original file line number Diff line number Diff line change
@@ -30,7 +30,7 @@ git clone https://github.com/fallen/impersonate_macaddress
make -C impersonate_macaddress
# Tell mibuild where Xilinx toolchains are installed
# and feed it the mac address corresponding to the license
cat > $HOME/.mlabs/build_settings.sh << EOF
cat >> $HOME/.mlabs/build_settings.sh << EOF
MISOC_EXTRA_VIVADO_CMDLINE="-Ob vivado_path $HOME/Xilinx/Vivado"
MISOC_EXTRA_ISE_CMDLINE="-Ob ise_path $HOME/opt/Xilinx/"
export MACADDR=$macaddress
6 changes: 3 additions & 3 deletions artiq/compiler/testbench/embedding.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sys, os

from artiq.protocols.file_db import FlatFileDB
from artiq.master.databases import DeviceDB
from artiq.master.worker_db import DeviceManager

from artiq.coredevice.core import Core, CompileError
@@ -17,10 +17,10 @@ def main():
testcase_vars = {'__name__': 'testbench'}
exec(testcase_code, testcase_vars)

ddb_path = os.path.join(os.path.dirname(sys.argv[1]), "ddb.pyon")
ddb_path = os.path.join(os.path.dirname(sys.argv[1]), "device_db.pyon")

try:
core = Core(dmgr=DeviceManager(FlatFileDB(ddb_path)))
core = Core(dmgr=DeviceManager(DeviceDB(ddb_path)))
if compile_only:
core.compile(testcase_vars["entrypoint"], (), {})
else:
18 changes: 16 additions & 2 deletions artiq/coredevice/core.py
Original file line number Diff line number Diff line change
@@ -34,10 +34,22 @@ def rtio_get_counter() -> TInt64:
raise NotImplementedError("syscall not simulated")

class Core:
def __init__(self, dmgr, ref_period=8*ns, external_clock=False):
self.comm = dmgr.get("comm")
"""Core device driver.
:param ref_period: period of the reference clock for the RTIO subsystem.
On platforms that use clock multiplication and SERDES-based PHYs,
this is the period after multiplication. For example, with a RTIO core
clocked at 125MHz and a SERDES multiplication factor of 8, the
reference period is 1ns.
The time machine unit is equal to this period.
:param external_clock: whether the core device should switch to its
external RTIO clock input instead of using its internal oscillator.
:param comm_device: name of the device used for communications.
"""
def __init__(self, dmgr, ref_period=8*ns, external_clock=False, comm_device="comm"):
self.ref_period = ref_period
self.external_clock = external_clock
self.comm = dmgr.get(comm_device)

self.first_run = True
self.core = self
@@ -80,6 +92,8 @@ def get_rtio_counter_mu(self):

@kernel
def break_realtime(self):
"""Set the timeline to the current value of the hardware RTIO counter
plus a margin of 125000 machine units."""
min_now = rtio_get_counter() + 125000
if now_mu() < min_now:
at_mu(min_now)
35 changes: 4 additions & 31 deletions artiq/devices/novatech409b/driver.py
Original file line number Diff line number Diff line change
@@ -137,50 +137,24 @@ def set_simultaneous_update(self, simultaneous):
else:
self._ser_send("I a")

def do_simultaneous_update(self):
"""Apply update in simultaneous update mode."""
self._ser_send("I p")

def set_freq(self, ch_no, freq):
"""Set frequency of one channel."""
self.set_simultaneous_update(False)
# Novatech expects MHz
self._ser_send("F{:d} {:f}".format(ch_no, freq/1e6))

def set_phase(self, ch_no, phase):
"""Set phase of one channel."""
# do this immediately, disable SimultaneousUpdate mode
self.set_simultaneous_update(False)
# phase word is required by device
# N is an integer from 0 to 16383. Phase is set to
# N*360/16384 deg; in ARTIQ represent phase in cycles [0, 1]
phase_word = round(phase*16383)
cmd = "P{:d} {:d}".format(ch_no, phase_word)
self._ser_send(cmd)

def set_freq_all_phase_continuous(self, freq):
"""Set frequency of all channels simultaneously.
Set frequency of all channels simultaneously.
1) all DDSs are set to phase continuous mode
2) all DDSs are simultaneously set to new frequency
Together 1 and 2 ensure phase continuous frequency switching.
"""
self.set_simultaneous_update(True)
self.set_phase_continuous(True)
for i in range(4):
self.set_freq(i, freq)
# send command necessary to update all channels at the same time
self._ser_send("I p")

def set_phase_all(self, phase):
"""Set phase of all channels simultaneously."""

self.set_simultaneous_update(True)
# Note that this only works if the continuous
# phase switching is turned off.
self.set_phase_continuous(False)
for i in range(4):
self.set_phase(i, phase)
# send command necessary to update all channels at the same time
self._ser_send("I p")

def set_gain(self, ch_no, volts):
"""Set amplitude of one channel."""

@@ -191,7 +165,6 @@ def set_gain(self, ch_no, volts):
s = "Amplitude out of range {v}".format(v=volts)
raise ValueError(s)

self.set_simultaneous_update(False)
s = "V{:d} {:d}".format(ch_no, dac_value)
self._ser_send(s)

86 changes: 41 additions & 45 deletions artiq/frontend/artiq_client.py
Original file line number Diff line number Diff line change
@@ -12,6 +12,7 @@
from artiq.protocols.pc_rpc import Client
from artiq.protocols.sync_struct import Subscriber
from artiq.protocols import pyon
from artiq.tools import short_format


def clear_screen():
@@ -58,40 +59,37 @@ def get_argparser():
parser_delete = subparsers.add_parser("delete",
help="delete an experiment "
"from the schedule")
parser_delete.add_argument("-g", action="store_true",
help="request graceful termination")
parser_delete.add_argument("rid", type=int,
help="run identifier (RID)")

parser_set_device = subparsers.add_parser(
"set-device", help="add or modify a device")
parser_set_device.add_argument("name", help="name of the device")
parser_set_device.add_argument("description",
help="description in PYON format")
parser_set_dataset = subparsers.add_parser(
"set-dataset", help="add or modify a dataset")
parser_set_dataset.add_argument("name", help="name of the dataset")
parser_set_dataset.add_argument("value",
help="value in PYON format")
parser_set_dataset.add_argument("-p", "--persist", action="store_true",
help="make the dataset persistent")

parser_del_device = subparsers.add_parser(
"del-device", help="delete a device")
parser_del_device.add_argument("name", help="name of the device")

parser_set_parameter = subparsers.add_parser(
"set-parameter", help="add or modify a parameter")
parser_set_parameter.add_argument("name", help="name of the parameter")
parser_set_parameter.add_argument("value",
help="value in PYON format")

parser_del_parameter = subparsers.add_parser(
"del-parameter", help="delete a parameter")
parser_del_parameter.add_argument("name", help="name of the parameter")
parser_del_dataset = subparsers.add_parser(
"del-dataset", help="delete a dataset")
parser_del_dataset.add_argument("name", help="name of the dataset")

parser_show = subparsers.add_parser(
"show", help="show schedule, log, devices or parameters")
"show", help="show schedule, log, devices or datasets")
parser_show.add_argument(
"what",
help="select object to show: schedule/log/devices/parameters")
help="select object to show: schedule/log/devices/datasets")

parser_scan = subparsers.add_parser("scan-repository",
help="trigger a repository (re)scan")
parser_scan.add_argument("revision", default=None, nargs="?",
help="use a specific repository revision "
"(defaults to head)")
subparsers.add_parser(
"scan-devices", help="trigger a device database (re)scan")

parser_scan_repos = subparsers.add_parser(
"scan-repository", help="trigger a repository (re)scan")
parser_scan_repos.add_argument("revision", default=None, nargs="?",
help="use a specific repository revision "
"(defaults to head)")

return parser

@@ -128,23 +126,22 @@ def _action_submit(remote, args):


def _action_delete(remote, args):
remote.delete(args.rid)
if args.g:
remote.request_termination(args.rid)
else:
remote.delete(args.rid)


def _action_set_device(remote, args):
remote.set(args.name, pyon.decode(args.description))
def _action_set_dataset(remote, args):
remote.set(args.name, pyon.decode(args.value), args.persist)


def _action_del_device(remote, args):
def _action_del_dataset(remote, args):
remote.delete(args.name)


def _action_set_parameter(remote, args):
remote.set(args.name, pyon.decode(args.value))


def _action_del_parameter(remote, args):
remote.delete(args.name)
def _action_scan_devices(remote, args):
remote.scan()


def _action_scan_repository(remote, args):
@@ -192,11 +189,11 @@ def _show_devices(devices):
print(table)


def _show_parameters(parameters):
def _show_datasets(datasets):
clear_screen()
table = PrettyTable(["Parameter", "Value"])
for k, v in sorted(parameters.items(), key=itemgetter(0)):
table.add_row([k, str(v)])
table = PrettyTable(["Dataset", "Persistent", "Value"])
for k, (persist, value) in sorted(datasets.items(), key=itemgetter(0)):
table.add_row([k, "Y" if persist else "N", short_format(value)])
print(table)


@@ -265,8 +262,8 @@ def main():
_show_log(args)
elif args.what == "devices":
_show_dict(args, "devices", _show_devices)
elif args.what == "parameters":
_show_dict(args, "parameters", _show_parameters)
elif args.what == "datasets":
_show_dict(args, "datasets", _show_datasets)
else:
print("Unknown object to show, use -h to list valid names.")
sys.exit(1)
@@ -275,10 +272,9 @@ def main():
target_name = {
"submit": "master_schedule",
"delete": "master_schedule",
"set_device": "master_ddb",
"del_device": "master_ddb",
"set_parameter": "master_pdb",
"del_parameter": "master_pdb",
"set_dataset": "master_dataset_db",
"del_dataset": "master_dataset_db",
"scan_devices": "master_device_db",
"scan_repository": "master_repository"
}[action]
remote = Client(args.server, port, target_name)
Loading

0 comments on commit bd5b324

Please sign in to comment.