博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
PCI Express(六) - Simple transactions
阅读量:6767 次
发布时间:2019-06-26

本文共 2467 字,大约阅读时间需要 8 分钟。

原文地址:http://www.fpga4fun.com/PCI-Express6.html

 

Let's try to control LEDs from the PCI Express bus.

Xilinx's "Endpoint Block Plus" core allows us to work at the transaction layer level, so it's just going to take us a few lines of code.

Instead of providing data on a 32-bit bus, "Endpoint Block Plus" uses a 64-bit bus (so we get twice as much data at each clock cycle). That's not a problem and a simple state-machine will handle simple memory reads & writes.

// we use signals from Xilinx's "Endpoint Block Plus"// first we declare that we are always ready to get dataassign trn_rdst_rdy_n = 1'b0;// then we create a state machine that triggers when we get a PCI Express memory read or writereg RXstate;reg [63:0] RXrd;always @(posedge clk)case(RXstate)    // we are going to handle simple memory reads & writes    // we know that with the "Endpoint Block Plus" core, such simple transactions always happens     //  using two cycles so we just need a two-states state machine    // first, we wait for the beginning of a memory transaction with up to 32-bit data (i.e. with length=1)    1'b0: if(~trn_rsrc_rdy_n && ~trn_rsof_n && trn_rd[61:56]==6'b0_00000 && trn_rd[41:32]==10'h001)    begin         RXstate <= 1'b1;        RXrd <= trn_rd;    end    // then the second state waits for the end of the transaction    1'b1: if(~trn_rsrc_rdy_n) RXstate <= 1'b0;endcase

Now we are ready to update the LEDs.

wire [31:0] RXaddr = trn_rd[63:32];   // memory address (read or write) (valid during the second state of the state machine)wire [31:0] RXdata = trn_rd[31:0];   // memory data (for a write) (valid during the second state of the state machine)wire RXrdwr = RXrd[62];  // 0 for a read, 1 for a writewire RXRead = ~trn_rsrc_rdy_n & RXstate & ~RXrdwr;    // true when a read is happeningwire RXwrite = ~trn_rsrc_rdy_n & RXstate & RXrdwr;    // true when a write is happening// update two LEDs using the two LSBs from the data writtenreg [1:0] LEDs;always @(posedge clk) if(RXwrite) LEDs <= RXdata[1:0];

For a memory write, that's all there is to it. For a memory read, you need to create a response packet with the data to return. Generating an interrupt is also very easy - just assert a signal called "cfg_interrupt_n".

Want more? Check Dragon-E's startup-kit for a more complete example, and Xilinx's  specification documentation for a description of all the signals.

posted on
2016-08-21 17:05 阅读(
...) 评论(
...)

转载于:https://www.cnblogs.com/christsong/p/5721660.html

你可能感兴趣的文章
我的人生
查看>>
OSI七层模型
查看>>
Linux中的变量
查看>>
全新Linux+Python高端运维班第二次作业
查看>>
一步一步找出网站速度慢的原因
查看>>
操作系统之文件系统
查看>>
VMware vSAN Part 1 之硬件配置信息
查看>>
金山快盘
查看>>
HTML5 入门资料
查看>>
PingingLab传世经典系列《CCNA完全配置宝典》-1.9 IOS恢复
查看>>
我的友情链接
查看>>
ab,webbench,Siege,http_load,Web Application Stress
查看>>
返回Json数据浏览器带上<pre></pre>标签解决方法
查看>>
基于HTTP协议的轻量级开源简单队列服务:HTTPSQS[原创]
查看>>
Nginx 编译扩展pcre
查看>>
栈相关操作[1]
查看>>
【Spark亚太研究院系列丛书】Spark实战高手之路-第一章 构建Spark集群(第四步)(4)...
查看>>
64位win 8系统装64位oracle遇到的sqlplus和sqldeveloper乱码解决
查看>>
linux awk命令详解一
查看>>
Redis 新特性---pipeline(管道)
查看>>