From d1ad2f191892e6be76c3aa939a76c97ad51d5f67 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 31 Oct 2015 23:44:09 +0800 Subject: [PATCH 01/20] examples/dds_setter: fix, scale inputs --- examples/master/repository/dds_setter.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/examples/master/repository/dds_setter.py b/examples/master/repository/dds_setter.py index 1e35496d8..a50e242c0 100644 --- a/examples/master/repository/dds_setter.py +++ b/examples/master/repository/dds_setter.py @@ -6,6 +6,8 @@ from artiq import * class DDSSetter(EnvExperiment): """DDS Setter""" def build(self): + self.setattr_device("core") + self.dds = dict() device_db = self.get_device_db() @@ -16,10 +18,16 @@ class DDSSetter(EnvExperiment): and v["class"] in {"AD9858", "AD9914"}): self.dds[k] = { "driver": self.get_device(k), - "frequency": self.get_argument("{}_frequency".format(k), - NumberValue()) + "frequency": self.get_argument( + "{}_frequency".format(k), + NumberValue(100e6, scale=1e6, unit="MHz", ndecimals=6)) } + @kernel + def set_dds(self, dds, frequency): + dds.set(frequency) + delay(200*ms) + def run(self): for k, v in self.dds.items(): - v["driver"].set(v["frequency"]) + self.set_dds(v["driver"], v["frequency"]) From f57145c4f33fd407acfb79b3cdcb98936a9b1f02 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 31 Oct 2015 23:58:39 +0800 Subject: [PATCH 02/20] gui: support triggering repository rescan --- artiq/frontend/artiq_gui.py | 27 ++++++++++++++------------- artiq/gui/explorer.py | 9 ++++++++- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/artiq/frontend/artiq_gui.py b/artiq/frontend/artiq_gui.py index 4a4b3369c..a94b44d1f 100755 --- a/artiq/frontend/artiq_gui.py +++ b/artiq/frontend/artiq_gui.py @@ -69,12 +69,15 @@ def main(): asyncio.set_event_loop(loop) atexit.register(lambda: loop.close()) - smgr = StateManager(args.db_file) + rpc_clients = dict() + for target in "schedule", "repository", "dataset_db": + client = AsyncioClient() + loop.run_until_complete(client.connect_rpc( + args.server, args.port_control, "master_" + target)) + atexit.register(lambda: client.close_rpc()) + rpc_clients[target] = client - schedule_ctl = AsyncioClient() - loop.run_until_complete(schedule_ctl.connect_rpc( - args.server, args.port_control, "master_schedule")) - atexit.register(lambda: schedule_ctl.close_rpc()) + smgr = StateManager(args.db_file) win = MainWindow(app, args.server) area = dockarea.DockArea() @@ -85,7 +88,9 @@ def main(): status_bar.showMessage("Connected to {}".format(args.server)) win.setStatusBar(status_bar) - d_explorer = ExplorerDock(win, status_bar, schedule_ctl) + d_explorer = ExplorerDock(win, status_bar, + rpc_clients["schedule"], + rpc_clients["repository"]) smgr.register(d_explorer) loop.run_until_complete(d_explorer.sub_connect( args.server, args.port_notify)) @@ -110,7 +115,7 @@ def main(): area.addDock(d_datasets, "top") area.addDock(d_explorer, "above", d_datasets) - d_schedule = ScheduleDock(status_bar, schedule_ctl) + d_schedule = ScheduleDock(status_bar, rpc_clients["schedule"]) loop.run_until_complete(d_schedule.sub_connect( args.server, args.port_notify)) atexit.register(lambda: loop.run_until_complete(d_schedule.sub_close())) @@ -121,14 +126,10 @@ def main(): args.server, args.port_notify)) atexit.register(lambda: loop.run_until_complete(d_log.sub_close())) - dataset_db = AsyncioClient() - loop.run_until_complete(dataset_db.connect_rpc( - args.server, args.port_control, "master_dataset_db")) - atexit.register(lambda: dataset_db.close_rpc()) def _set_dataset(k, v): - asyncio.ensure_future(dataset_db.set(k, v)) + asyncio.ensure_future(rpc_clients["dataset_db"].set(k, v)) def _del_dataset(k): - asyncio.ensure_future(dataset_db.delete(k)) + asyncio.ensure_future(rpc_clients["dataset_db"].delete(k)) d_console = ConsoleDock( d_datasets.get_dataset, _set_dataset, diff --git a/artiq/gui/explorer.py b/artiq/gui/explorer.py index c9816b55d..90b9ac4ce 100644 --- a/artiq/gui/explorer.py +++ b/artiq/gui/explorer.py @@ -216,7 +216,7 @@ class _ArgumentEditor(QtGui.QTreeWidget): class ExplorerDock(dockarea.Dock): - def __init__(self, main_window, status_bar, schedule_ctl): + def __init__(self, main_window, status_bar, schedule_ctl, repository_ctl): dockarea.Dock.__init__(self, "Explorer", size=(1500, 500)) self.main_window = main_window @@ -279,6 +279,13 @@ class ExplorerDock(dockarea.Dock): edit_shortcuts_action = QtGui.QAction("Edit shortcuts", self.el) edit_shortcuts_action.triggered.connect(self.edit_shortcuts) self.el.addAction(edit_shortcuts_action) + scan_repository_action = QtGui.QAction("(Re)scan repository HEAD", + self.el) + def scan_repository(): + asyncio.ensure_future(repository_ctl.scan_async()) + self.status_bar.showMessage("Requested repository scan") + scan_repository_action.triggered.connect(scan_repository) + self.el.addAction(scan_repository_action) def update_selection(self, selected, deselected): if deselected: From 8e24a018ea8bcd01ab8a101b6d8620a72b1a6912 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sun, 1 Nov 2015 00:01:45 +0800 Subject: [PATCH 03/20] gui/log: fix filter initialization race condition --- artiq/gui/log.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/artiq/gui/log.py b/artiq/gui/log.py index 819c13d95..f3de6cc19 100644 --- a/artiq/gui/log.py +++ b/artiq/gui/log.py @@ -191,10 +191,14 @@ class LogDock(dockarea.Dock): await self.subscriber.close() def filter_level_changed(self): + if not hasattr(self, "table_model_filter"): + return self.table_model_filter.set_min_level( getattr(logging, self.filter_level.currentText())) def filter_freetext_changed(self): + if not hasattr(self, "table_model_filter"): + return self.table_model_filter.set_freetext(self.filter_freetext.text()) def rows_inserted_before(self): From a2c074cc3355bd109f2a761cb350c44f7c45a933 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sun, 1 Nov 2015 00:03:46 +0800 Subject: [PATCH 04/20] gui: fix RPC client teardown --- artiq/frontend/artiq_gui.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/artiq/frontend/artiq_gui.py b/artiq/frontend/artiq_gui.py index a94b44d1f..8967757d0 100755 --- a/artiq/frontend/artiq_gui.py +++ b/artiq/frontend/artiq_gui.py @@ -67,14 +67,14 @@ def main(): app = QtGui.QApplication([]) loop = QEventLoop(app) asyncio.set_event_loop(loop) - atexit.register(lambda: loop.close()) + atexit.register(loop.close) rpc_clients = dict() for target in "schedule", "repository", "dataset_db": client = AsyncioClient() loop.run_until_complete(client.connect_rpc( args.server, args.port_control, "master_" + target)) - atexit.register(lambda: client.close_rpc()) + atexit.register(client.close_rpc) rpc_clients[target] = client smgr = StateManager(args.db_file) From 73fed53c09a0466163aad60122531baf91087457 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sun, 1 Nov 2015 00:24:44 +0800 Subject: [PATCH 05/20] manual: document startup clock and kernel --- doc/manual/installing.rst | 25 ++++++++++++++++++------- doc/manual/utilities.rst | 4 ++-- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/doc/manual/installing.rst b/doc/manual/installing.rst index 9a3ea155a..3a24d6dc6 100644 --- a/doc/manual/installing.rst +++ b/doc/manual/installing.rst @@ -323,7 +323,7 @@ Installing the host-side software Configuring the core device --------------------------- -This should be done after either installation methods (conda or source). +This should be done after either installation method (conda or source). .. _flash-mac-ip-addr: @@ -371,16 +371,16 @@ This should be done after either installation methods (conda or source). .. note:: The reset button of the KC705 board is the "CPU_RST" labeled button. .. warning:: Both those instructions will result in the flash storage being wiped out. However you can use the test mode to change the IP/MAC without erasing everything if you skip the "fserase" command. -* (optional) Flash the ``idle`` kernel +* (optional) Flash the idle kernel -The ``idle`` kernel is the kernel (some piece of code running on the core device) which the core device runs whenever it is not connected to a PC via ethernet. +The idle kernel is the kernel (some piece of code running on the core device) which the core device runs whenever it is not connected to a PC via ethernet. This kernel is therefore stored in the :ref:`core device configuration flash storage `. -To flash the ``idle`` kernel: +To flash the idle kernel: - * Compile the ``idle`` experiment: - The ``idle`` experiment's ``run()`` method must be a kernel: it must be decorated with the ``@kernel`` decorator (see :ref:`next topic ` for more information about kernels). + * Compile the idle experiment: + The idle experiment's ``run()`` method must be a kernel: it must be decorated with the ``@kernel`` decorator (see :ref:`next topic ` for more information about kernels). - Since the core device is not connected to the PC, RPCs (calling Python code running on the PC from the kernel) are forbidden in the ``idle`` experiment. + Since the core device is not connected to the PC, RPCs (calling Python code running on the PC from the kernel) are forbidden in the idle experiment. :: $ artiq_compile idle.py @@ -391,6 +391,17 @@ To flash the ``idle`` kernel: .. note:: You can find more information about how to use the ``artiq_coretool`` utility on the :ref:`Utilities ` page. +* (optional) Flash the startup kernel + +The startup kernel is executed once when the core device powers up. It should initialize DDSes, set up TTL directions, etc. Proceed as with the idle kernel, but using the ``startup_kernel`` key in ``artiq_coretool``. + +* (optional) Select the startup clock + +The core device may use either an external clock signal or its internal clock. This clock can be switched dynamically after the PC is connected using the ``external_clock`` parameter of the core device driver; however, one may want to select the clock at power-up so that it is used for the startup and idle kernels. Use one of these commands: :: + + $ artiq_coretool cfg-write -s startup_clock i # internal clock (default) + $ artiq_coretool cfg-write -s startup_clock e # external clock + Ubuntu 14.04 specific instructions ---------------------------------- diff --git a/doc/manual/utilities.rst b/doc/manual/utilities.rst index 1f97c98ca..486b30e97 100644 --- a/doc/manual/utilities.rst +++ b/doc/manual/utilities.rst @@ -104,7 +104,7 @@ The artiq_coretool utility allows to perform maintenance on the core device: * as well as read, write and remove key-value records from the :ref:`core-device-flash-storage`; * erase the entire flash storage area. -To use this tool, you need to specify a ``device_db.pyon`` device database file which contains a ``comm`` device (an example is provided in ``artiq/examples/master/device_db.pyon``). This tells the tool how to connect to the core device (via serial or via TCP) and with which parameters (baudrate, serial device, IP address, TCP port). When not specified, the artiq_coretool utility will assume that there is a file named ``device_db.pyon`` in the current directory. +To use this tool, you need to specify a ``device_db.pyon`` device database file which contains a ``comm`` device (an example is provided in ``examples/master/device_db.pyon``). This tells the tool how to connect to the core device (via serial or via TCP) and with which parameters (baudrate, serial device, IP address, TCP port). When not specified, the artiq_coretool utility will assume that there is a file named ``device_db.pyon`` in the current directory. To read the record whose key is ``mac``:: @@ -117,7 +117,7 @@ To write the value ``test_value`` in the key ``my_key``:: $ artiq_coretool cfg-read my_key b'test_value' -You can also write entire files in a record using the ``-f`` parameter. This is useful for instance to write the ``idle`` kernel in the flash storage:: +You can also write entire files in a record using the ``-f`` parameter. This is useful for instance to write the startup and idle kernels in the flash storage:: $ artiq_coretool cfg-write -f idle_kernel idle.elf $ artiq_coretool cfg-read idle_kernel | head -c9 From 644a410c90799f767b9c208c7aae5df90702e272 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Tue, 3 Nov 2015 17:54:27 +0800 Subject: [PATCH 06/20] thorlabs_tcube: fix -P case handling --- artiq/frontend/thorlabs_tcube_controller.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/artiq/frontend/thorlabs_tcube_controller.py b/artiq/frontend/thorlabs_tcube_controller.py index c9b209070..6e8d9bbc8 100755 --- a/artiq/frontend/thorlabs_tcube_controller.py +++ b/artiq/frontend/thorlabs_tcube_controller.py @@ -11,8 +11,8 @@ from artiq.tools import verbosity_args, simple_network_args, init_logger def get_argparser(): parser = argparse.ArgumentParser() parser.add_argument("-P", "--product", required=True, - help="type of the Thorlabs T-Cube device to control", - choices=["tdc001", "tpz001"]) + help="type of the Thorlabs T-Cube device to control: " + "tdc001/tpz001") parser.add_argument("-d", "--device", default=None, help="serial device. See documentation for how to " "specify a USB Serial Number.") @@ -39,11 +39,19 @@ def main(): dev = TdcSim() elif product == "tpz001": dev = TpzSim() + else: + print("Invalid product string (-P/--product), " + "choose from tdc001 or tpz001") + sys.exit(1) else: if product == "tdc001": dev = Tdc(args.device) elif product == "tpz001": dev = Tpz(args.device) + else: + print("Invalid product string (-P/--product), " + "choose from tdc001 or tpz001") + sys.exit(1) try: simple_server_loop({product: dev}, args.bind, args.port) From e26147b2aca5f3936ab88321731bac9bce12f021 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Wed, 4 Nov 2015 00:35:03 +0800 Subject: [PATCH 07/20] gateware,runtime: use new migen/misoc --- .gitignore | 2 +- .gitmodules | 4 +- artiq/frontend/artiq_gui.py | 9 +-- artiq/gateware/ad9xxx.py | 51 +++++------- artiq/gateware/amp/kernel_cpu.py | 16 ++-- artiq/gateware/amp/mailbox.py | 4 +- artiq/gateware/nist_qc1.py | 2 +- artiq/gateware/nist_qc2.py | 2 +- artiq/gateware/rtio/core.py | 60 +++++++++----- artiq/gateware/rtio/moninj.py | 10 +-- artiq/gateware/rtio/phy/dds.py | 18 ++--- artiq/gateware/rtio/phy/ttl_serdes_7series.py | 2 +- artiq/gateware/rtio/phy/ttl_serdes_generic.py | 10 +-- .../gateware/rtio/phy/ttl_serdes_spartan6.py | 2 +- artiq/gateware/rtio/phy/ttl_simple.py | 2 +- artiq/gateware/rtio/phy/wishbone.py | 10 +-- artiq/gateware/rtio/rtlink.py | 4 +- artiq/gateware/soc.py | 6 +- .../gateware/targets/kc705.py | 80 ++++++++++++++----- .../gateware/targets/pipistrello.py | 48 ++++++++--- artiq/runtime/Makefile | 64 +++++++++++++++ {soc => artiq}/runtime/bridge.c | 0 {soc => artiq}/runtime/bridge.h | 0 {soc => artiq}/runtime/bridge_ctl.c | 0 {soc => artiq}/runtime/bridge_ctl.h | 0 {soc => artiq}/runtime/clock.c | 0 {soc => artiq}/runtime/clock.h | 0 {soc => artiq}/runtime/dds.c | 0 {soc => artiq}/runtime/dds.h | 0 {soc => artiq}/runtime/elf_loader.c | 0 {soc => artiq}/runtime/elf_loader.h | 0 {soc => artiq}/runtime/exception_jmp.S | 0 {soc => artiq}/runtime/exceptions.c | 0 {soc => artiq}/runtime/exceptions.h | 0 {soc => artiq}/runtime/flash_storage.c | 0 {soc => artiq}/runtime/flash_storage.h | 0 {soc => artiq}/runtime/gen_service_table.py | 0 {soc => artiq}/runtime/isr.c | 0 {soc => artiq}/runtime/kloader.c | 0 {soc => artiq}/runtime/kloader.h | 0 {soc => artiq}/runtime/ksupport.c | 0 {soc => artiq}/runtime/ksupport.ld | 0 artiq/runtime/liblwip/Makefile | 66 +++++++++++++++ {soc => artiq}/runtime/liblwip/arch/cc.h | 0 {soc => artiq}/runtime/liblwip/arch/perf.h | 0 .../runtime/liblwip/arch/sys_arch.h | 0 .../runtime/liblwip}/liteethif.c | 2 +- .../runtime/liblwip}/liteethif.h | 0 {soc => artiq}/runtime/liblwip/lwipopts.h | 0 {soc => artiq}/runtime/linker.ld | 0 {soc => artiq}/runtime/log.c | 0 {soc => artiq}/runtime/log.h | 0 {soc => artiq}/runtime/lwip | 0 {soc => artiq}/runtime/mailbox.c | 0 {soc => artiq}/runtime/mailbox.h | 0 {soc => artiq}/runtime/main.c | 4 +- {soc => artiq}/runtime/messages.h | 0 {soc => artiq}/runtime/moninj.c | 0 {soc => artiq}/runtime/moninj.h | 0 {soc => artiq}/runtime/net_server.c | 4 +- {soc => artiq}/runtime/net_server.h | 0 {soc => artiq}/runtime/rtio.c | 0 {soc => artiq}/runtime/rtio.h | 0 {soc => artiq}/runtime/rtiocrg.c | 0 {soc => artiq}/runtime/rtiocrg.h | 0 {soc => artiq}/runtime/services.c | 0 {soc => artiq}/runtime/services.h | 0 {soc => artiq}/runtime/session.c | 0 {soc => artiq}/runtime/session.h | 0 {soc => artiq}/runtime/test_mode.c | 0 {soc => artiq}/runtime/test_mode.h | 0 {soc => artiq}/runtime/ttl.c | 0 {soc => artiq}/runtime/ttl.h | 0 artiq/tools.py | 4 +- soc/runtime/Makefile | 72 ----------------- soc/runtime/liblwip/Makefile | 55 ------------- 76 files changed, 343 insertions(+), 270 deletions(-) rename soc/targets/artiq_kc705.py => artiq/gateware/targets/kc705.py (79%) mode change 100644 => 100755 rename soc/targets/artiq_pipistrello.py => artiq/gateware/targets/pipistrello.py (87%) mode change 100644 => 100755 create mode 100644 artiq/runtime/Makefile rename {soc => artiq}/runtime/bridge.c (100%) rename {soc => artiq}/runtime/bridge.h (100%) rename {soc => artiq}/runtime/bridge_ctl.c (100%) rename {soc => artiq}/runtime/bridge_ctl.h (100%) rename {soc => artiq}/runtime/clock.c (100%) rename {soc => artiq}/runtime/clock.h (100%) rename {soc => artiq}/runtime/dds.c (100%) rename {soc => artiq}/runtime/dds.h (100%) rename {soc => artiq}/runtime/elf_loader.c (100%) rename {soc => artiq}/runtime/elf_loader.h (100%) rename {soc => artiq}/runtime/exception_jmp.S (100%) rename {soc => artiq}/runtime/exceptions.c (100%) rename {soc => artiq}/runtime/exceptions.h (100%) rename {soc => artiq}/runtime/flash_storage.c (100%) rename {soc => artiq}/runtime/flash_storage.h (100%) rename {soc => artiq}/runtime/gen_service_table.py (100%) rename {soc => artiq}/runtime/isr.c (100%) rename {soc => artiq}/runtime/kloader.c (100%) rename {soc => artiq}/runtime/kloader.h (100%) rename {soc => artiq}/runtime/ksupport.c (100%) rename {soc => artiq}/runtime/ksupport.ld (100%) create mode 100644 artiq/runtime/liblwip/Makefile rename {soc => artiq}/runtime/liblwip/arch/cc.h (100%) rename {soc => artiq}/runtime/liblwip/arch/perf.h (100%) rename {soc => artiq}/runtime/liblwip/arch/sys_arch.h (100%) rename {soc/runtime/liblwip/netif => artiq/runtime/liblwip}/liteethif.c (99%) rename {soc/runtime/liblwip/netif => artiq/runtime/liblwip}/liteethif.h (100%) rename {soc => artiq}/runtime/liblwip/lwipopts.h (100%) rename {soc => artiq}/runtime/linker.ld (100%) rename {soc => artiq}/runtime/log.c (100%) rename {soc => artiq}/runtime/log.h (100%) rename {soc => artiq}/runtime/lwip (100%) rename {soc => artiq}/runtime/mailbox.c (100%) rename {soc => artiq}/runtime/mailbox.h (100%) rename {soc => artiq}/runtime/main.c (99%) rename {soc => artiq}/runtime/messages.h (100%) rename {soc => artiq}/runtime/moninj.c (100%) rename {soc => artiq}/runtime/moninj.h (100%) rename {soc => artiq}/runtime/net_server.c (99%) rename {soc => artiq}/runtime/net_server.h (100%) rename {soc => artiq}/runtime/rtio.c (100%) rename {soc => artiq}/runtime/rtio.h (100%) rename {soc => artiq}/runtime/rtiocrg.c (100%) rename {soc => artiq}/runtime/rtiocrg.h (100%) rename {soc => artiq}/runtime/services.c (100%) rename {soc => artiq}/runtime/services.h (100%) rename {soc => artiq}/runtime/session.c (100%) rename {soc => artiq}/runtime/session.h (100%) rename {soc => artiq}/runtime/test_mode.c (100%) rename {soc => artiq}/runtime/test_mode.h (100%) rename {soc => artiq}/runtime/ttl.c (100%) rename {soc => artiq}/runtime/ttl.h (100%) delete mode 100644 soc/runtime/Makefile delete mode 100644 soc/runtime/liblwip/Makefile diff --git a/.gitignore b/.gitignore index 2cc1c622f..83bcf3a24 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ __pycache__ *.bin *.elf *.fbi -soc/runtime/service_table.h +artiq/runtime/service_table.h doc/manual/_build /build /dist diff --git a/.gitmodules b/.gitmodules index 20c22bc61..dcb309bfe 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,4 +1,4 @@ -[submodule "soc/runtime/lwip"] - path = soc/runtime/lwip +[submodule "artiq/runtime/lwip"] + path = artiq/runtime/lwip url = git://git.savannah.nongnu.org/lwip.git ignore = untracked diff --git a/artiq/frontend/artiq_gui.py b/artiq/frontend/artiq_gui.py index 8967757d0..fd18f715c 100755 --- a/artiq/frontend/artiq_gui.py +++ b/artiq/frontend/artiq_gui.py @@ -10,7 +10,7 @@ import os from quamash import QEventLoop, QtGui, QtCore from pyqtgraph import dockarea -from artiq.tools import verbosity_args, init_logger +from artiq.tools import verbosity_args, init_logger, artiq_dir from artiq.protocols.pc_rpc import AsyncioClient from artiq.gui.state import StateManager from artiq.gui.explorer import ExplorerDock @@ -21,10 +21,6 @@ from artiq.gui.log import LogDock from artiq.gui.console import ConsoleDock -data_dir = os.path.join(os.path.abspath(os.path.dirname(__file__)), - "..", "gui") - - def get_argparser(): parser = argparse.ArgumentParser(description="ARTIQ GUI client") parser.add_argument( @@ -46,7 +42,8 @@ def get_argparser(): class MainWindow(QtGui.QMainWindow): def __init__(self, app, server): QtGui.QMainWindow.__init__(self) - self.setWindowIcon(QtGui.QIcon(os.path.join(data_dir, "icon.png"))) + icon = QtGui.QIcon(os.path.join(artiq_dir, "gui", "icon.png")) + self.setWindowIcon(icon) self.setWindowTitle("ARTIQ - {}".format(server)) self.exit_request = asyncio.Event() diff --git a/artiq/gateware/ad9xxx.py b/artiq/gateware/ad9xxx.py index 0bd290df7..2c30af242 100644 --- a/artiq/gateware/ad9xxx.py +++ b/artiq/gateware/ad9xxx.py @@ -1,18 +1,16 @@ -from migen.fhdl.std import * +from migen import * from migen.genlib.fsm import * from migen.genlib.misc import WaitTimer -from migen.bus import wishbone -from migen.bus.transactions import * -from migen.sim.generic import run_simulation +from misoc.interconnect import wishbone class AD9xxx(Module): """Wishbone interface to the AD9858 and AD9914 DDS chips. - Addresses 0-2**flen(pads.a)-1 map the AD9xxx registers. + Addresses 0-2**len(pads.a)-1 map the AD9xxx registers. - Write to address 2**flen(pads.a) to pulse the FUD signal. - Address 2**flen(pads.a)+1 is a GPIO register that controls the + Write to address 2**len(pads.a) to pulse the FUD signal. + Address 2**len(pads.a)+1 is a GPIO register that controls the sel and reset signals. rst is mapped to bit 0, followed by sel. Write timing: @@ -38,15 +36,15 @@ class AD9xxx(Module): read_wait_cycles=10, hiz_wait_cycles=3, bus=None): if bus is None: - bus = wishbone.Interface(data_width=flen(pads.d)) + bus = wishbone.Interface(data_width=len(pads.d)) self.bus = bus # # # - dts = TSTriple(flen(pads.d)) + dts = TSTriple(len(pads.d)) self.specials += dts.get_tristate(pads.d) hold_address = Signal() - dr = Signal(flen(pads.d)) + dr = Signal(len(pads.d)) rx = Signal() self.sync += [ If(~hold_address, pads.a.eq(bus.adr)), @@ -56,9 +54,9 @@ class AD9xxx(Module): ] if hasattr(pads, "sel"): - sel_len = flen(pads.sel) + sel_len = len(pads.sel) else: - sel_len = flen(pads.sel_n) + sel_len = len(pads.sel_n) gpio = Signal(sel_len + 1) gpio_load = Signal() self.sync += If(gpio_load, gpio.eq(bus.dat_w)) @@ -98,7 +96,7 @@ class AD9xxx(Module): fsm.act("IDLE", If(bus.cyc & bus.stb, - If(bus.adr[flen(pads.a)], + If(bus.adr[len(pads.a)], If(bus.adr[0], NextState("GPIO") ).Else( @@ -157,20 +155,20 @@ class AD9xxx(Module): ) -def _test_gen(): +def _test_gen(bus): # Test external bus writes - yield TWrite(4, 2) - yield TWrite(5, 3) + yield from bus.write(4, 2) + yield from bus.write(5, 3) yield # Test external bus reads - yield TRead(14) - yield TRead(15) + yield from bus.read(14) + yield from bus.read(15) yield # Test FUD - yield TWrite(64, 0) + yield from bus.write(64, 0) yield # Test GPIO - yield TWrite(65, 0xff) + yield from bus.write(65, 0xff) yield @@ -185,14 +183,7 @@ class _TestPads: self.rst_n = Signal() -class _TB(Module): - def __init__(self): - pads = _TestPads() - self.submodules.dut = AD9xxx(pads, drive_fud=True) - self.submodules.initiator = wishbone.Initiator(_test_gen()) - self.submodules.interconnect = wishbone.InterconnectPointToPoint( - self.initiator.bus, self.dut.bus) - - if __name__ == "__main__": - run_simulation(_TB(), vcd_name="ad9xxx.vcd") + pads = _TestPads() + dut = AD9xxx(pads) + run_simulation(dut, _test_gen(dut.bus), vcd_name="ad9xxx.vcd") diff --git a/artiq/gateware/amp/kernel_cpu.py b/artiq/gateware/amp/kernel_cpu.py index 7afd5730d..2736027e3 100644 --- a/artiq/gateware/amp/kernel_cpu.py +++ b/artiq/gateware/amp/kernel_cpu.py @@ -1,9 +1,8 @@ -from migen.fhdl.std import * -from migen.bank.description import * -from migen.bus import wishbone - -from misoclib.cpu import mor1kx -from misoclib.soc import mem_decoder +from migen import * +from misoc.interconnect.csr import * +from misoc.interconnect import wishbone +from misoc.cores import mor1kx +from misoc.integration.soc_core import mem_decoder class KernelCPU(Module): @@ -23,9 +22,8 @@ class KernelCPU(Module): self.cd_sys_kernel.clk.eq(ClockSignal()), self.cd_sys_kernel.rst.eq(self._reset.storage) ] - self.submodules.cpu = RenameClockDomains( - mor1kx.MOR1KX(platform, exec_address), - "sys_kernel") + self.submodules.cpu = ClockDomainsRenamer("sys_kernel")( + mor1kx.MOR1KX(platform, exec_address)) # DRAM access self.wb_sdram = wishbone.Interface() diff --git a/artiq/gateware/amp/mailbox.py b/artiq/gateware/amp/mailbox.py index 687467622..1addb50ba 100644 --- a/artiq/gateware/amp/mailbox.py +++ b/artiq/gateware/amp/mailbox.py @@ -1,5 +1,5 @@ -from migen.fhdl.std import * -from migen.bus import wishbone +from migen import * +from misoc.interconnect import wishbone class Mailbox(Module): diff --git a/artiq/gateware/nist_qc1.py b/artiq/gateware/nist_qc1.py index f75f52371..918ac0be9 100644 --- a/artiq/gateware/nist_qc1.py +++ b/artiq/gateware/nist_qc1.py @@ -1,4 +1,4 @@ -from mibuild.generic_platform import * +from migen.build.generic_platform import * papilio_adapter_io = [ diff --git a/artiq/gateware/nist_qc2.py b/artiq/gateware/nist_qc2.py index da3997f91..3235c9846 100644 --- a/artiq/gateware/nist_qc2.py +++ b/artiq/gateware/nist_qc2.py @@ -1,4 +1,4 @@ -from mibuild.generic_platform import * +from migen.build.generic_platform import * fmc_adapter_io = [ diff --git a/artiq/gateware/rtio/core.py b/artiq/gateware/rtio/core.py index 7a087c7c3..07d4a3ad3 100644 --- a/artiq/gateware/rtio/core.py +++ b/artiq/gateware/rtio/core.py @@ -1,10 +1,12 @@ -from migen.fhdl.std import * -from migen.bank.description import * -from migen.genlib.misc import optree +from functools import reduce +from operator import and_ + +from migen import * from migen.genlib.record import Record from migen.genlib.cdc import * from migen.genlib.fifo import AsyncFIFO from migen.genlib.resetsync import AsyncResetSynchronizer +from misoc.interconnect.csr import * from artiq.gateware.rtio import rtlink @@ -105,9 +107,15 @@ class _OutputManager(Module): # # # # FIFO - fifo = RenameClockDomains(AsyncFIFO(ev_layout, fifo_depth), - {"write": "rsys", "read": "rio"}) + fifo = ClockDomainsRenamer({"write": "rsys", "read": "rio"})( + AsyncFIFO(layout_len(ev_layout), fifo_depth)) self.submodules += fifo + fifo_in = Record(ev_layout) + fifo_out = Record(ev_layout) + self.comb += [ + fifo.din.eq(fifo_in.raw_bits()), + fifo_out.raw_bits().eq(fifo.dout) + ] # Buffer buf_pending = Signal() @@ -138,13 +146,15 @@ class _OutputManager(Module): if interface.suppress_nop: # disable NOP at reset: do not suppress a first write with all 0s nop_en = Signal(reset=0) + addresses_equal = [getattr(self.ev, a) == getattr(buf, a) + for a in ("data", "address") + if hasattr(self.ev, a)] + if addresses_equal: + self.sync.rsys += nop.eq( + nop_en & reduce(and_, addresses_equal)) + else: + self.comb.eq(nop.eq(0)) self.sync.rsys += [ - nop.eq(nop_en & - optree("&", - [getattr(self.ev, a) == getattr(buf, a) - for a in ("data", "address") - if hasattr(self.ev, a)], - default=0)), # buf now contains valid data. enable NOP. If(self.we & ~any_error, nop_en.eq(1)), # underflows cancel the write. allow it to be retried. @@ -156,7 +166,7 @@ class _OutputManager(Module): ] # Buffer read and FIFO write - self.comb += fifo.din.eq(buf) + self.comb += fifo_in.eq(buf) in_guard_time = Signal() self.comb += in_guard_time.eq( buf.timestamp[fine_ts_width:] @@ -195,7 +205,7 @@ class _OutputManager(Module): self.sync.rio += \ If(fifo.re, dout_stb.eq(1), - dout.eq(fifo.dout) + dout.eq(fifo_out) ).Elif(dout_ack, dout_stb.eq(0) ) @@ -235,24 +245,30 @@ class _InputManager(Module): # # # - fifo = RenameClockDomains(AsyncFIFO(ev_layout, fifo_depth), - {"read": "rsys", "write": "rio"}) + fifo = ClockDomainsRenamer({"read": "rsys", "write": "rio"})( + AsyncFIFO(layout_len(ev_layout), fifo_depth)) self.submodules += fifo + fifo_in = Record(ev_layout) + fifo_out = Record(ev_layout) + self.comb += [ + fifo.din.eq(fifo_in.raw_bits()), + fifo_out.raw_bits().eq(fifo.dout) + ] # FIFO write if data_width: - self.comb += fifo.din.data.eq(interface.data) + self.comb += fifo_in.data.eq(interface.data) if interface.timestamped: if fine_ts_width: full_ts = Cat(interface.fine_ts, counter.value_rio) else: full_ts = counter.value_rio - self.comb += fifo.din.timestamp.eq(full_ts) + self.comb += fifo_in.timestamp.eq(full_ts) self.comb += fifo.we.eq(interface.stb) # FIFO read self.comb += [ - self.ev.eq(fifo.dout), + self.ev.eq(fifo_out), self.readable.eq(fifo.readable), fifo.re.eq(self.re) ] @@ -376,8 +392,8 @@ class RTIO(Module): if hasattr(o_manager.ev, "address"): self.comb += o_manager.ev.address.eq( self.kcsrs.o_address.storage) - ts_shift = (flen(self.kcsrs.o_timestamp.storage) - - flen(o_manager.ev.timestamp)) + ts_shift = (len(self.kcsrs.o_timestamp.storage) + - len(o_manager.ev.timestamp)) self.comb += o_manager.ev.timestamp.eq( self.kcsrs.o_timestamp.storage[ts_shift:]) @@ -412,8 +428,8 @@ class RTIO(Module): else: i_datas.append(0) if channel.interface.i.timestamped: - ts_shift = (flen(self.kcsrs.i_timestamp.status) - - flen(i_manager.ev.timestamp)) + ts_shift = (len(self.kcsrs.i_timestamp.status) + - len(i_manager.ev.timestamp)) i_timestamps.append(i_manager.ev.timestamp << ts_shift) else: i_timestamps.append(0) diff --git a/artiq/gateware/rtio/moninj.py b/artiq/gateware/rtio/moninj.py index 9bb0d0283..4ca981c14 100644 --- a/artiq/gateware/rtio/moninj.py +++ b/artiq/gateware/rtio/moninj.py @@ -1,6 +1,6 @@ -from migen.fhdl.std import * -from migen.bank.description import * +from migen import * from migen.genlib.cdc import BusSynchronizer, MultiReg +from misoc.interconnect.csr import * class Monitor(Module, AutoCSR): @@ -8,7 +8,7 @@ class Monitor(Module, AutoCSR): chan_probes = [c.probes for c in channels] max_chan_probes = max(len(cp) for cp in chan_probes) - max_probe_len = max(flen(p) for cp in chan_probes for p in cp) + max_probe_len = max(len(p) for cp in chan_probes for p in cp) self.chan_sel = CSRStorage(bits_for(len(chan_probes)-1)) self.probe_sel = CSRStorage(bits_for(max_chan_probes-1)) self.value_update = CSR() @@ -20,7 +20,7 @@ class Monitor(Module, AutoCSR): for cp in chan_probes: cp_sys = [] for p in cp: - vs = BusSynchronizer(flen(p), "rio", "rsys") + vs = BusSynchronizer(len(p), "rio", "rsys") self.submodules += vs self.comb += vs.i.eq(p) cp_sys.append(vs.o) @@ -36,7 +36,7 @@ class Injector(Module, AutoCSR): chan_overrides = [c.overrides for c in channels] max_chan_overrides = max(len(co) for co in chan_overrides) - max_override_len = max(flen(o) for co in chan_overrides for o in co) + max_override_len = max(len(o) for co in chan_overrides for o in co) self.chan_sel = CSRStorage(bits_for(len(chan_overrides)-1)) self.override_sel = CSRStorage(bits_for(max_chan_overrides-1)) self.value = CSR(max_override_len) diff --git a/artiq/gateware/rtio/phy/dds.py b/artiq/gateware/rtio/phy/dds.py index f0a8e9c8c..040a701f5 100644 --- a/artiq/gateware/rtio/phy/dds.py +++ b/artiq/gateware/rtio/phy/dds.py @@ -1,4 +1,4 @@ -from migen.fhdl.std import * +from migen import * from artiq.gateware import ad9xxx from artiq.gateware.rtio.phy.wishbone import RT2WB @@ -6,9 +6,9 @@ from artiq.gateware.rtio.phy.wishbone import RT2WB class _AD9xxx(Module): def __init__(self, ftw_base, pads, nchannels, onehot=False, **kwargs): - self.submodules._ll = RenameClockDomains( - ad9xxx.AD9xxx(pads, **kwargs), "rio") - self.submodules._rt2wb = RT2WB(flen(pads.a)+1, self._ll.bus) + self.submodules._ll = ClockDomainsRenamer("rio")( + ad9xxx.AD9xxx(pads, **kwargs)) + self.submodules._rt2wb = RT2WB(len(pads.a)+1, self._ll.bus) self.rtlink = self._rt2wb.rtlink self.probes = [Signal(32) for i in range(nchannels)] @@ -22,8 +22,8 @@ class _AD9xxx(Module): current_data.eq(self.rtlink.o.data)) # keep track of the currently selected channel(s) - current_sel = Signal(flen(current_data)-1) - self.sync.rio += If(current_address == 2**flen(pads.a) + 1, + current_sel = Signal(len(current_data)-1) + self.sync.rio += If(current_address == 2**len(pads.a) + 1, current_sel.eq(current_data[1:])) # strip reset def selected(c): @@ -35,13 +35,13 @@ class _AD9xxx(Module): # keep track of frequency tuning words, before they are FUDed ftws = [Signal(32) for i in range(nchannels)] for c, ftw in enumerate(ftws): - if flen(pads.d) == 8: + if len(pads.d) == 8: self.sync.rio_phy += \ If(selected(c), [ If(current_address == ftw_base+i, ftw[i*8:(i+1)*8].eq(current_data)) for i in range(4)]) - elif flen(pads.d) == 16: + elif len(pads.d) == 16: self.sync.rio_phy += \ If(selected(c), [ If(current_address == ftw_base+2*i, @@ -51,7 +51,7 @@ class _AD9xxx(Module): raise NotImplementedError # FTW to probe on FUD - self.sync.rio_phy += If(current_address == 2**flen(pads.a), [ + self.sync.rio_phy += If(current_address == 2**len(pads.a), [ If(selected(c), probe.eq(ftw)) for c, (probe, ftw) in enumerate(zip(self.probes, ftws))]) diff --git a/artiq/gateware/rtio/phy/ttl_serdes_7series.py b/artiq/gateware/rtio/phy/ttl_serdes_7series.py index b2322b4f5..b8c759ce9 100644 --- a/artiq/gateware/rtio/phy/ttl_serdes_7series.py +++ b/artiq/gateware/rtio/phy/ttl_serdes_7series.py @@ -1,4 +1,4 @@ -from migen.fhdl.std import * +from migen import * from artiq.gateware.rtio.phy import ttl_serdes_generic diff --git a/artiq/gateware/rtio/phy/ttl_serdes_generic.py b/artiq/gateware/rtio/phy/ttl_serdes_generic.py index 2ba010226..2ad163298 100644 --- a/artiq/gateware/rtio/phy/ttl_serdes_generic.py +++ b/artiq/gateware/rtio/phy/ttl_serdes_generic.py @@ -1,4 +1,4 @@ -from migen.fhdl.std import * +from migen import * from migen.genlib.coding import PriorityEncoder from artiq.gateware.rtio import rtlink @@ -18,7 +18,7 @@ def _mk_edges(w, direction): class _SerdesDriver(Module): def __init__(self, serdes_o, stb, data, fine_ts, override_en, override_o): previous_data = Signal() - serdes_width = flen(serdes_o) + serdes_width = len(serdes_o) edges = Array(_mk_edges(serdes_width, "rising")) edges_n = Array(_mk_edges(serdes_width, "falling")) self.sync.rio_phy += [ @@ -40,7 +40,7 @@ class _SerdesDriver(Module): class Output(Module): def __init__(self, serdes): self.rtlink = rtlink.Interface( - rtlink.OInterface(1, fine_ts_width=log2_int(flen(serdes.o)))) + rtlink.OInterface(1, fine_ts_width=log2_int(len(serdes.o)))) self.probes = [serdes.o[-1]] override_en = Signal() override_o = Signal() @@ -56,8 +56,8 @@ class Output(Module): class Inout(Module): def __init__(self, serdes): - serdes_width = flen(serdes.o) - assert flen(serdes.i) == serdes_width + serdes_width = len(serdes.o) + assert len(serdes.i) == serdes_width self.rtlink = rtlink.Interface( rtlink.OInterface(2, 2, fine_ts_width=log2_int(serdes_width)), rtlink.IInterface(1, fine_ts_width=log2_int(serdes_width))) diff --git a/artiq/gateware/rtio/phy/ttl_serdes_spartan6.py b/artiq/gateware/rtio/phy/ttl_serdes_spartan6.py index a1515c8ac..bf851a662 100644 --- a/artiq/gateware/rtio/phy/ttl_serdes_spartan6.py +++ b/artiq/gateware/rtio/phy/ttl_serdes_spartan6.py @@ -1,6 +1,6 @@ # Copyright (C) 2014, 2015 Robert Jordens -from migen.fhdl.std import * +from migen import * from artiq.gateware.rtio.phy import ttl_serdes_generic diff --git a/artiq/gateware/rtio/phy/ttl_simple.py b/artiq/gateware/rtio/phy/ttl_simple.py index d424babe7..1cc55ac48 100644 --- a/artiq/gateware/rtio/phy/ttl_simple.py +++ b/artiq/gateware/rtio/phy/ttl_simple.py @@ -1,4 +1,4 @@ -from migen.fhdl.std import * +from migen import * from migen.genlib.cdc import MultiReg from artiq.gateware.rtio import rtlink diff --git a/artiq/gateware/rtio/phy/wishbone.py b/artiq/gateware/rtio/phy/wishbone.py index b1184ca43..1b58525f6 100644 --- a/artiq/gateware/rtio/phy/wishbone.py +++ b/artiq/gateware/rtio/phy/wishbone.py @@ -1,5 +1,5 @@ -from migen.fhdl.std import * -from migen.bus import wishbone +from migen import * +from misoc.interconnect import wishbone from artiq.gateware.rtio import rtlink @@ -11,11 +11,11 @@ class RT2WB(Module): self.wb = wb self.rtlink = rtlink.Interface( rtlink.OInterface( - flen(wb.dat_w), + len(wb.dat_w), address_width + 1, suppress_nop=False), rtlink.IInterface( - flen(wb.dat_r), + len(wb.dat_r), timestamped=False) ) @@ -28,7 +28,7 @@ class RT2WB(Module): wb.adr.eq(self.rtlink.o.address[:address_width]), wb.we.eq(~self.rtlink.o.address[address_width]), wb.dat_w.eq(self.rtlink.o.data), - wb.sel.eq(2**flen(wb.sel) - 1) + wb.sel.eq(2**len(wb.sel) - 1) ), If(wb.ack, active.eq(0) diff --git a/artiq/gateware/rtio/rtlink.py b/artiq/gateware/rtio/rtlink.py index b6d6dc000..c9d281ceb 100644 --- a/artiq/gateware/rtio/rtlink.py +++ b/artiq/gateware/rtio/rtlink.py @@ -1,4 +1,4 @@ -from migen.fhdl.std import * +from migen import * class OInterface: @@ -64,7 +64,7 @@ def _get_or_zero(interface, attr): _get_or_zero(interface.o, attr)) else: if hasattr(interface, attr): - return flen(getattr(interface, attr)) + return len(getattr(interface, attr)) else: return 0 diff --git a/artiq/gateware/soc.py b/artiq/gateware/soc.py index 15095ea92..f5b48caf9 100644 --- a/artiq/gateware/soc.py +++ b/artiq/gateware/soc.py @@ -1,5 +1,5 @@ -from misoclib.soc import mem_decoder -from misoclib.cpu import timer +from misoc.integration.soc_core import mem_decoder +from misoc.cores import timer from artiq.gateware import amp @@ -11,7 +11,7 @@ class AMPSoC: a "mailbox" entry in the memory map. """ def __init__(self): - if not hasattr(self, "cpu_or_bridge"): + if not hasattr(self, "cpu"): raise ValueError("Platform SoC must be initialized first") if hasattr(self, "timer0"): raise ValueError("Timer already exists. " diff --git a/soc/targets/artiq_kc705.py b/artiq/gateware/targets/kc705.py old mode 100644 new mode 100755 similarity index 79% rename from soc/targets/artiq_kc705.py rename to artiq/gateware/targets/kc705.py index a548d98dc..66ba7b3f8 --- a/soc/targets/artiq_kc705.py +++ b/artiq/gateware/targets/kc705.py @@ -1,20 +1,26 @@ -from migen.fhdl.std import * +#!/usr/bin/env python3 + +import argparse +import os + +from migen import * from migen.genlib.resetsync import AsyncResetSynchronizer from migen.genlib.cdc import MultiReg -from migen.bank.description import * -from migen.bank import wbgen -from mibuild.generic_platform import * -from mibuild.xilinx.vivado import XilinxVivadoToolchain -from mibuild.xilinx.ise import XilinxISEToolchain +from migen.build.generic_platform import * +from migen.build.xilinx.vivado import XilinxVivadoToolchain +from migen.build.xilinx.ise import XilinxISEToolchain -from misoclib.com import gpio -from misoclib.soc import mem_decoder -from misoclib.mem.sdram.core.minicon import MiniconSettings -from targets.kc705 import MiniSoC +from misoc.interconnect.csr import * +from misoc.interconnect import wishbone +from misoc.cores import gpio +from misoc.integration.soc_core import mem_decoder +from misoc.integration.builder import * +from misoc.targets.kc705 import MiniSoC, soc_kc705_args, soc_kc705_argdict from artiq.gateware.soc import AMPSoC from artiq.gateware import rtio, nist_qc1, nist_qc2 from artiq.gateware.rtio.phy import ttl_simple, ttl_serdes_7series, dds +from artiq.tools import artiq_dir class _RTIOCRG(Module, AutoCSR): @@ -87,15 +93,17 @@ class _NIST_QCx(MiniSoC, AMPSoC): } mem_map.update(MiniSoC.mem_map) - def __init__(self, platform, cpu_type="or1k", **kwargs): - MiniSoC.__init__(self, platform, + def __init__(self, cpu_type="or1k", **kwargs): + MiniSoC.__init__(self, cpu_type=cpu_type, - sdram_controller_settings=MiniconSettings(l2_size=128*1024), + sdram_controller_type="minicon", + l2_size=128*1024, with_timer=False, **kwargs) AMPSoC.__init__(self) + self.submodules.leds = gpio.GPIOOut(Cat( - platform.request("user_led", 0), - platform.request("user_led", 1))) + self.platform.request("user_led", 0), + self.platform.request("user_led", 1))) def add_rtio(self, rtio_channels): self.submodules.rtio_crg = _RTIOCRG(self.platform, self.crg.cd_sys.clk) @@ -121,7 +129,7 @@ TIMESPEC "TSfix_cdc2" = FROM "GRPrio_clk" TO "GRPrsys_clk" TIG; """, rio_clk=self.rtio_crg.cd_rtio.clk) rtio_csrs = self.rtio.get_csrs() - self.submodules.rtiowb = wbgen.Bank(rtio_csrs) + self.submodules.rtiowb = wishbone.CSRBank(rtio_csrs) self.kernel_cpu.add_wb_slave(mem_decoder(self.mem_map["rtio"]), self.rtiowb.bus) self.add_csr_region("rtio", self.mem_map["rtio"] | 0x80000000, 32, @@ -129,8 +137,10 @@ TIMESPEC "TSfix_cdc2" = FROM "GRPrio_clk" TO "GRPrsys_clk" TIG; class NIST_QC1(_NIST_QCx): - def __init__(self, platform, cpu_type="or1k", **kwargs): - _NIST_QCx.__init__(self, platform, cpu_type, **kwargs) + def __init__(self, cpu_type="or1k", **kwargs): + _NIST_QCx.__init__(self, cpu_type, **kwargs) + + platform = self.platform platform.add_extension(nist_qc1.fmc_adapter_io) self.comb += [ @@ -174,6 +184,8 @@ class NIST_QC1(_NIST_QCx): class NIST_QC2(_NIST_QCx): def __init__(self, platform, cpu_type="or1k", **kwargs): _NIST_QCx.__init__(self, platform, cpu_type, **kwargs) + + platform = self.platform platform.add_extension(nist_qc2.fmc_adapter_io) rtio_channels = [] @@ -214,4 +226,34 @@ class NIST_QC2(_NIST_QCx): self.add_rtio(rtio_channels) -default_subtarget = NIST_QC1 +def main(): + parser = argparse.ArgumentParser( + description="ARTIQ core device builder / KC705 " + "+ NIST Ions QC1/QC2 hardware adapters") + builder_args(parser) + soc_kc705_args(parser) + parser.add_argument("-H", "--hw-adapter", default="qc1", + help="hardware adapter type: qc1/qc2 " + "(default: %(default)s)") + args = parser.parse_args() + + hw_adapter = args.hw_adapter.lower() + if hw_adapter == "qc1": + cls = NIST_QC1 + elif hw_adapter == "qc2": + cls = NIST_QC2 + else: + print("Invalid hardware adapter string (-H/--hw-adapter), " + "choose from qc1 or qc2") + sys.exit(1) + + soc = cls(**soc_kc705_argdict(args)) + builder = Builder(soc, **builder_argdict(args)) + builder.add_software_package("liblwip", os.path.join(artiq_dir, "runtime", + "liblwip")) + builder.add_software_package("runtime", os.path.join(artiq_dir, "runtime")) + builder.build() + + +if __name__ == "__main__": + main() diff --git a/soc/targets/artiq_pipistrello.py b/artiq/gateware/targets/pipistrello.py old mode 100644 new mode 100755 similarity index 87% rename from soc/targets/artiq_pipistrello.py rename to artiq/gateware/targets/pipistrello.py index 044e4d02c..0561f850b --- a/soc/targets/artiq_pipistrello.py +++ b/artiq/gateware/targets/pipistrello.py @@ -1,22 +1,26 @@ +#!/usr/bin/env python3 + # Copyright (C) 2014, 2015 Robert Jordens # Copyright (C) 2014, 2015 M-Labs Limited +import argparse +import os from fractions import Fraction -from migen.fhdl.std import * -from migen.bank.description import * -from migen.bank import wbgen +from migen import * from migen.genlib.resetsync import AsyncResetSynchronizer from migen.genlib.cdc import MultiReg -from misoclib.com import gpio -from misoclib.soc import mem_decoder -from misoclib.mem.sdram.core.minicon import MiniconSettings -from targets.pipistrello import BaseSoC +from misoc.interconnect.csr import * +from misoc.interconnect import wishbone +from misoc.cores import gpio +from misoc.integration.soc_core import mem_decoder +from misoc.targets.pipistrello import * from artiq.gateware.soc import AMPSoC from artiq.gateware import rtio, nist_qc1 from artiq.gateware.rtio.phy import ttl_simple, ttl_serdes_spartan6, dds +from artiq.tools import artiq_dir class _RTIOCRG(Module, AutoCSR): @@ -110,12 +114,15 @@ class NIST_QC1(BaseSoC, AMPSoC): } mem_map.update(BaseSoC.mem_map) - def __init__(self, platform, cpu_type="or1k", **kwargs): - BaseSoC.__init__(self, platform, + def __init__(self, cpu_type="or1k", **kwargs): + BaseSoC.__init__(self, cpu_type=cpu_type, - sdram_controller_settings=MiniconSettings(l2_size=64*1024), + l2_size=64*1024, with_timer=False, **kwargs) AMPSoC.__init__(self) + + platform = self.platform + platform.toolchain.ise_commands += """ trce -v 12 -fastpaths -tsi {build_name}.tsi -o {build_name}.twr {build_name}.ncd {build_name}.pcf """ @@ -192,11 +199,28 @@ trce -v 12 -fastpaths -tsi {build_name}.tsi -o {build_name}.twr {build_name}.ncd # CPU connections rtio_csrs = self.rtio.get_csrs() - self.submodules.rtiowb = wbgen.Bank(rtio_csrs) + self.submodules.rtiowb = wishbone.CSRBank(rtio_csrs) self.kernel_cpu.add_wb_slave(mem_decoder(self.mem_map["rtio"]), self.rtiowb.bus) self.add_csr_region("rtio", self.mem_map["rtio"] | 0x80000000, 32, rtio_csrs) -default_subtarget = NIST_QC1 +def main(): + parser = argparse.ArgumentParser( + description="ARTIQ core device builder / Pipistrello " + "+ NIST Ions QC1 hardware adapter") + builder_args(parser) + soc_pipistrello_args(parser) + args = parser.parse_args() + + soc = NIST_QC1(**soc_pipistrello_argdict(args)) + builder = Builder(soc, **builder_argdict(args)) + builder.add_software_package("liblwip", os.path.join(artiq_dir, "runtime", + "liblwip")) + builder.add_software_package("runtime", os.path.join(artiq_dir, "runtime")) + builder.build() + + +if __name__ == "__main__": + main() diff --git a/artiq/runtime/Makefile b/artiq/runtime/Makefile new file mode 100644 index 000000000..cb3dd41e9 --- /dev/null +++ b/artiq/runtime/Makefile @@ -0,0 +1,64 @@ +include ../include/generated/variables.mak +include $(MISOC_DIRECTORY)/software/common.mak + +PYTHON ?= python3 + +OBJECTS := isr.o flash_storage.o clock.o rtiocrg.o elf_loader.o services.o session.o log.o test_mode.o kloader.o bridge_ctl.o mailbox.o ksupport_data.o net_server.o moninj.o main.o +OBJECTS_KSUPPORT := ksupport.o exception_jmp.o exceptions.o mailbox.o bridge.o rtio.o ttl.o dds.o + +CFLAGS += -I$(LIBLWIP_DIRECTORY)/../lwip/src/include -I$(LIBLWIP_DIRECTORY) + +all: runtime.bin runtime.fbi + +%.bin: %.elf + $(OBJCOPY) -O binary $< $@ + @chmod -x $@ + +%.fbi: %.bin + @echo " MSCIMG " $@ && $(PYTHON) -m misoc.tools.mkmscimg -f -o $@ $< + +runtime.elf: $(OBJECTS) + $(LD) $(LDFLAGS) \ + -T $(RUNTIME_DIRECTORY)/linker.ld \ + -N -o $@ \ + ../libbase/crt0-$(CPU).o \ + $(OBJECTS) \ + -L../libbase \ + -L../libcompiler_rt \ + -L../liblwip \ + -lbase -lcompiler_rt -llwip + @chmod -x $@ + +ksupport.elf: $(OBJECTS_KSUPPORT) + $(LD) $(LDFLAGS) \ + -T $(RUNTIME_DIRECTORY)/ksupport.ld \ + -N -o $@ \ + ../libbase/crt0-$(CPU).o \ + $^ \ + -L../libcompiler_rt \ + -lcompiler_rt + @chmod -x $@ + +ksupport_data.o: ksupport.bin + $(LD) -r -b binary -o $@ $< + +service_table.h: ksupport.elf $(RUNTIME_DIRECTORY)/gen_service_table.py + @echo " GEN " $@ && $(PYTHON) $(RUNTIME_DIRECTORY)/gen_service_table.py ksupport.elf > $@ + +services.c: service_table.h + +main.o: $(RUNTIME_DIRECTORY)/main.c + $(compile) + +%.o: $(RUNTIME_DIRECTORY)/%.c + $(compile) + +%.o: $(RUNTIME_DIRECTORY)/%.S + $(assemble) + +clean: + $(RM) $(OBJECTS) $(OBJECTS_KSUPPORT) + $(RM) runtime.elf runtime.bin runtime.fbi .*~ *~ + $(RM) service_table.h ksupport.elf ksupport.bin + +.PHONY: all clean main.o diff --git a/soc/runtime/bridge.c b/artiq/runtime/bridge.c similarity index 100% rename from soc/runtime/bridge.c rename to artiq/runtime/bridge.c diff --git a/soc/runtime/bridge.h b/artiq/runtime/bridge.h similarity index 100% rename from soc/runtime/bridge.h rename to artiq/runtime/bridge.h diff --git a/soc/runtime/bridge_ctl.c b/artiq/runtime/bridge_ctl.c similarity index 100% rename from soc/runtime/bridge_ctl.c rename to artiq/runtime/bridge_ctl.c diff --git a/soc/runtime/bridge_ctl.h b/artiq/runtime/bridge_ctl.h similarity index 100% rename from soc/runtime/bridge_ctl.h rename to artiq/runtime/bridge_ctl.h diff --git a/soc/runtime/clock.c b/artiq/runtime/clock.c similarity index 100% rename from soc/runtime/clock.c rename to artiq/runtime/clock.c diff --git a/soc/runtime/clock.h b/artiq/runtime/clock.h similarity index 100% rename from soc/runtime/clock.h rename to artiq/runtime/clock.h diff --git a/soc/runtime/dds.c b/artiq/runtime/dds.c similarity index 100% rename from soc/runtime/dds.c rename to artiq/runtime/dds.c diff --git a/soc/runtime/dds.h b/artiq/runtime/dds.h similarity index 100% rename from soc/runtime/dds.h rename to artiq/runtime/dds.h diff --git a/soc/runtime/elf_loader.c b/artiq/runtime/elf_loader.c similarity index 100% rename from soc/runtime/elf_loader.c rename to artiq/runtime/elf_loader.c diff --git a/soc/runtime/elf_loader.h b/artiq/runtime/elf_loader.h similarity index 100% rename from soc/runtime/elf_loader.h rename to artiq/runtime/elf_loader.h diff --git a/soc/runtime/exception_jmp.S b/artiq/runtime/exception_jmp.S similarity index 100% rename from soc/runtime/exception_jmp.S rename to artiq/runtime/exception_jmp.S diff --git a/soc/runtime/exceptions.c b/artiq/runtime/exceptions.c similarity index 100% rename from soc/runtime/exceptions.c rename to artiq/runtime/exceptions.c diff --git a/soc/runtime/exceptions.h b/artiq/runtime/exceptions.h similarity index 100% rename from soc/runtime/exceptions.h rename to artiq/runtime/exceptions.h diff --git a/soc/runtime/flash_storage.c b/artiq/runtime/flash_storage.c similarity index 100% rename from soc/runtime/flash_storage.c rename to artiq/runtime/flash_storage.c diff --git a/soc/runtime/flash_storage.h b/artiq/runtime/flash_storage.h similarity index 100% rename from soc/runtime/flash_storage.h rename to artiq/runtime/flash_storage.h diff --git a/soc/runtime/gen_service_table.py b/artiq/runtime/gen_service_table.py similarity index 100% rename from soc/runtime/gen_service_table.py rename to artiq/runtime/gen_service_table.py diff --git a/soc/runtime/isr.c b/artiq/runtime/isr.c similarity index 100% rename from soc/runtime/isr.c rename to artiq/runtime/isr.c diff --git a/soc/runtime/kloader.c b/artiq/runtime/kloader.c similarity index 100% rename from soc/runtime/kloader.c rename to artiq/runtime/kloader.c diff --git a/soc/runtime/kloader.h b/artiq/runtime/kloader.h similarity index 100% rename from soc/runtime/kloader.h rename to artiq/runtime/kloader.h diff --git a/soc/runtime/ksupport.c b/artiq/runtime/ksupport.c similarity index 100% rename from soc/runtime/ksupport.c rename to artiq/runtime/ksupport.c diff --git a/soc/runtime/ksupport.ld b/artiq/runtime/ksupport.ld similarity index 100% rename from soc/runtime/ksupport.ld rename to artiq/runtime/ksupport.ld diff --git a/artiq/runtime/liblwip/Makefile b/artiq/runtime/liblwip/Makefile new file mode 100644 index 000000000..6febd6e10 --- /dev/null +++ b/artiq/runtime/liblwip/Makefile @@ -0,0 +1,66 @@ +include ../include/generated/variables.mak +include $(MISOC_DIRECTORY)/software/common.mak + +LWIPDIR=$(LIBLWIP_DIRECTORY)/../lwip/src + +CFLAGS += $(CPPFLAGS) -I. \ + -I$(LWIPDIR)/include \ + -I$(LWIPDIR)/include/ipv4 + +# COREFILES, CORE4FILES: The minimum set of files needed for lwIP. +COREFILES=core/mem.c \ + core/memp.c \ + core/netif.c \ + core/pbuf.c \ + core/raw.c \ + core/stats.c \ + core/sys.c \ + core/tcp.c \ + core/tcp_in.c \ + core/tcp_out.c \ + core/udp.c \ + core/dhcp.c \ + core/inet_chksum.c \ + core/timers.c \ + core/init.c + +CORE4FILES=core/ipv4/icmp.c \ + core/ipv4/ip4.c \ + core/ipv4/ip4_addr.c \ + core/ipv4/ip_frag.c + +# NETIFFILES: Files implementing various generic network interface functions. +NETIFFILES=netif/etharp.c + +# LWIPFILES: All the above. +LWIPFILES=$(COREFILES) $(CORE4FILES) $(NETIFFILES) + +LWIPOBJS:=$(LWIPFILES:.c=.o) liteethif.o + +all: prepare liblwip.a + +prepare: + ln -sf $(LIBLWIP_DIRECTORY)/lwipopts.h lwipopts.h + ln -sf $(LIBLWIP_DIRECTORY)/arch arch + mkdir -p core/ipv4 + mkdir -p netif + +core/%.o: $(LWIPDIR)/core/%.c + $(compile) + +core/ipv4/%.o: $(LWIPDIR)/core/ipv4/%.c + $(compile) + +netif/%.o: $(LWIPDIR)/netif/%.c + $(compile) + +%.o: $(LIBLWIP_DIRECTORY)/%.c + $(compile) + +.PHONY: all clean prepare + +clean: + rm -f $(LWIPOBJS) liblwip.a + +liblwip.a: $(LWIPOBJS) + $(AR) clr liblwip.a $(LWIPOBJS) diff --git a/soc/runtime/liblwip/arch/cc.h b/artiq/runtime/liblwip/arch/cc.h similarity index 100% rename from soc/runtime/liblwip/arch/cc.h rename to artiq/runtime/liblwip/arch/cc.h diff --git a/soc/runtime/liblwip/arch/perf.h b/artiq/runtime/liblwip/arch/perf.h similarity index 100% rename from soc/runtime/liblwip/arch/perf.h rename to artiq/runtime/liblwip/arch/perf.h diff --git a/soc/runtime/liblwip/arch/sys_arch.h b/artiq/runtime/liblwip/arch/sys_arch.h similarity index 100% rename from soc/runtime/liblwip/arch/sys_arch.h rename to artiq/runtime/liblwip/arch/sys_arch.h diff --git a/soc/runtime/liblwip/netif/liteethif.c b/artiq/runtime/liblwip/liteethif.c similarity index 99% rename from soc/runtime/liblwip/netif/liteethif.c rename to artiq/runtime/liblwip/liteethif.c index 757918e25..2e57e26b7 100644 --- a/soc/runtime/liblwip/netif/liteethif.c +++ b/artiq/runtime/liblwip/liteethif.c @@ -10,7 +10,7 @@ #include #include -#include "netif/liteethif.h" +#include "liteethif.h" #include #include diff --git a/soc/runtime/liblwip/netif/liteethif.h b/artiq/runtime/liblwip/liteethif.h similarity index 100% rename from soc/runtime/liblwip/netif/liteethif.h rename to artiq/runtime/liblwip/liteethif.h diff --git a/soc/runtime/liblwip/lwipopts.h b/artiq/runtime/liblwip/lwipopts.h similarity index 100% rename from soc/runtime/liblwip/lwipopts.h rename to artiq/runtime/liblwip/lwipopts.h diff --git a/soc/runtime/linker.ld b/artiq/runtime/linker.ld similarity index 100% rename from soc/runtime/linker.ld rename to artiq/runtime/linker.ld diff --git a/soc/runtime/log.c b/artiq/runtime/log.c similarity index 100% rename from soc/runtime/log.c rename to artiq/runtime/log.c diff --git a/soc/runtime/log.h b/artiq/runtime/log.h similarity index 100% rename from soc/runtime/log.h rename to artiq/runtime/log.h diff --git a/soc/runtime/lwip b/artiq/runtime/lwip similarity index 100% rename from soc/runtime/lwip rename to artiq/runtime/lwip diff --git a/soc/runtime/mailbox.c b/artiq/runtime/mailbox.c similarity index 100% rename from soc/runtime/mailbox.c rename to artiq/runtime/mailbox.c diff --git a/soc/runtime/mailbox.h b/artiq/runtime/mailbox.h similarity index 100% rename from soc/runtime/mailbox.h rename to artiq/runtime/mailbox.h diff --git a/soc/runtime/main.c b/artiq/runtime/main.c similarity index 99% rename from soc/runtime/main.c rename to artiq/runtime/main.c index f020b74ea..173ab486d 100644 --- a/soc/runtime/main.c +++ b/artiq/runtime/main.c @@ -8,8 +8,6 @@ #include #ifdef CSR_ETHMAC_BASE -#include -#include #include #include #include @@ -18,6 +16,8 @@ #include #include #include +#include +#include #endif #include "bridge_ctl.h" diff --git a/soc/runtime/messages.h b/artiq/runtime/messages.h similarity index 100% rename from soc/runtime/messages.h rename to artiq/runtime/messages.h diff --git a/soc/runtime/moninj.c b/artiq/runtime/moninj.c similarity index 100% rename from soc/runtime/moninj.c rename to artiq/runtime/moninj.c diff --git a/soc/runtime/moninj.h b/artiq/runtime/moninj.h similarity index 100% rename from soc/runtime/moninj.h rename to artiq/runtime/moninj.h diff --git a/soc/runtime/net_server.c b/artiq/runtime/net_server.c similarity index 99% rename from soc/runtime/net_server.c rename to artiq/runtime/net_server.c index fa06474b6..296fded5f 100644 --- a/soc/runtime/net_server.c +++ b/artiq/runtime/net_server.c @@ -2,8 +2,6 @@ #ifdef CSR_ETHMAC_BASE -#include -#include #include #include #include @@ -12,6 +10,8 @@ #include #include #include +#include +#include #include "session.h" #include "net_server.h" diff --git a/soc/runtime/net_server.h b/artiq/runtime/net_server.h similarity index 100% rename from soc/runtime/net_server.h rename to artiq/runtime/net_server.h diff --git a/soc/runtime/rtio.c b/artiq/runtime/rtio.c similarity index 100% rename from soc/runtime/rtio.c rename to artiq/runtime/rtio.c diff --git a/soc/runtime/rtio.h b/artiq/runtime/rtio.h similarity index 100% rename from soc/runtime/rtio.h rename to artiq/runtime/rtio.h diff --git a/soc/runtime/rtiocrg.c b/artiq/runtime/rtiocrg.c similarity index 100% rename from soc/runtime/rtiocrg.c rename to artiq/runtime/rtiocrg.c diff --git a/soc/runtime/rtiocrg.h b/artiq/runtime/rtiocrg.h similarity index 100% rename from soc/runtime/rtiocrg.h rename to artiq/runtime/rtiocrg.h diff --git a/soc/runtime/services.c b/artiq/runtime/services.c similarity index 100% rename from soc/runtime/services.c rename to artiq/runtime/services.c diff --git a/soc/runtime/services.h b/artiq/runtime/services.h similarity index 100% rename from soc/runtime/services.h rename to artiq/runtime/services.h diff --git a/soc/runtime/session.c b/artiq/runtime/session.c similarity index 100% rename from soc/runtime/session.c rename to artiq/runtime/session.c diff --git a/soc/runtime/session.h b/artiq/runtime/session.h similarity index 100% rename from soc/runtime/session.h rename to artiq/runtime/session.h diff --git a/soc/runtime/test_mode.c b/artiq/runtime/test_mode.c similarity index 100% rename from soc/runtime/test_mode.c rename to artiq/runtime/test_mode.c diff --git a/soc/runtime/test_mode.h b/artiq/runtime/test_mode.h similarity index 100% rename from soc/runtime/test_mode.h rename to artiq/runtime/test_mode.h diff --git a/soc/runtime/ttl.c b/artiq/runtime/ttl.c similarity index 100% rename from soc/runtime/ttl.c rename to artiq/runtime/ttl.c diff --git a/soc/runtime/ttl.h b/artiq/runtime/ttl.h similarity index 100% rename from soc/runtime/ttl.h rename to artiq/runtime/ttl.h diff --git a/artiq/tools.py b/artiq/tools.py index dfd9ef0bb..cde22a629 100644 --- a/artiq/tools.py +++ b/artiq/tools.py @@ -6,7 +6,7 @@ import sys import asyncio import time import collections -import os.path +import os import numpy as np @@ -16,6 +16,8 @@ from artiq.protocols import pyon logger = logging.getLogger(__name__) +artiq_dir = os.path.join(os.path.abspath(os.path.dirname(__file__))) + def parse_arguments(arguments): d = {} diff --git a/soc/runtime/Makefile b/soc/runtime/Makefile deleted file mode 100644 index bbfa9ef8a..000000000 --- a/soc/runtime/Makefile +++ /dev/null @@ -1,72 +0,0 @@ -include $(MSCDIR)/software/common.mak - -PYTHON ?= python3 - -OBJECTS := isr.o flash_storage.o clock.o rtiocrg.o elf_loader.o services.o session.o log.o test_mode.o kloader.o bridge_ctl.o mailbox.o ksupport_data.o net_server.o moninj.o main.o -OBJECTS_KSUPPORT := ksupport.o exception_jmp.o exceptions.o mailbox.o bridge.o rtio.o ttl.o dds.o - -CFLAGS += -Ilwip/src/include -Iliblwip - -all: runtime.bin runtime.fbi - -# pull in dependency info for *existing* .o files --include $(OBJECTS:.o=.d) - -%.bin: %.elf - $(OBJCOPY) -O binary $< $@ - @chmod -x $@ - -%.fbi: %.bin - @echo " MSCIMG " $@ && $(MSCDIR)/mkmscimg.py -f -o $@ $< - -runtime.elf: $(OBJECTS) libs - $(LD) $(LDFLAGS) \ - -T linker.ld \ - -N -o $@ \ - $(MSCDIR)/software/libbase/crt0-$(CPU).o \ - $(OBJECTS) \ - -L$(MSCDIR)/software/libbase \ - -L$(MSCDIR)/software/libcompiler-rt \ - -Lliblwip \ - -lbase -lcompiler-rt -llwip - @chmod -x $@ - -ksupport.elf: $(OBJECTS_KSUPPORT) - $(LD) $(LDFLAGS) \ - -T ksupport.ld \ - -N -o $@ \ - $(MSCDIR)/software/libbase/crt0-$(CPU).o \ - $^ \ - -L$(MSCDIR)/software/libcompiler-rt \ - -lcompiler-rt - @chmod -x $@ - -ksupport_data.o: ksupport.bin - $(LD) -r -b binary -o $@ $< - -service_table.h: ksupport.elf gen_service_table.py - @echo " GEN " $@ && $(PYTHON) gen_service_table.py ksupport.elf > $@ - -services.c: service_table.h - -main.o: main.c - $(compile-dep) - -%.o: %.c - $(compile-dep) - -%.o: %.S - $(assemble) - -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 - -.PHONY: all main.o clean libs load diff --git a/soc/runtime/liblwip/Makefile b/soc/runtime/liblwip/Makefile deleted file mode 100644 index 0aaabd954..000000000 --- a/soc/runtime/liblwip/Makefile +++ /dev/null @@ -1,55 +0,0 @@ -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) From 3404a6565b7af1c3e0eaa21d1159afea8aba2ae1 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Wed, 4 Nov 2015 10:40:46 +0800 Subject: [PATCH 08/20] frontend/artiq_flash: reorganize device binaries --- artiq/frontend/artiq_flash.sh | 37 +++++++++++++++-------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/artiq/frontend/artiq_flash.sh b/artiq/frontend/artiq_flash.sh index 94773ec9b..4443c54b6 100755 --- a/artiq/frontend/artiq_flash.sh +++ b/artiq/frontend/artiq_flash.sh @@ -11,17 +11,14 @@ def run(script): file.close() run(""" -# exit on error set -e -# print commands -#set -x ARTIQ_PREFIX=$(python3 -c "import artiq; print(artiq.__path__[0])") # Default is kc705 BOARD=kc705 -# Default mezzanine board is nist_qc1 -MEZZANINE_BOARD=nist_qc1 +# Default hardware adapter is qc1 +HARDWARE_ADAPTER=qc1 while getopts "bBrht:d:f:m:" opt do @@ -67,14 +64,14 @@ do fi ;; m) - if [ "$OPTARG" == "nist_qc1" ] + if [ "$OPTARG" == "qc1" ] then - MEZZANINE_BOARD=nist_qc1 - elif [ "$OPTARG" == "nist_qc2" ] + HARDWARE_ADAPTER=qc1 + elif [ "$OPTARG" == "qc2" ] then - MEZZANINE_BOARD=nist_qc2 + HARDWARE_ADAPTER=qc2 else - echo "KC705 mezzanine board is either nist_qc1 or nist_qc2" + echo "Hardware adapter should be qc1 or qc2" exit 1 fi ;; @@ -88,8 +85,8 @@ do echo "-B Flash BIOS" echo "-r Flash ARTIQ runtime" echo "-h Show this help message" - echo "-t Target (kc705, pipistrello, default is: kc705)" - echo "-m Mezzanine board (nist_qc1, nist_qc2, default is: nist_qc1)" + echo "-t Target (kc705/pipistrello, default: kc705)" + echo "-m Hardware adapter (qc1/qc2, default: qc1)" echo "-f Flash storage image generated with artiq_mkfs" echo "-d Directory containing the binaries to be flashed" exit 1 @@ -129,30 +126,28 @@ fi if [ "$BOARD" == "kc705" ] then UDEV_RULES=99-kc705.rules - BITSTREAM=artiq_kc705-${MEZZANINE_BOARD}-kc705.bit CABLE=jtaghs1_fast PROXY=bscan_spi_kc705.bit BIOS_ADDR=0xaf0000 RUNTIME_ADDR=0xb00000 - RUNTIME_FILE=runtime.fbi FS_ADDR=0xb40000 if [ -z "$BIN_PREFIX" ] then - RUNTIME_FILE=${MEZZANINE_BOARD}/runtime.fbi - BIN_PREFIX=$ARTIQ_PREFIX/binaries/kc705 + BIN_PREFIX=$ARTIQ_PREFIX/binaries/kc705-$HARDWARE_ADAPTER fi search_for_proxy $PROXY elif [ "$BOARD" == "pipistrello" ] then UDEV_RULES=99-papilio.rules - BITSTREAM=artiq_pipistrello-nist_qc1-pipistrello.bit CABLE=papilio PROXY=bscan_spi_lx45_csg324.bit BIOS_ADDR=0x170000 RUNTIME_ADDR=0x180000 - RUNTIME_FILE=runtime.fbi FS_ADDR=0x1c0000 - if [ -z "$BIN_PREFIX" ]; then BIN_PREFIX=$ARTIQ_PREFIX/binaries/pipistrello; fi + if [ -z "$BIN_PREFIX" ]; + then + BIN_PREFIX=$ARTIQ_PREFIX/binaries/pipistrello-$HARDWARE_ADAPTER + fi search_for_proxy $PROXY fi @@ -195,7 +190,7 @@ fi if [ "${FLASH_BITSTREAM}" == "1" ] then echo "Flashing FPGA bitstream..." - xc3sprog -v -c $CABLE -I$PROXY_PATH/$PROXY $BIN_PREFIX/$BITSTREAM:w:0x0:BIT + xc3sprog -v -c $CABLE -I$PROXY_PATH/$PROXY $BIN_PREFIX/top.bit:w:0x0:BIT fi if [ "${FLASH_BIOS}" == "1" ] @@ -207,7 +202,7 @@ fi if [ "${FLASH_RUNTIME}" == "1" ] then echo "Flashing ARTIQ runtime..." - xc3sprog -v -c $CABLE -I$PROXY_PATH/$PROXY $BIN_PREFIX/${RUNTIME_FILE}:w:$RUNTIME_ADDR:BIN + xc3sprog -v -c $CABLE -I$PROXY_PATH/$PROXY $BIN_PREFIX/runtime.fbi:w:$RUNTIME_ADDR:BIN fi echo "Done." xc3sprog -v -c $CABLE -R > /dev/null 2>&1 From 087c2fd078c64f75baffd72d7b2a735459c7442f Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Wed, 4 Nov 2015 11:22:56 +0800 Subject: [PATCH 09/20] runtime: fix generation of service_table.h --- .gitignore | 1 - artiq/runtime/Makefile | 7 +++++-- artiq/runtime/services.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 83bcf3a24..950cbbedb 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,6 @@ __pycache__ *.bin *.elf *.fbi -artiq/runtime/service_table.h doc/manual/_build /build /dist diff --git a/artiq/runtime/Makefile b/artiq/runtime/Makefile index cb3dd41e9..476d4ab3f 100644 --- a/artiq/runtime/Makefile +++ b/artiq/runtime/Makefile @@ -6,7 +6,7 @@ PYTHON ?= python3 OBJECTS := isr.o flash_storage.o clock.o rtiocrg.o elf_loader.o services.o session.o log.o test_mode.o kloader.o bridge_ctl.o mailbox.o ksupport_data.o net_server.o moninj.o main.o OBJECTS_KSUPPORT := ksupport.o exception_jmp.o exceptions.o mailbox.o bridge.o rtio.o ttl.o dds.o -CFLAGS += -I$(LIBLWIP_DIRECTORY)/../lwip/src/include -I$(LIBLWIP_DIRECTORY) +CFLAGS += -I$(LIBLWIP_DIRECTORY)/../lwip/src/include -I$(LIBLWIP_DIRECTORY) -I. all: runtime.bin runtime.fbi @@ -45,7 +45,10 @@ ksupport_data.o: ksupport.bin service_table.h: ksupport.elf $(RUNTIME_DIRECTORY)/gen_service_table.py @echo " GEN " $@ && $(PYTHON) $(RUNTIME_DIRECTORY)/gen_service_table.py ksupport.elf > $@ -services.c: service_table.h +$(RUNTIME_DIRECTORY)/services.c: service_table.h + +services.o: $(RUNTIME_DIRECTORY)/services.c service_table.h + $(compile) main.o: $(RUNTIME_DIRECTORY)/main.c $(compile) diff --git a/artiq/runtime/services.c b/artiq/runtime/services.c index 74bdeef71..39db8537b 100644 --- a/artiq/runtime/services.c +++ b/artiq/runtime/services.c @@ -8,7 +8,7 @@ #include "exceptions.h" #include "services.h" -#include "service_table.h" +#include #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wimplicit-int" From 38740a4abe8d5682a0bc69ed126b5279e1820418 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Wed, 4 Nov 2015 12:34:18 +0800 Subject: [PATCH 10/20] runtime: log startup kernel start --- artiq/runtime/session.c | 1 + 1 file changed, 1 insertion(+) diff --git a/artiq/runtime/session.c b/artiq/runtime/session.c index a76a51687..5fa39f8cd 100644 --- a/artiq/runtime/session.c +++ b/artiq/runtime/session.c @@ -73,6 +73,7 @@ void session_startup_kernel(void) if(!kloader_start_startup_kernel()) return; + log("Startup kernel started"); while(1) { kloader_service_essential_kmsg(); From 649069980a6ce716663237927424c0a4eb82eb9e Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Wed, 4 Nov 2015 15:59:08 +0800 Subject: [PATCH 11/20] conda,travis: use new SoC build system --- .travis.yml | 1 - .travis/get-misoc.sh | 4 ---- .travis/get-xilinx.sh | 6 +++--- conda/artiq-kc705-nist_qc1/build.sh | 25 ++++++---------------- conda/artiq-kc705-nist_qc1/meta.yaml | 1 + conda/artiq-kc705-nist_qc2/build.sh | 25 ++++++---------------- conda/artiq-kc705-nist_qc2/meta.yaml | 1 + conda/artiq-pipistrello-nist_qc1/build.sh | 23 ++++++-------------- conda/artiq-pipistrello-nist_qc1/meta.yaml | 1 + 9 files changed, 26 insertions(+), 61 deletions(-) delete mode 100755 .travis/get-misoc.sh diff --git a/.travis.yml b/.travis.yml index e05589de2..881694a54 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,6 @@ install: - if [ $TRAVIS_PULL_REQUEST != false ]; then BUILD_SOC=none; fi - if [ $BUILD_SOC != none ]; then ./.travis/get-xilinx.sh; fi - if [ $BUILD_SOC != none ]; then ./.travis/get-toolchain.sh; fi - - if [ $BUILD_SOC != none ]; then ./.travis/get-misoc.sh; fi - . ./.travis/get-anaconda.sh - source $HOME/miniconda/bin/activate py35 - conda install -q pip coverage anaconda-client cython diff --git a/.travis/get-misoc.sh b/.travis/get-misoc.sh deleted file mode 100755 index 355e8ffa5..000000000 --- a/.travis/get-misoc.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -git clone --recursive https://github.com/m-labs/misoc $HOME/misoc -echo "export MSCDIR=$HOME/misoc" >> $HOME/.m-labs/build_settings.sh diff --git a/.travis/get-xilinx.sh b/.travis/get-xilinx.sh index 3d49fd693..61eaf091a 100755 --- a/.travis/get-xilinx.sh +++ b/.travis/get-xilinx.sh @@ -26,13 +26,13 @@ echo "$secret" | gpg --passphrase-fd 0 Xilinx.lic.gpg mkdir -p ~/.Xilinx mv Xilinx.lic ~/.Xilinx/Xilinx.lic -git clone https://github.com/fallen/impersonate_macaddress +git clone https://github.com/m-labs/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/.m-labs/build_settings.sh << EOF -MISOC_EXTRA_VIVADO_CMDLINE="-Ob vivado_path $HOME/Xilinx/Vivado" -MISOC_EXTRA_ISE_CMDLINE="-Ob ise_path $HOME/opt/Xilinx/" +MISOC_EXTRA_ISE_CMDLINE="--gateware-toolchain-path $HOME/opt/Xilinx/" +MISOC_EXTRA_VIVADO_CMDLINE="--gateware-toolchain-path $HOME/Xilinx/Vivado" export MACADDR=$macaddress export LD_PRELOAD=$PWD/impersonate_macaddress/impersonate_macaddress.so EOF diff --git a/conda/artiq-kc705-nist_qc1/build.sh b/conda/artiq-kc705-nist_qc1/build.sh index 495a0e74c..03bcadd9a 100644 --- a/conda/artiq-kc705-nist_qc1/build.sh +++ b/conda/artiq-kc705-nist_qc1/build.sh @@ -3,24 +3,13 @@ BUILD_SETTINGS_FILE=$HOME/.m-labs/build_settings.sh [ -f $BUILD_SETTINGS_FILE ] && . $BUILD_SETTINGS_FILE -SOC_PREFIX=$PREFIX/lib/python3.5/site-packages/artiq/binaries/kc705 -mkdir -p $SOC_PREFIX/nist_qc1 +SOC_PREFIX=$PREFIX/lib/python3.5/site-packages/artiq/binaries/kc705-qc1 +mkdir -p $SOC_PREFIX -SOC_ROOT=$PWD/soc +$PYTHON -m artiq.gateware.targets.kc705 -H qc1 $MISOC_EXTRA_ISE_CMDLINE +cp misoc_nist_qc1_kc705/gateware/top.bit $SOC_PREFIX +cp misoc_nist_qc1_kc705/software/bios/bios.bin $SOC_PREFIX +cp misoc_nist_qc1_kc705/software/runtime/runtime.fbi $SOC_PREFIX -# build bitstream - -(cd $MSCDIR; $PYTHON make.py -X $SOC_ROOT -t artiq_kc705 $MISOC_EXTRA_VIVADO_CMDLINE build-bitstream) -cp $MSCDIR/build/artiq_kc705-nist_qc1-kc705.bit $SOC_PREFIX/ wget http://sionneau.net/artiq/binaries/kc705/flash_proxy/bscan_spi_kc705.bit -mv bscan_spi_kc705.bit $SOC_PREFIX/ - -# build BIOS - -(cd $MSCDIR; $PYTHON make.py -X $SOC_ROOT -t artiq_kc705 build-headers build-bios) -cp $MSCDIR/software/bios/bios.bin $SOC_PREFIX/ - -# build runtime - -make -C soc/runtime clean runtime.fbi -cp soc/runtime/runtime.fbi $SOC_PREFIX/nist_qc1/ +mv bscan_spi_kc705.bit $SOC_PREFIX diff --git a/conda/artiq-kc705-nist_qc1/meta.yaml b/conda/artiq-kc705-nist_qc1/meta.yaml index 765cb2c96..7a18496af 100644 --- a/conda/artiq-kc705-nist_qc1/meta.yaml +++ b/conda/artiq-kc705-nist_qc1/meta.yaml @@ -16,6 +16,7 @@ requirements: # We don't get meaningful GIT_DESCRIBE_* values until before conda installs build dependencies. - artiq 0.0 - migen 0.0 + - misoc 0.0 - llvm-or1k - binutils-or1k-linux run: diff --git a/conda/artiq-kc705-nist_qc2/build.sh b/conda/artiq-kc705-nist_qc2/build.sh index a65294b85..38cac5ab7 100644 --- a/conda/artiq-kc705-nist_qc2/build.sh +++ b/conda/artiq-kc705-nist_qc2/build.sh @@ -3,24 +3,13 @@ BUILD_SETTINGS_FILE=$HOME/.m-labs/build_settings.sh [ -f $BUILD_SETTINGS_FILE ] && . $BUILD_SETTINGS_FILE -SOC_PREFIX=$PREFIX/lib/python3.5/site-packages/artiq/binaries/kc705 -mkdir -p $SOC_PREFIX/nist_qc2 +SOC_PREFIX=$PREFIX/lib/python3.5/site-packages/artiq/binaries/kc705-qc2 +mkdir -p $SOC_PREFIX -SOC_ROOT=$PWD/soc +$PYTHON -m artiq.gateware.targets.kc705 -H qc2 $MISOC_EXTRA_ISE_CMDLINE +cp misoc_nist_qc2_kc705/gateware/top.bit $SOC_PREFIX +cp misoc_nist_qc2_kc705/software/bios/bios.bin $SOC_PREFIX +cp misoc_nist_qc2_kc705/software/runtime/runtime.fbi $SOC_PREFIX -# build bitstream - -(cd $MSCDIR; $PYTHON make.py -X $SOC_ROOT -t artiq_kc705 -s NIST_QC2 $MISOC_EXTRA_VIVADO_CMDLINE build-bitstream) -cp $MSCDIR/build/artiq_kc705-nist_qc2-kc705.bit $SOC_PREFIX/ wget http://sionneau.net/artiq/binaries/kc705/flash_proxy/bscan_spi_kc705.bit -mv bscan_spi_kc705.bit $SOC_PREFIX/ - -# build BIOS - -(cd $MSCDIR; $PYTHON make.py -X $SOC_ROOT -t artiq_kc705 -s NIST_QC2 build-headers build-bios) -cp $MSCDIR/software/bios/bios.bin $SOC_PREFIX/ - -# build runtime - -make -C soc/runtime clean runtime.fbi -cp soc/runtime/runtime.fbi $SOC_PREFIX/nist_qc2/ +mv bscan_spi_kc705.bit $SOC_PREFIX diff --git a/conda/artiq-kc705-nist_qc2/meta.yaml b/conda/artiq-kc705-nist_qc2/meta.yaml index 166163a1c..9be8b6c69 100644 --- a/conda/artiq-kc705-nist_qc2/meta.yaml +++ b/conda/artiq-kc705-nist_qc2/meta.yaml @@ -16,6 +16,7 @@ requirements: # We don't get meaningful GIT_DESCRIBE_* values until before conda installs build dependencies. - artiq 0.0 - migen 0.0 + - misoc 0.0 - llvm-or1k - binutils-or1k-linux run: diff --git a/conda/artiq-pipistrello-nist_qc1/build.sh b/conda/artiq-pipistrello-nist_qc1/build.sh index f35b22a39..d7f5690c2 100644 --- a/conda/artiq-pipistrello-nist_qc1/build.sh +++ b/conda/artiq-pipistrello-nist_qc1/build.sh @@ -3,24 +3,13 @@ BUILD_SETTINGS_FILE=$HOME/.m-labs/build_settings.sh [ -f $BUILD_SETTINGS_FILE ] && . $BUILD_SETTINGS_FILE -SOC_PREFIX=$PREFIX/lib/python3.5/site-packages/artiq/binaries/pipistrello +SOC_PREFIX=$PREFIX/lib/python3.5/site-packages/artiq/binaries/pipistrello-qc1 mkdir -p $SOC_PREFIX -SOC_ROOT=$PWD/soc +$PYTHON -m artiq.gateware.targets.pipistrello $MISOC_EXTRA_ISE_CMDLINE +cp misoc_nist_qc1_pipistrello/gateware/top.bit $SOC_PREFIX +cp misoc_nist_qc1_pipistrello/software/bios/bios.bin $SOC_PREFIX +cp misoc_nist_qc1_pipistrello/software/runtime/runtime.fbi $SOC_PREFIX -# build bitstream - -(cd $MSCDIR; $PYTHON make.py -X $SOC_ROOT -t artiq_pipistrello $MISOC_EXTRA_ISE_CMDLINE build-bitstream) -cp $MSCDIR/build/artiq_pipistrello-nist_qc1-pipistrello.bit $SOC_PREFIX/ wget https://people.phys.ethz.ch/~robertjo/bscan_spi_lx45_csg324.bit -mv bscan_spi_lx45_csg324.bit $SOC_PREFIX/ - -# build BIOS - -(cd $MSCDIR; $PYTHON make.py -X $SOC_ROOT -t artiq_pipistrello build-headers build-bios) -cp $MSCDIR/software/bios/bios.bin $SOC_PREFIX/ - -# build runtime - -make -C soc/runtime clean runtime.fbi -cp soc/runtime/runtime.fbi $SOC_PREFIX/ +mv bscan_spi_lx45_csg324.bit $SOC_PREFIX diff --git a/conda/artiq-pipistrello-nist_qc1/meta.yaml b/conda/artiq-pipistrello-nist_qc1/meta.yaml index 11a62058a..a62e942fa 100644 --- a/conda/artiq-pipistrello-nist_qc1/meta.yaml +++ b/conda/artiq-pipistrello-nist_qc1/meta.yaml @@ -16,6 +16,7 @@ requirements: # We don't get meaningful GIT_DESCRIBE_* values until before conda installs build dependencies. - artiq 0.0 - migen 0.0 + - misoc 0.0 - llvm-or1k - binutils-or1k-linux run: From 4d0f500301c14ac5691e0a78746f6ca7b1333807 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Wed, 4 Nov 2015 16:49:35 +0800 Subject: [PATCH 12/20] conda: update migen/misoc dependencies --- conda/artiq-kc705-nist_qc1/meta.yaml | 4 ++-- conda/artiq-kc705-nist_qc2/meta.yaml | 4 ++-- conda/artiq-pipistrello-nist_qc1/meta.yaml | 4 ++-- conda/artiq/meta.yaml | 1 - 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/conda/artiq-kc705-nist_qc1/meta.yaml b/conda/artiq-kc705-nist_qc1/meta.yaml index 7a18496af..19a100199 100644 --- a/conda/artiq-kc705-nist_qc1/meta.yaml +++ b/conda/artiq-kc705-nist_qc1/meta.yaml @@ -15,8 +15,8 @@ requirements: build: # We don't get meaningful GIT_DESCRIBE_* values until before conda installs build dependencies. - artiq 0.0 - - migen 0.0 - - misoc 0.0 + - migen 0.2 + - misoc 0.1 - llvm-or1k - binutils-or1k-linux run: diff --git a/conda/artiq-kc705-nist_qc2/meta.yaml b/conda/artiq-kc705-nist_qc2/meta.yaml index 9be8b6c69..469a86665 100644 --- a/conda/artiq-kc705-nist_qc2/meta.yaml +++ b/conda/artiq-kc705-nist_qc2/meta.yaml @@ -15,8 +15,8 @@ requirements: build: # We don't get meaningful GIT_DESCRIBE_* values until before conda installs build dependencies. - artiq 0.0 - - migen 0.0 - - misoc 0.0 + - migen 0.2 + - misoc 0.1 - llvm-or1k - binutils-or1k-linux run: diff --git a/conda/artiq-pipistrello-nist_qc1/meta.yaml b/conda/artiq-pipistrello-nist_qc1/meta.yaml index a62e942fa..aa9fc6e4c 100644 --- a/conda/artiq-pipistrello-nist_qc1/meta.yaml +++ b/conda/artiq-pipistrello-nist_qc1/meta.yaml @@ -15,8 +15,8 @@ requirements: build: # We don't get meaningful GIT_DESCRIBE_* values until before conda installs build dependencies. - artiq 0.0 - - migen 0.0 - - misoc 0.0 + - migen 0.2 + - misoc 0.1 - llvm-or1k - binutils-or1k-linux run: diff --git a/conda/artiq/meta.yaml b/conda/artiq/meta.yaml index 9fa02839d..d76f4d4e3 100644 --- a/conda/artiq/meta.yaml +++ b/conda/artiq/meta.yaml @@ -33,7 +33,6 @@ requirements: - python >=3.5.0 - setuptools - numpy - - migen 0.0 - pyelftools - binutils-or1k-linux run: From c1c3abc1de30e0220445c7d49ecc0ee90c91d591 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Wed, 4 Nov 2015 17:10:10 +0800 Subject: [PATCH 13/20] examples/device_db: add comment about KC705/QC1 --- examples/master/device_db.pyon | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/master/device_db.pyon b/examples/master/device_db.pyon index f1502abb4..c1fd359f5 100644 --- a/examples/master/device_db.pyon +++ b/examples/master/device_db.pyon @@ -1,3 +1,6 @@ +# This is an example device database that needs to be adapted to your setup. +# The RTIO channel numbers here are for NIST QC1 on KC705. + { "comm": { "type": "local", From d06a4d60a8a698917934e278e01b2599535397ab Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Wed, 4 Nov 2015 18:00:31 +0800 Subject: [PATCH 14/20] travis/get-xilinx: use http github clone url --- .travis/get-xilinx.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis/get-xilinx.sh b/.travis/get-xilinx.sh index 61eaf091a..960a7671f 100755 --- a/.travis/get-xilinx.sh +++ b/.travis/get-xilinx.sh @@ -26,7 +26,7 @@ echo "$secret" | gpg --passphrase-fd 0 Xilinx.lic.gpg mkdir -p ~/.Xilinx mv Xilinx.lic ~/.Xilinx/Xilinx.lic -git clone https://github.com/m-labs/impersonate_macaddress +git clone http://github.com/m-labs/impersonate_macaddress make -C impersonate_macaddress # Tell mibuild where Xilinx toolchains are installed # and feed it the mac address corresponding to the license From 56281c1a5c375f0631aa7102bed0b4b4be90f43e Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Wed, 4 Nov 2015 18:03:50 +0800 Subject: [PATCH 15/20] Revert "travis/get-xilinx: use http github clone url" This reverts commit d06a4d60a8a698917934e278e01b2599535397ab. --- .travis/get-xilinx.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis/get-xilinx.sh b/.travis/get-xilinx.sh index 960a7671f..61eaf091a 100755 --- a/.travis/get-xilinx.sh +++ b/.travis/get-xilinx.sh @@ -26,7 +26,7 @@ echo "$secret" | gpg --passphrase-fd 0 Xilinx.lic.gpg mkdir -p ~/.Xilinx mv Xilinx.lic ~/.Xilinx/Xilinx.lic -git clone http://github.com/m-labs/impersonate_macaddress +git clone https://github.com/m-labs/impersonate_macaddress make -C impersonate_macaddress # Tell mibuild where Xilinx toolchains are installed # and feed it the mac address corresponding to the license From d4747a85f3e59feb63f4decc66c51deab8e0204f Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Wed, 4 Nov 2015 18:36:34 +0800 Subject: [PATCH 16/20] conda: use vivado for kc705 builds --- conda/artiq-kc705-nist_qc1/build.sh | 2 +- conda/artiq-kc705-nist_qc2/build.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/conda/artiq-kc705-nist_qc1/build.sh b/conda/artiq-kc705-nist_qc1/build.sh index 03bcadd9a..c0f1c9de9 100644 --- a/conda/artiq-kc705-nist_qc1/build.sh +++ b/conda/artiq-kc705-nist_qc1/build.sh @@ -6,7 +6,7 @@ BUILD_SETTINGS_FILE=$HOME/.m-labs/build_settings.sh SOC_PREFIX=$PREFIX/lib/python3.5/site-packages/artiq/binaries/kc705-qc1 mkdir -p $SOC_PREFIX -$PYTHON -m artiq.gateware.targets.kc705 -H qc1 $MISOC_EXTRA_ISE_CMDLINE +$PYTHON -m artiq.gateware.targets.kc705 -H qc1 --toolchain vivado $MISOC_EXTRA_VIVADO_CMDLINE cp misoc_nist_qc1_kc705/gateware/top.bit $SOC_PREFIX cp misoc_nist_qc1_kc705/software/bios/bios.bin $SOC_PREFIX cp misoc_nist_qc1_kc705/software/runtime/runtime.fbi $SOC_PREFIX diff --git a/conda/artiq-kc705-nist_qc2/build.sh b/conda/artiq-kc705-nist_qc2/build.sh index 38cac5ab7..c9094cc96 100644 --- a/conda/artiq-kc705-nist_qc2/build.sh +++ b/conda/artiq-kc705-nist_qc2/build.sh @@ -6,7 +6,7 @@ BUILD_SETTINGS_FILE=$HOME/.m-labs/build_settings.sh SOC_PREFIX=$PREFIX/lib/python3.5/site-packages/artiq/binaries/kc705-qc2 mkdir -p $SOC_PREFIX -$PYTHON -m artiq.gateware.targets.kc705 -H qc2 $MISOC_EXTRA_ISE_CMDLINE +$PYTHON -m artiq.gateware.targets.kc705 -H qc2 --toolchain vivado $MISOC_EXTRA_VIVADO_CMDLINE cp misoc_nist_qc2_kc705/gateware/top.bit $SOC_PREFIX cp misoc_nist_qc2_kc705/software/bios/bios.bin $SOC_PREFIX cp misoc_nist_qc2_kc705/software/runtime/runtime.fbi $SOC_PREFIX From ad5a32fb6ea0066601ba0cfde1ae045dd1cab488 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Wed, 4 Nov 2015 20:09:37 +0800 Subject: [PATCH 17/20] targets/kc705: remove unneeded argument on qc2 --- artiq/gateware/targets/kc705.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/artiq/gateware/targets/kc705.py b/artiq/gateware/targets/kc705.py index 66ba7b3f8..38228e136 100755 --- a/artiq/gateware/targets/kc705.py +++ b/artiq/gateware/targets/kc705.py @@ -182,8 +182,8 @@ class NIST_QC1(_NIST_QCx): class NIST_QC2(_NIST_QCx): - def __init__(self, platform, cpu_type="or1k", **kwargs): - _NIST_QCx.__init__(self, platform, cpu_type, **kwargs) + def __init__(self, cpu_type="or1k", **kwargs): + _NIST_QCx.__init__(self, cpu_type, **kwargs) platform = self.platform platform.add_extension(nist_qc2.fmc_adapter_io) From b13ee2ed8fd478611941593102223bd4f8cfdd98 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Wed, 4 Nov 2015 23:38:24 +0800 Subject: [PATCH 18/20] doc: update compilation instructions --- doc/manual/installing.rst | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/doc/manual/installing.rst b/doc/manual/installing.rst index 3a24d6dc6..788dc7870 100644 --- a/doc/manual/installing.rst +++ b/doc/manual/installing.rst @@ -220,16 +220,18 @@ These steps are required to generate bitstream (``.bit``) files, build the MiSoC Then copy the generated ``bscan_spi_kc705.bit`` to ``~/.migen``, ``/usr/local/share/migen`` or ``/usr/share/migen``. -* Download MiSoC: :: +* Download and install MiSoC: :: $ cd ~/artiq-dev $ git clone --recursive https://github.com/m-labs/misoc - $ export MSCDIR=~/artiq-dev/misoc # append this line to .bashrc + $ cd misoc + $ python3 setup.py develop --user * Download and install ARTIQ: :: $ cd ~/artiq-dev $ git clone --recursive https://github.com/m-labs/artiq + $ cd artiq $ python3 setup.py develop --user .. note:: @@ -238,26 +240,30 @@ These steps are required to generate bitstream (``.bit``) files, build the MiSoC :ref:`installing the host-side software `. -* Build and flash the bitstream and BIOS by running `from the MiSoC top-level directory`: +* Build the bitstream, BIOS and runtime by running: :: - $ cd ~/artiq-dev/misoc + $ cd ~/artiq-dev $ export PATH=/usr/local/llvm-or1k/bin:$PATH .. note:: Make sure that ``/usr/local/llvm-or1k/bin`` is first in your ``PATH``, so that the ``clang`` command you just built is found instead of the system one, if any. * For Pipistrello:: - $ ./make.py -X ~/artiq-dev/artiq/soc -t artiq_pipistrello all + $ python3 -m artiq.gateware.targets.pipistrello * For KC705:: - $ ./make.py -X ~/artiq-dev/artiq/soc -t artiq_kc705 all + $ python3 -m artiq.gateware.targets.kc705 -H qc1 # or qc2 -* Then, build and flash the ARTIQ runtime: :: +* Then, gather the binaries and flash them: :: - $ cd ~/artiq-dev/artiq/soc/runtime && make runtime.fbi - $ ~/artiq-dev/artiq/artiq/frontend/artiq_flash.sh -t pipistrello -d $PWD -r + $ mkdir binaries + $ cp misoc_nist_qcX_/gateware/top.bit binaries + $ cp misoc_nist_qcX_/software/bios/bios.bin binaries + $ cp misoc_nist_qcX_/software/runtime/runtime.fbi binaries + $ cd binaries + $ artiq_flash.sh -d . -t .. note:: The `-t` option specifies the board your are targeting. Available options are ``kc705`` and ``pipistrello``. From 976e13639ee3f21d0ec28ae63fbc56690740b9f3 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Wed, 4 Nov 2015 23:38:51 +0800 Subject: [PATCH 19/20] travis/get-*: fail build earlier on problems --- .travis/get-anaconda.sh | 2 ++ .travis/get-toolchain.sh | 2 ++ .travis/get-xilinx.sh | 2 ++ 3 files changed, 6 insertions(+) diff --git a/.travis/get-anaconda.sh b/.travis/get-anaconda.sh index 69f107dce..383cdaa00 100755 --- a/.travis/get-anaconda.sh +++ b/.travis/get-anaconda.sh @@ -1,6 +1,8 @@ #!/bin/sh # Copyright (C) 2014, 2015 Robert Jordens +set -e + export PATH=$HOME/miniconda/bin:$PATH wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh bash miniconda.sh -b -p $HOME/miniconda diff --git a/.travis/get-toolchain.sh b/.travis/get-toolchain.sh index 6dd5f94ff..e7a61a91d 100755 --- a/.travis/get-toolchain.sh +++ b/.travis/get-toolchain.sh @@ -1,5 +1,7 @@ #!/bin/sh +set -e + packages="http://us.archive.ubuntu.com/ubuntu/pool/universe/i/iverilog/iverilog_0.9.7-1_amd64.deb" mkdir -p packages diff --git a/.travis/get-xilinx.sh b/.travis/get-xilinx.sh index 61eaf091a..8ea50d25e 100755 --- a/.travis/get-xilinx.sh +++ b/.travis/get-xilinx.sh @@ -2,6 +2,8 @@ # Copyright (C) 2014, 2015 M-Labs Limited # Copyright (C) 2014, 2015 Robert Jordens +set -e + wget http://sionneau.net/artiq/Xilinx/xilinx_ise_14.7_s3_s6.tar.gz.gpg echo "$secret" | gpg --passphrase-fd 0 xilinx_ise_14.7_s3_s6.tar.gz.gpg tar -C $HOME/ -xzf xilinx_ise_14.7_s3_s6.tar.gz From a7c9c950857544930efdc8c358d281a738b295ec Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Thu, 5 Nov 2015 19:04:10 +0800 Subject: [PATCH 20/20] gui/explorer: support requesting termination of all instances --- artiq/frontend/artiq_gui.py | 1 + artiq/gui/explorer.py | 38 +++++++++++++++++++++++++++++++++++-- artiq/gui/schedule.py | 8 +++++++- 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/artiq/frontend/artiq_gui.py b/artiq/frontend/artiq_gui.py index fd18f715c..d3f5f7d11 100755 --- a/artiq/frontend/artiq_gui.py +++ b/artiq/frontend/artiq_gui.py @@ -116,6 +116,7 @@ def main(): loop.run_until_complete(d_schedule.sub_connect( args.server, args.port_notify)) atexit.register(lambda: loop.run_until_complete(d_schedule.sub_close())) + d_explorer.get_current_schedule = d_schedule.get_current_schedule d_log = LogDock() smgr.register(d_log) diff --git a/artiq/gui/explorer.py b/artiq/gui/explorer.py index 90b9ac4ce..a885a15df 100644 --- a/artiq/gui/explorer.py +++ b/artiq/gui/explorer.py @@ -263,8 +263,7 @@ class ExplorerDock(dockarea.Dock): grid.addWidget(self.log_level, 3, 3) submit = QtGui.QPushButton("Submit") - submit.setShortcut("CTRL+RETURN") - submit.setToolTip("Schedule the selected experiment (CTRL+ENTER)") + submit.setToolTip("Schedule the selected experiment (Ctrl+Return)") grid.addWidget(submit, 4, 0, colspan=4) submit.clicked.connect(self.submit_clicked) @@ -276,6 +275,19 @@ class ExplorerDock(dockarea.Dock): self.shortcuts = ShortcutManager(self.main_window, self) self.el.setContextMenuPolicy(QtCore.Qt.ActionsContextMenu) + submit_action = QtGui.QAction("Submit", self.el) + submit_action.triggered.connect(self.submit_clicked) + submit_action.setShortcut("CTRL+RETURN") + self.el.addAction(submit_action) + reqterm_action = QtGui.QAction("Request termination of instances", self.el) + reqterm_action.triggered.connect(self.request_inst_term) + reqterm_action.setShortcut("CTRL+BACKSPACE") + self.el.addAction(reqterm_action) + + sep = QtGui.QAction(self.el) + sep.setSeparator(True) + self.el.addAction(sep) + edit_shortcuts_action = QtGui.QAction("Edit shortcuts", self.el) edit_shortcuts_action.triggered.connect(self.edit_shortcuts) self.el.addAction(edit_shortcuts_action) @@ -392,6 +404,28 @@ class ExplorerDock(dockarea.Dock): due_date, self.flush.isChecked()) + async def request_term_multiple(self, rids): + for rid in rids: + try: + await self.schedule_ctl.request_termination(rid) + except: + pass + + def request_inst_term(self): + if self.selected_key is not None: + expinfo = self.explist_model.backing_store[self.selected_key] + # attribute get_current_schedule must be set externally after + # instance creation + current_schedule = self.get_current_schedule() + rids = [] + for rid, desc in current_schedule.items(): + expid = desc["expid"] + if ("repo_rev" in expid # only consider runs from repository + and expid["file"] == expinfo["file"] + and expid["class_name"] == expinfo["class_name"]): + rids.append(rid) + asyncio.ensure_future(self.request_term_multiple(rids)) + def edit_shortcuts(self): experiments = sorted(self.explist_model.backing_store.keys()) self.shortcuts.edit(experiments) diff --git a/artiq/gui/schedule.py b/artiq/gui/schedule.py index 42ae01a1d..9971cd703 100644 --- a/artiq/gui/schedule.py +++ b/artiq/gui/schedule.py @@ -82,7 +82,6 @@ class ScheduleDock(dockarea.Dock): delete_action.setShortcut("SHIFT+DELETE") self.table.addAction(delete_action) - async def sub_connect(self, host, port): self.subscriber = Subscriber("schedule", self.init_schedule_model) await self.subscriber.connect(host, port) @@ -90,6 +89,13 @@ class ScheduleDock(dockarea.Dock): async def sub_close(self): await self.subscriber.close() + def get_current_schedule(self): + try: + table_model = self.table_model + except AttributeError: + return dict() + return table_model.backing_store + def init_schedule_model(self, init): self.table_model = _ScheduleModel(self.table, init) self.table.setModel(self.table_model)