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 = '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的更多相关文章
- PCI Express(四) - The transaction layer
原文出处:http://www.fpga4fun.com/PCI-Express4.html 感觉没什么好翻译的,都比较简单,主要讲了TLP的帧结构 In the transaction layer, ...
- PCI Express(三) - A story of packets, stack and network
原文出处:http://www.fpga4fun.com/PCI-Express3.html Packetized transactions PCI express is a serial bus. ...
- PCI Express(二) - Topology
原文出处:http://www.fpga4fun.com/PCI-Express2.html Point-to-point architecture At 2.5Gbps, the PCI Expre ...
- PCI Express(一)- Connector
在FPGA4FUN上看到一篇介绍PCI-E的帖子,简单易懂,适合入门,特地搬过来 原文地址:http://www.fpga4fun.com/PCI-Express.html 前言: As PCI Ex ...
- 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 ...
- 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 ...
- [中英对照]How PCI Express Works | PCIe工作原理
How PCI Express Works | PCIe工作原理 PCI Express is a high-speed serial connection that operates more li ...
- PCI Express(五) - Xilinx wizard
原文地址:http://www.fpga4fun.com/PCI-Express5.html Xilinx makes using PCI express easy - they provide a ...
- 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 ...
随机推荐
- golang flag包
go flag 包用来解析命令行参数,通过一个简单的例子来了解下 package main import ( "flag" "fmt" ) fu ...
- 解决ideviceinstaller未安装的问题
在Mac上,使用Appium时提示: Could not initialize ideviceinstaller; make sure it is installed and works on you ...
- 1、SQL可搜索可排序可分页存储过程, 2、范围内的随机时间 适用于sql 2008以上
-- ============================================= -- Author: 蜘蛛王 -- Create date: 2015-10-29 -- Descri ...
- rake :You have already activated rake 10.1.0
rake aborted! You have already activated rake 10.1.0, but your Gemfile requires rake 10.0.3. Using b ...
- Shiro标签
在使用Shiro标签库前,首先需要在JSP引入shiro标签: <%@ taglib prefix="shiro" uri="http://shiro.apache ...
- pythonbrew, pythonz, virtualenv
Python 的虛擬環境及多版本開發利器─Virtualenv 與 Pythonbrewhttp://www.openfoundry.org/tw/tech-column/8516-pythons-v ...
- CSS详解
Web前端开发css基础样式总结 颜色和单位的使用 颜色 用颜色的名字表示颜色,比如:red 用16进制表示演示 比如:#FF0000 用rgb数值表示颜色,rgb(红,绿,蓝),每个值都在0-255 ...
- Caffe使用:如何将一维数据或其他非图像数据转换成lmdb
caffe事儿真多,数据必须得lmdb或者leveldb什么的才行,如果数据是图片的话,那用caffe自带的convert_image.cpp就行,但如果不是图片,就得自己写程序了.我也不是计算机专业 ...
- Ubuntu 下安装 SQL Server 2016初探
安装步骤参官方 https://docs.microsoft.com/zh-cn/sql/linux/sql-server-linux-setup-ubuntu 执行命令如下: .Enter supe ...
- nyoj 708 ones 动态规划
http://acm.nyist.net/JudgeOnline/problem.php?pid=708 状态转移方程的思路:对于一个数N,可以是N - 1的状态+1 得到,另外,也可以是(n / 2 ...