原文地址: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 data
assign trn_rdst_rdy_n = 'b0; // then we create a state machine that triggers when we get a PCI Express memory read or write
reg RXstate;
reg [:] 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)
'b0: if(~trn_rsrc_rdy_n && ~trn_rsof_n && trn_rd[61:56]==6'b0_00000 && trn_rd[:]=='h001)
begin
RXstate <= 'b1;
RXrd <= trn_rd;
end
// then the second state waits for the end of the transaction
'b1: if(~trn_rsrc_rdy_n) RXstate <= 1'b0;
endcase

Now we are ready to update the LEDs.

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

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 Endpoint Block Plus specification documentation for a description of all the signals.

PCI Express(六) - Simple transactions的更多相关文章

  1. PCI Express(四) - The transaction layer

    原文出处:http://www.fpga4fun.com/PCI-Express4.html 感觉没什么好翻译的,都比较简单,主要讲了TLP的帧结构 In the transaction layer, ...

  2. PCI Express(三) - A story of packets, stack and network

    原文出处:http://www.fpga4fun.com/PCI-Express3.html Packetized transactions PCI express is a serial bus. ...

  3. PCI Express(二) - Topology

    原文出处:http://www.fpga4fun.com/PCI-Express2.html Point-to-point architecture At 2.5Gbps, the PCI Expre ...

  4. PCI Express(一)- Connector

    在FPGA4FUN上看到一篇介绍PCI-E的帖子,简单易懂,适合入门,特地搬过来 原文地址:http://www.fpga4fun.com/PCI-Express.html 前言: As PCI Ex ...

  5. Down to the TLP: How PCI express devices talk (Part II)

    http://xillybus.com/tutorials/pci-express-tlp-pcie-primer-tutorial-guide-2 Data Link Layer Packets A ...

  6. Down to the TLP: How PCI express devices talk (Part I)

    http://xillybus.com/tutorials/pci-express-tlp-pcie-primer-tutorial-guide-1 Down to the TLP: How PCI ...

  7. [中英对照]How PCI Express Works | PCIe工作原理

    How PCI Express Works | PCIe工作原理 PCI Express is a high-speed serial connection that operates more li ...

  8. PCI Express(五) - Xilinx wizard

    原文地址:http://www.fpga4fun.com/PCI-Express5.html Xilinx makes using PCI express easy - they provide a ...

  9. Ubuntu 16.04 RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller” 不能上网

    来源:http://forum.ubuntu.org.cn/viewtopic.php?f=116&t=463646 1.执行如下命令 uname -a sudo lspci -knn sud ...

随机推荐

  1. Codeforces Round #361 Jul.6th A题 ☺译

    A.迈克和手机 当迈克在沙滩上游泳的时候,他意外的把他的手机扔进了水里.不过你甭担心因为他立马买了个便宜些的代替品,这个代替品是老款九键键盘,这个键盘只有十个等大的数字按键,按以下方式排列: 1 2 ...

  2. [Thinking in Java]Nothing but Java

    1 对象(Double Elephants) 1.1 抽象 万物皆对象.什么东西都可以抽象成属性和方法,达到可重用的目的. 对象之间交流靠发送消息.就是通过调用某个特定对象的方法来达到消息传递的目的. ...

  3. iOS NSTimer使用详解 开启、关闭、移除

    定时器定时器详解ios定时器关闭定时器NSTimer 一,要使用一个定时器首先要定义一个定时器: @property (strong, nonatomic) NSTimer *myTimer;//定时 ...

  4. 在Linux操作系统下备份恢复技术的应用 转自https://yq.aliyun.com/articles/50205?spm=5176.100239.blogcont24250.9.CfBYE9

    摘要: 安全防护:在Linux操作系统下备份恢复技术的应用  原文参见:http://linux.chinaunix.net/techdoc/system/2005/12/19/925898.shtm ...

  5. IIS7下使用4.0框架集成模式URLRewriter重写中文URL乱码问题

    解决方法: 1 url中中文先通过Server.UrlEncode编码 2 修改网站编码 3.更改URLRewriter.net中源码 找到RewriterEngine类中 private strin ...

  6. springmvc登陆拦截案例

    一.web.xml <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi=&qu ...

  7. java异常笔记

    1:<java核心技术卷一>473页提到:如果在子类中覆盖了超类的一个方法,子类方法中声明的已检查异常不能超过超类方法中声明的异常范围. 显然,如果子类中抛出的异常范围比超类还大.多态将无 ...

  8. npoi上传xlsx文件,并读取数据

    视图 public PartialViewResult UploadIndex() { return PartialView(); } <div> <fieldset style=& ...

  9. PL/SQLDeveloper导入导出Oracle数据库方法

    前一篇博客介绍了Navicat工具备份Oracle的方法,这篇博客介绍一下使用PL/SQL Developer工具导入导出Oracle数据库的方法. PL/SQL Developer是Oracle数据 ...

  10. oracle and 和 or

    源地址:https://zhidao.baidu.com/question/350891282.html (FirstName='Thomas' OR FirstName='William') AND ...