Based on work by Chris Ballance https://github.com/m-labs/artiq/issues/1167#issuecomment-427188287 #55 Work-in-progress, only gateware part and build system, untested.