跳转到主要内容

JESD204 IP核的AXI4-lite接口协议读写

judy 提交于

<font color="#FF8000">作者:小青菜哥哥
原文链接:https://mp.weixin.qq.com/s?__biz=MzUxMTcyNDQyMQ==&mid=2247484506&idx=1&…
声明:本文由原创博主授权转发,如需转载请联系博主</font>

本篇介绍AXI4-Lite接口协议的数据读写操作~

如下表所示为AXI4-Lite协议所使用信号的官方标准,共有21组信号:
<center><img src="http://xilinx.eetrend.com/files/2020-04/%E5%8D%9A%E5%AE%A2/100049051-96…; alt=""></center>

如下图所示为vivado例化的JESD204 IP核,其中标记部分即为AXI4-Lite接口,共有19组信号,官方标准中的AWPROT和ARPROT信号无需使用。操作这19组信号即可实现对JESD204 IP核的寄存器配置与状态监测,我们接下来详细介绍这些信号:
<center><img src="http://xilinx.eetrend.com/files/2020-04/%E5%8D%9A%E5%AE%A2/100049051-96…; alt=""></center>

<strong>全局信号</strong>
<li>s_axi_aclk</li>
接口的读写时钟,默认为100MHz,由用户提供。

<li>s_axi_aresetn</li>
接口的复位信号,默认低电平复位,由用户提供,最好使用同步复位。

<table border="1" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td width="525" colspan="3" valign="top"><p>Table A2-1 Global signals</p></td>
</tr>
<tr>
<td width="179" valign="top"><p>Signal</p></td>
<td width="172" valign="top"><p>source</p></td>
<td width="174" valign="top"><p>description</p></td>
</tr>
<tr>
<td width="179" valign="top"><p>ACLK</p></td>
<td width="172" valign="top"><p>Clock source</p></td>
<td width="174" valign="top"><p>Global clock signal</p></td>
</tr>
<tr>
<td width="179" valign="top"><p>ARESETn</p></td>
<td width="172" valign="top"><p>Reset source</p></td>
<td width="174" valign="top"><p>Global reset signal, active  LOW</p></td>
</tr>
<tr>
<td width="525" colspan="3" valign="top"><p>All signals are sampled on  the rising edge of the global clock</p></td>
</tr>
</tbody>
</table>

<strong>写地址信号</strong>
<li>s_axi_awaddr</li>
写地址信号。用户向IP核发送12bit位宽的寄存器地址信号,准备向该地址写入数据。
<li>s_axi_awvalid</li>
写地址可用信号。用户向IP核发送1bit位宽的写地址可用信号,告诉IP核,用户端发送的12bit地址是有效的。
<li>s_axi_awready</li>
写地址准备信号。IP核向用户端发送1bit位宽的写地址准备信号,告诉用户端,它已经准备好接收12bit的寄存器地址信号了。

<table border="1" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td width="506" colspan="3"><p>Table A2-2 Write address  channel signals</p></td>
</tr>
<tr>
<td width="104"><p>Signal</p></td>
<td width="68"><p>source</p></td>
<td width="346"><p>description</p></td>
</tr>
<tr>
<td width="104"><p>AWADDR</p></td>
<td width="76"><p>Master</p></td>
<td width="346"><p>Write address. The write  address gives the address of the first transfer in a write burst transaction</p></td>
</tr>
<tr>
<td width="104"><p>AWVALID</p></td>
<td width="76"><p>Master</p></td>
<td width="346"><p>Write address valid. This  signal indicates that the channel is signaling valid write address and  control information</p></td>
</tr>
<tr>
<td width="104"><p>AWREADY</p></td>
<td width="76"><p>Slave</p></td>
<td width="346"><p>Write address ready. This  signal indicates that the slave is ready to accept an address and associated  control signal</p></td>
</tr>
</tbody>
</table>
<p><br />
</p>

<strong>写数据信号</strong>
<li>s_axi_wdata</li>
写数据信号。用户向IP核写入32bit位宽的寄存器配置数据,写入的地址即为上表中的12bit位宽的地址。
<li>s_axi_wstrb</li>
写字节有效信号。该信号4bit位宽,每bit信号标志着8bit的写入数据是否有效。4bit位宽的该信号正好对应32bit的写数据信号是否有效。用户在向IP核写入32bit的 s_axi_wdata时,同时要写入s_axi_wstrb,一般s_axi_wstrb置为全1即可,表明写入数据都是可用的。
<li>s_axi_wvalid</li>
写可用信号。用户向IP核发送该信号,表明s_axi_wdata和s_axi_wstrb
信号对于IP核都是可用的。
<li>s_axi_wready</li>
写准备信号。IP核向用户发送该信号,表明IP核已经准备好接收来自用户端的s_axi_wdata和s_axi_wstrb信号。

