41 #include <boost/python.hpp>
42namespace bp = boost::python;
52rpx::Xvc::Xvc(uint16_t port) :
JtagDriver(port), thread_(nullptr), threadEn_(false), mtu_(1450) {
66void rpx::Xvc::start() {
68 log_->debug(
"Starting the XVC server thread");
72 thread_ =
new std::thread(&rpx::Xvc::runThread,
this);
76void rpx::Xvc::stop() {
78 log_->debug(
"Stopping the XVC server thread");
84 while (!queue_.empty())
auto f = queue_.pop();
98void rpx::Xvc::runThread() {
100 unsigned maxMsg = 32768;
107 s.
run(threadEn_, log_);
113 if (!queue_.busy()) queue_.push(frame);
121uint64_t rpx::Xvc::getMaxVectorSize() {
123 uint64_t mtuLim = (mtu_ - getWordSize()) / 2;
128int rpx::Xvc::xfer(uint8_t* txBuffer,
135 if (!threadEn_)
return (0);
142 log_->debug(
"Tx buffer has %", PRIi32,
" bytes to send\n", txBytes);
145 frame = reqFrame(txBytes,
true);
146 frame->setPayload(txBytes);
152 log_->debug(
"Sending new frame of size %", PRIi32, frame->getSize());
155 if (txBytes) sendFrame(frame);
165 if (!queue_.empty() && (frame = queue_.pop()) !=
nullptr) {
166 log_->debug(
"Receiving new frame of size %", PRIi32, frame->getSize());
171 std::lock_guard<std::mutex> lock(mtx_);
174 iter = frame->begin();
175 if (hdBuffer) std::copy(iter, iter + hdBytes, hdBuffer);
178 if (rxBuffer)
ris::fromFrame(iter += hdBytes, frame->getPayload() - hdBytes, rxBuffer);
184void rpx::Xvc::setup_python() {
187 bp::class_<rpx::Xvc, rpx::XvcPtr, bp::bases<ris::Master, ris::Slave, rpx::JtagDriver>, boost::noncopyable>(
189 bp::init<uint16_t>())
190 .def(
"_start", &rpx::Xvc::start)
191 .def(
"_stop", &rpx::Xvc::stop);
192 bp::implicitly_convertible<rpx::XvcPtr, ris::MasterPtr>();
193 bp::implicitly_convertible<rpx::XvcPtr, ris::SlavePtr>();
194 bp::implicitly_convertible<rpx::XvcPtr, rpx::JtagDriverPtr>();
RAII helper that releases the Python GIL for a scope.
static std::shared_ptr< rogue::Logging > create(const std::string &name, bool quiet=false)
Creates a logger instance.
void setThold(uint32_t thold)
Sets busy-threshold depth used by busy().
Random-access byte iterator across a Frame payload.
Base transport driver for the AxisToJtag firmware protocol.
TCP listener for XVC client connections.
virtual void run(bool &threadEn, rogue::LoggingPtr log)
Runs accept loop while thread enable flag is true.
rogue::Queue< std::shared_ptr< rogue::interfaces::stream::Frame > > queue_
std::shared_ptr< rogue::Logging > log_
static void fromFrame(rogue::interfaces::stream::FrameIterator &iter, uint32_t size, void *dst)
Copies bytes from a frame iterator to a destination pointer.
std::shared_ptr< rogue::interfaces::stream::Frame > FramePtr
Shared pointer alias for Frame.
static void toFrame(rogue::interfaces::stream::FrameIterator &iter, uint32_t size, void *src)
Copies bytes from a source pointer into a frame iterator.
std::shared_ptr< rogue::interfaces::stream::FrameLock > FrameLockPtr
Shared pointer alias for FrameLock.
std::shared_ptr< rogue::protocols::xilinx::Xvc > XvcPtr