Rework connection interface
* As discussed on 2020-04-07 after the Softie's meeting (ECM, YS, PSP, CM, OJB), we want to have a streamlined connection interfaces for all the possible ways we turn FPGA words into other FPGA words in hardware. * C++-API: Split old Connection objects into two parts: * The connection object that the user can only create and destroy but which holds state necessary for communication with the backend (hw, CoSim, QuiggelyClient, etc) and allows some state to be set. * Introduce hxcomm/common/stream.h: * The Stream-object featuring a uniform interface handling how to feed and read words to/from the backend. * The interface is defined via templated `Stream`-class that has to be befriended in the corresponding connection implementations * The Stream-interface is verified at compile time via the Streamable helper-struct. * Move `execute_words` from fisch as more generic `execute_messages`-function that is the entry point for all upper layers when communcating with backends. * Overloading is possible by fully or partially-specializing the detail::ExecutorMessages-helper struct's operator() method (not needed once partial function specialization arrives, so never) * default implementation in common namespace by adding explicit `send_halt_message_type` to ConnectionParameter template argument * Rework hxcomm/common/{arq,sim}connection.{h,tcc} to use the new Stream interface. * Update all tests to use streams for interacting with the hardware. * Rename init_parameters_t -> init_parameters_type to be consistent (they will be used by quiggeldy but that change is not merged -> no API break) * Provide get_connection_from_env-function that returns a connection variant over all possible connections (and is used in pyhxcomm, see below). * Introduce seperate `pyhxcomm`-namespace that is private to hxcomm and only to be accessed from Python. It adds convenience context-wrappers for connections ensuring connections get closed upon exiting contexts in Python * pyhxcomm::Managed<Connection> provides enter/exit-methods * enter() returns pyhxcom::Handle<Connection> holding the connection * if Handle<Connection> gets destroyed, connection gets freed (i.e. disconnected) * Managed<Connection> also holds a weak-ptr to the returned ConnectionHandle object and disconnects the Handle upon exit()-ing * Expose union over all Connections as `pyhxcomm_vx.ConnectionHandle` that can be used in type annotations in Python. * Expose special context manager `pyhxcomm_vx.ManagedConnection` that automatically creates a new connection from the environment and returns `ConnectionHandle` (which is a concrete `<Connection>Handle` in python rather than the cumbersome variant type). * Introduce hxcomm::visit_connection that allows for applying operations on connections wrapped in Handle-objects such as variants for hxcomm and pyhxcomm::ConnectionHandles. It is used in hxcomm::execute_messages as well as stadls::run-pybind11 bindings. * Functions templated over connections can be easily specialized for all wrapped connections via: * `ConnectionIsPlainGuard<Connection> = 0` * `ConnectionIsWrappedGuard<Connection> = 0` * Another possibility is to perform compile time checks using `ConnectionIsPlain<Connection>::value` (see `run`-implementation in haldls for example). * Add `static char const name[]` attributes for all connection for more informative logging. Depends-On: 10346,10335,10703,10978,11027 Change-Id: I3ff901db53a5cb94a1faa50b18dc36786246f389
Showing
- example/hxcomm_arq.cpp 3 additions, 1 deletionexample/hxcomm_arq.cpp
- example/hxcomm_sim.cpp 3 additions, 1 deletionexample/hxcomm_sim.cpp
- example/reset_and_id_readout.h 24 additions, 26 deletionsexample/reset_and_id_readout.h
- include/hxcomm/common/arqconnection.h 10 additions, 13 deletionsinclude/hxcomm/common/arqconnection.h
- include/hxcomm/common/connection.h 68 additions, 0 deletionsinclude/hxcomm/common/connection.h
- include/hxcomm/common/connection_parameter.h 3 additions, 0 deletionsinclude/hxcomm/common/connection_parameter.h
- include/hxcomm/common/connection_variant.h 17 additions, 0 deletionsinclude/hxcomm/common/connection_variant.h
- include/hxcomm/common/execute_messages.h 90 additions, 0 deletionsinclude/hxcomm/common/execute_messages.h
- include/hxcomm/common/logger.h 1 addition, 0 deletionsinclude/hxcomm/common/logger.h
- include/hxcomm/common/simconnection.h 38 additions, 31 deletionsinclude/hxcomm/common/simconnection.h
- include/hxcomm/common/simconnection.tcc 5 additions, 4 deletionsinclude/hxcomm/common/simconnection.tcc
- include/hxcomm/common/stream.h 173 additions, 0 deletionsinclude/hxcomm/common/stream.h
- include/hxcomm/common/visit_connection.h 109 additions, 0 deletionsinclude/hxcomm/common/visit_connection.h
- include/hxcomm/vx/arqconnection.h 2 additions, 4 deletionsinclude/hxcomm/vx/arqconnection.h
- include/hxcomm/vx/connection_from_env.h 23 additions, 0 deletionsinclude/hxcomm/vx/connection_from_env.h
- include/hxcomm/vx/connection_from_env.tcc 39 additions, 0 deletionsinclude/hxcomm/vx/connection_from_env.tcc
- include/hxcomm/vx/connection_parameter.h 1 addition, 0 deletionsinclude/hxcomm/vx/connection_parameter.h
- include/hxcomm/vx/connection_variant.h 11 additions, 0 deletionsinclude/hxcomm/vx/connection_variant.h
- include/hxcomm/vx/simconnection.h 1 addition, 4 deletionsinclude/hxcomm/vx/simconnection.h
- pyhxcomm/include/pyhxcomm/common/connection_handle.h 18 additions, 0 deletionspyhxcomm/include/pyhxcomm/common/connection_handle.h
Please register or sign in to comment