<table border="1" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td width="525" colspan="3"><p>Table A2-3 Write data  channel signals</p></td>
</tr>
<tr>
<td width="67"><p>Signal</p></td>
<td width="74"><p>source</p></td>
<td width="384"><p>description</p></td>
</tr>
<tr>
<td width="67"><p>WDATA</p></td>
<td width="74"><p>Master</p></td>
<td width="384"><p>Write data</p></td>
</tr>
<tr>
<td width="67"><p>WSTRB</p></td>
<td width="74"><p>Master</p></td>
<td width="384"><p>Write strobes. This signal  indicates which byte lanes hold valid data. There is one write strobe bit for  each eight bits of the write data bus</p></td>
</tr>
<tr>
<td width="67"><p>WVALID</p></td>
<td width="74"><p>Master</p></td>
<td width="384"><p>Write valid. This signal  indicates that valid write data and strobes are available</p></td>
</tr>
<tr>
<td width="67"><p>WREADY</p></td>
<td width="74"><p>Slave</p></td>
<td width="384"><p>Write ready. This signal  indicates that the slave can accept the write data</p></td>
</tr>
</tbody>
</table>

<strong>写响应信号</strong>
<li>s_axi_bresp</li>
写响应信号。该信号2bit位宽,当用户向IP核写入数据后,IP核会向用户反馈写入是否成功。s_axi_bresp共4种状态,当其为2’b00时,表示写成功。
<li>s_axi_bvalid</li>
写响应可用信号。该信号1bit位宽,表示此时写响应信号可用,在该标志位下,用户获取写响应信号,此信号由IP核提供,用户端接收。
<li>s_axi_bready</li>
写响应准备信号。该信号1bit位宽,由用户端发送到IP核,表示用户端已经准备好接收s_axi_bresp和s_axi_bvalid信号。

<table border="1" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td width="525" colspan="3"><p>Table A2-4 Write response  channel signals</p></td>
</tr>
<tr>
<td width="66"><p>Signal</p></td>
<td width="76"><p>source</p></td>
<td width="372"><p>description</p></td>
</tr>
<tr>
<td width="66"><p>BRESP</p></td>
<td width="76"><p>Slave</p></td>
<td width="372"><p>Write response. This signal  indicates the status of the write transaction</p></td>
</tr>
<tr>
<td width="66"><p>BVALID</p></td>
<td width="76"><p>Slave</p></td>
<td width="372"><p>Write response valid. This  signal indicates that the channel is signaling a valid write response</p></td>
</tr>
<tr>
<td width="66"><p>BREADY</p></td>
<td width="76"><p>Master</p></td>
<td width="372"><p>Response ready. This signal  indicates that the master can accept a write response to accept an address  and associated control signal</p></td>
</tr>
</tbody>
</table>

<strong>读地址信号</strong>
<li>s_axi_araddr</li>
读地址信号。用户向IP核写入需要读写的寄存器地址,共12bit位宽。
<li>s_axi_arvalid</li>
读地址可用信号。用户向IP核提供读地址可用信号,共1bit位宽,该标志位与s_axi_araddr信号同时发送到IP核。
<li>s_axi_arready</li>
写地址准备信号。IP核向用户提供该1bit位宽信号,来告诉用户什么时候可以向它写入s_axi_araddr和s_axi_arvalid信号

<table border="1" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td width="525" colspan="3"><p>Table A2-5 Read address  channel signals</p></td>
</tr>
<tr>
<td width="76"><p>Signal</p></td>
<td width="93"><p>source</p></td>
<td width="344"><p>description</p></td>
</tr>
<tr>
<td width="76"><p>ARADDR</p></td>
<td width="101"><p>Master</p></td>
<td width="344"><p>Read address. The read  address gives the address of the first transfer in a read burst transaction</p></td>
</tr>
<tr>
<td width="76"><p>ARVALID</p></td>
<td width="101"><p>Master</p></td>
<td width="344"><p>Read address valid. This  signal indicates that the channel is signaling valid read address and control  information</p></td>
</tr>
<tr>
<td width="76"><p>ARREADY</p></td>
<td width="101"><p>Slave</p></td>
<td width="344"><p>Read address ready. This  signal indicates that the slave is ready to accept an address and associated  control signals</p></td>
</tr>
</tbody>
</table>
<p><br />
</p>

<strong>读数据信号</strong>
<li>s_axi_rdata</li>
读数据信号。该信号32bit位宽,由IP核提供给用户,是寄存器的值。
<li>s_axi_rresp</li>
读数据响应。IP核向用户传输寄存器值时,还同时传输该响应信号,该信号2bit位宽,指示读数据的共4种状态,其中2’b00表示正常。
<li>s_axi_rvalid</li>
读数据可用信号。该信号作为读数据信号的可用标志信号,同样由IP核提供给用户。
<li>s_axi_rready</li>
读数据准备信号。用户向IP提供该1bit信号,表示用户端已经准备好接收数据了。

