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 ...
随机推荐
- CefBrowser 复制图片解决办法
使用的是CefSharp控件,开放出的功能比较多,但是还是有一些封闭的.例如复制图片到Clipbord,库没有提供. VC虽然看得懂,但托管代码没搞过,看得很蛋痛,而且如果有CefSharp有新版本还 ...
- Socket 通信(基础原理、实时聊天系统雏形)
什么是 Socket? Socket 英文直译为"孔或插座",也称为套接字.用于描述 IP 地址和端口号,是一种进程间的通信机制.你可以理解为 IP 地址确定了网内的唯一计算机,而 ...
- Docker 容器部署 Consul 集群
Docker 容器部署 Consul 集群 一.docker安装与启动1.1安装docker[root@localhost /]# yum -y install docker-io 1.2更改配置文件 ...
- file_get_contents()函数
$data = file_get_contents('http://www.zgjmwl.com/jinshui/pro_one/ceshi_a.php'); var_dump(substr($dat ...
- web三种跨域请求数据方法
以下测试代码使用php,浏览器测试使用IE9,chrome,firefox,safari <!DOCTYPE HTML> <html> <head> < ...
- Microsoft Visual Studio 2012注册密钥
Microsoft Visual Studio Ultimate 2012 旗舰版 有效注册密钥:YKCW6-BPFPF-BT8C9-7DCTH-QXGWCMicrosoft Visual Studi ...
- [Android] ADB操作相关经验
1.手机必须先root,小米可以安卓开发版系统即可.(注意:usb设置为调试模式) 2.安卓 adb工具(android debug bridge) 3.依次执行下面的命令: #adb root 获得 ...
- ubuntu 更换系统语言,Change System Language
1.打开设置,打开“Language Support”. 2.如果列表中没有你的语言,点击“Install/Remove Language”,下拉选择你的语言,点击“Apply Changes”. 3 ...
- Mac下Virtual Box Host-Only网络配置
Mac下的虚拟机其实有很多,Parallels.VMware Fusion.Virtual Box都不错,Parallels是目前试过感觉最好的,Fusion装64位系统驱动支持似乎不完善,而且混合模 ...
- ARM指令分类及其寻址方式
ARM指令分类及其寻址方式 一:ARM指令的分类 ARM指令集可以分为以下6类: •跳转指令: •数据处理指令: •程序状态寄存器(PSR)传输指令: •load/store指令: •协处理器指令: ...