PCI Express(六) - Simple transactions

原文地址: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 = 1‘b0;

// then we create a state machine that triggers when we get a PCI Express memory read or write
reg 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 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 [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 Endpoint Block Plus specification documentation for a description of all the signals.

时间: 2024-10-11 02:40:32

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

PCI Express(四) - The transaction layer

原文出处:http://www.fpga4fun.com/PCI-Express4.html 感觉没什么好翻译的,都比较简单,主要讲了TLP的帧结构 In the transaction layer, we receive "packets". There is a 32-bits bus and the packets arrive on the bus (packet lengths are always multiples of 32-bits). Maybe one packe

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

原文出处:http://www.fpga4fun.com/PCI-Express3.html Packetized transactions PCI express is a serial bus. Or is it? From the computer's perspective, it is a conventional bus where read and write transactions can be achieved. The trick is that all operation

PCI Express(二) - Topology

原文出处:http://www.fpga4fun.com/PCI-Express2.html Point-to-point architecture At 2.5Gbps, the PCI Express Gen1 line speed is a whopping 75 times faster than the 33MHz legacy PCI speed.How is that possible? only because PCI express is a point-to-point bu

PCI Express(一)

在FPGA4FUN上看到一篇介绍PCI-E的帖子,简单易懂,适合入门,特地搬过来 原文地址:http://www.fpga4fun.com/PCI-Express.html 前言: As PCI Express becomes common place in high-end FPGAs, let's see how easy FPGA vendors made the technology available. In particular, we look more closely at Xi

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 sudo lshw -C network ifconfig ping 192.168.1.1 -c 4 tail /var/log/syslog -n 20 2.查看状态: [email protected]:~$ uname -aLinux gofox-To-be-filled-by-O-E-M 3.13.0-

PCI Express(五) - Xilinx wizard

原文地址:http://www.fpga4fun.com/PCI-Express5.html Xilinx makes using PCI express easy - they provide a free PCI Express core (called "Endpoint Block Plus") and a wizard to configure it, all that in their free version of ISE - ISE WebPack. So let's

《PCI EXPRESS体系结构导读》读书笔记之第 1 章 PCI总线的基本知识(3)

PCI总线的中断机制 中断信号与中断控制器的连接关系 中断信号与PCI总线的连接关系 PCI桥规范并没有要求桥片传递其下PCI设备的中断请求.事实上多数PCI桥也没有为下游PCI总线提供中断引脚INTx#,管理其下游的PCI设备. 而同时又说,在PCI EXPRESS中的中断机制,用的是MSI中断机制.所以这种外部中断引脚的中断机制我就暂时不看了. 版权声明:本文为博主原创文章,欢迎垂询 email: [email protected]

PCI Express

1.1课题研究背景 在目前高速发展的计算机平台上,应用软件的开发越来越依赖于硬件平台,尤其是随着大数据.云计算的提出,人们对计算机在各个领域的性能有更高的需求.日常生活中的视频和图像信息包含大量的数据,对此计算机对这些海量信息的实时处理.高效传输和大容量存储都是今后计算机发展的趋势和目标. 总线是由多个部件和设备所共享的,是计算机通信接口的重要技术.为了简化硬件电路设计.简化系统结构,通常用一组线路配置适当的接口电路,与各部件和外围设备连接,这组共用的连接线路称为总线.采用总线结构便于部件和设备

Altera:PCI Express参考设计和应用笔记(链接)

PCI Express参考设计和应用笔记 DB5CGXFC7 Cyclone V Development Board DB5CGXFC7 Cyclone V Development Board Board based on the Altera Cyclone V GX Device providing PCIe and SPF cages for the transceivers, 32 bit width DDR3 memory and a QSPI configuration device