<table border="1" cellpadding="0" cellspacing="0">
<tbody>
<tr>
<td width="525" colspan="3"><p>Table A2-6 Read data channel signals</p></td>
</tr>
<tr>
<td width="66"><p>Signal</p></td>
<td width="63"><p>source</p></td>
<td width="384"><p>description</p></td>
</tr>
<tr>
<td width="66"><p>RDATA</p></td>
<td width="71"><p>Slave</p></td>
<td width="384"><p>Read data</p></td>
</tr>
<tr>
<td width="66"><p>RRESP</p></td>
<td width="71"><p>Slave</p></td>
<td width="384"><p>Read response. This signal indicates the status of the read  transfer</p></td>
</tr>
<tr>
<td width="66"><p>RVALID</p></td>
<td width="71"><p>Slave</p></td>
<td width="384"><p>Read valid. This signal indicates that the channel is signaling  the required read data</p></td>
</tr>
<tr>
<td width="66"><p>RREADY</p></td>
<td width="71"><p>Master</p></td>
<td width="384"><p>Read ready. This signal indicates that the master can accept the  read data and response information</p></td>
</tr>
</tbody>
</table>

AXI4-Lite协议所使用的信号在这里就介绍完毕了,接下来介绍实现该协议的时序关系~

<strong>写时序</strong>
如下图所示为AXI4-lite写逻辑的时序图,仅供参考。通俗的说:如果我们想配置JESD204 IP核,就必须按照如图的时序关系才能实现。实现步骤可以分为3步:写地址、写数据以及写响应。
<center><img src="http://xilinx.eetrend.com/files/2020-04/%E5%8D%9A%E5%AE%A2/100049051-96…; alt=""></center>

<li>写地址</li>
当监测到IP核给出的AWREADY有效时,用户在时钟上升沿写入寄存器数据的地址AWADDR以及地址使能AWVALID。
<li>写数据</li>
当监测到WREADY有效时,用户在时钟上升沿写入寄存器数据WDATA、WSTRB以及数据使能WVALID。
<li>写响应</li>
当监测到BREADY、BVALID均有效时,用户获取写响应信号BRESP。

<strong>读时序</strong>
如下图所示为AXI4-lite读逻辑的时序图,仅供参考。如果我们想读取JESD204 IP核的内部寄存器值,就必须按照如图的时序关系才能实现。实现步骤可以分为2步:写地址、读数据以及读响应。
<center><img src="http://xilinx.eetrend.com/files/2020-04/%E5%8D%9A%E5%AE%A2/100049051-96…; alt=""></center>

<li>写地址</li>
当监测到IP核给出的ARREADY有效时,用户在时钟上升沿写入寄存器数据的地址ARADDR以及地址使能ARVALID。
<li>读数据及读响应</li>
当监测到IP核给出的RVALID有效且用户端的RREADY有效时,用户在时钟上升沿读取寄存器数据RDATA以及读响应信号RRESP。

下面介绍读写时序的verilog逻辑代码~

1, 写地址逻辑
<center><img src="http://xilinx.eetrend.com/files/2020-04/%E5%8D%9A%E5%AE%A2/100049051-96…; alt=""></center>

2, 写数据逻辑
<center><img src="http://xilinx.eetrend.com/files/2020-04/%E5%8D%9A%E5%AE%A2/100049051-96…; alt=""></center>

3, 写响应逻辑
<center><img src="http://xilinx.eetrend.com/files/2020-04/%E5%8D%9A%E5%AE%A2/100049051-96…; alt=""></center>

4, 读操作的写地址逻辑
<center><img src="http://xilinx.eetrend.com/files/2020-04/%E5%8D%9A%E5%AE%A2/100049051-96…; alt=""></center>

5, 读数据及读响应
<center><img src="http://xilinx.eetrend.com/files/2020-04/%E5%8D%9A%E5%AE%A2/100049051-96…; alt=""></center>

<strong>测试结果</strong>
该测试配置了JESD204 IP核的11个关键寄存器,如下图代码所示:
<center><img src="http://xilinx.eetrend.com/files/2020-04/%E5%8D%9A%E5%AE%A2/100049051-96…; alt=""></center>

配置完成后,将13个寄存器的值读出来:
<center><img src="http://xilinx.eetrend.com/files/2020-04/%E5%8D%9A%E5%AE%A2/100049051-96…; alt=""></center>

用逻辑分析仪可以看到,写入的数据和读出的数据是完全相同的,证明AXI4-Lite接口的读写时序没问题~
<center><img src="http://xilinx.eetrend.com/files/2020-04/%E5%8D%9A%E5%AE%A2/100049051-96…; alt=""></center>