本文主要是介绍xdma stream (timeout),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
xdma 回环
vivado 里有官方示例
fpga:pcie rx – axi-stream master – axi-stream slave – pcie tx
流程:电脑启动读取,然后电脑再在超时时间内写入。或者电脑启动写入,然后电脑再在超时时间内读出。只读取或只写入会报超时,所以需要双线程进行
细节:只有电脑启动读取,pcie tx – axi-stream slave 才会使能 ready 信号,然后 pcie rx – axi-stream master 才能向 pcie tx – axi-stream slave 写数据
linux 下 rust 测试 xdma stream 的回环
main.rs:
fn main() {use rand::Rng;use std::fs::OpenOptions;use std::io::{Read, Write};let (read_tx, read_rx) = mpsc::channel();thread::spawn(move || {let mut read = vec![0u8; 100];let mut file = OpenOptions::new().read(true).open("/dev/xdma0_c2h_0").unwrap();file.read(read.as_mut_slice()).unwrap();read_tx.send(read).unwrap();});thread::spawn(move || {let mut data = Vec::new();for _ in 1..=100 {let rng = rand::thread_rng().gen_range(0..=255);data.push(rng);}let mut file = OpenOptions::new().write(true).open("/dev/xdma0_h2c_0").unwrap();file.write(data.as_slice()).unwrap();});let data = read_rx.recv().unwrap();printfln!("xdma: {}", data);
}
Cargo.toml:
[dependencies]
rand = "*"
这篇关于xdma stream (timeout)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!