SYS/BIOS与SRIO应用实例

  SYS/BIOS是TI的实时内核,也叫做TI-RTOS,它是RTSC中的一个软件包,可以使DSP的软件设计更加方便。SRIO是适用于嵌入式系统中的高速接口,之前我也写过一些相关的文章,这次做了一些完善。补充了原先SRIO收发控制器中发送NREAD事务包的功能。

系统功能

在这里插入图片描述
  整个系统实现的功能大概如上图所示。DSP外接的DDR中存放有两张640×512的图片,DSP与FPGA通过一条1x的SRIO链路相连。DSP周期性地向FPGA发送门铃事务包,由FPGA内的MicroBlaze软核解析后,FPGA端发送相应的多个SRIO NREAD事务包,从DSP外接的DDR中读取特定地址区域的图片,然后通过VGA交替显示两张图片。
  DSP采用的是TMS320C6455,FPGA端实例化MicroBlaze软核处理器,由它向SRIO收发控制器发送命令。

SYS/BIOS的使用

  自从开始使用它以来,我觉得大部分情况下,我们都可以在这个实时内核的框架下来完成应用的设计。它的主要优势在于灵活,相较于传统的裸核程序运行在一个死循环里,它能够更快地添加一些功能,只要创建几个新的Task就行。在使用之后发现,它能够更方便地管理中断,更精确地控制延时。

文档查阅

  查询相关文档的方法在之前的文章中也已经介绍过了,在Help->Help Contents里,可以找到所有RTSC的软件包的API的介绍,SYS/BIOS自然也不例外,而且非常详细。

#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/knl/Semaphore.h>
#include <xdc/cfg/global.h>
#include <xdc/runtime/System.h>

  上面这些是一些常用的头文件。"BIOS.h"是最基本的,里面的BIOS_start()就相当于是FreeRTOS里的vTaskStartScheduler()。
  Task和Semaphore是最常用的,必要时还可能会用到Hwi、Cache、Event、Queue、Clock、Timer等API。
  include "global.h"主要是让C/C++源文件能够获取到XDCTools配置文件中创建的句柄,比如Task、Semaphore的句柄等。
  "System.h"主要用来实现打印输出。

UIA的使用

  UIA(Unified Instrumentation Architecture),是一个调试用的工具。我觉得它最棒的功能就是它能够把几个任务之间的切换通过下面这种图的方式表现出来。
在这里插入图片描述
  只需要根据“SPRUH43F-System Analyzer User’s Guide”这个文档进行配置就行,这个文档在UIA的安装目录下就有。主要是在XDCTools的配置文件中添加下面这行代码,然后也就有相应的图形界面可以设置。

var LoggingSetup = xdc.useModule('ti.uia.sysbios.LoggingSetup');

时间片调度

  SYS/BIOS是没有直接的时间片调度的,也就是说如果有两个相同优先级的Task,那就是哪个Task先创建就先执行哪个。如果想要进行时间片调度,就需要自己添加一个Clock的实例,并周期地执行"Task_yield()",让执行中的Task主动放弃CPU资源。这在SYS/BIOS的User’s Guide里的3.5.6中举了个例子。

精确控制延时

  使用SYS/BIOS能够精确地控制延时。Clock能够用来创建软件中断(Swi)层面的thread。Clock tick是计时的基本单位,包括在等待Semaphore或者Event时,也都是这个统一的单位。默认的一个Clock tick是1ms,这个可以在Clock的配置页面看到。
  而这个准确的计时是由硬件定时器Timer来完成的,每次Timer定时1ms都会自动调用Clock_tick(),使Clock的计数值加一。
在这里插入图片描述
  在Task中利用Task_sleep(delay)函数可以使Task休眠delay个Clock tick。在Clock tick是1ms的情况下,Task_sleep(1000)就可以让Task休眠1s。

中断管理

  在使用CSL库的时候,中断的配置是挺头疼的,需要创建好几个全局变量,需要一开始就确定中断的个数。但在SYS/BIOS里,就可以在XDCTools的配置脚本中完成,而且可以直接通过图形化界面配置。
在这里插入图片描述
  在C/C++的源文件中我们就只需要写相应的中断服务函数就行了。

关于RTSC工程

添加Section

  在创建了RTSC工程工程之后,不管是有没有用SYS/BIOS,原先的链接脚本文件基本上已经没用了,RTSC工程会自己产生一个链接脚本文件。如果仍然保留原先的链接脚本,很可能就会产生冲突,所以不建议再添加链接脚本。

Program.sectMap[".image"] = new Program.SectionSpec();
Program.sectMap[".image"].loadSegment = "DDR2";

  如果想要添加一个新的Section,需要在XDCTools的配置脚本中用类似上面的代码将Section分配到Memory中。上面的代码是将叫做".image"的Section放到叫做"DDR2"的Memory中。

打印输出

  打印输出采用的是System_printf(),默认不支持打印输出浮点数,如果想打印输出浮点数,需要在XDCTools的配置脚本中加上下面这行设置。

System.extendedFormats = "%f";

保留数据

  我将两幅图的数据定义成数组的形式,并存放到特定的地址空间里。等待FPGA端的SRIO来读这部分数据。

#pragma DATA_SECTION(nIrDst, ".image");
const Uint8 nIrDst[] = {……};

  然而因为我没有在其它地方对这部分数据进行读写,所以编译器在编译之后就把这部分数据省略了。
在这里插入图片描述
  为了解决这个问题,可以在linker的配置中显式的告诉linker这个变量不能省略。

FPGA端设计

  实例化了一个SRIO接收控制器用于接收门铃中断,实例化了一个SRIO收发控制器用于发送NREAD事务包,从DSP读取图像数据,并发送至VGA显示模块中的显存。

在这里插入图片描述

Local Memory与固化

  MicroBlaze要实现的功能非常少,只要接收门铃中断,然后配置SRIO收发控制器,发起NREAD事务就行,所以我一开始就想可以把代码都放在Local Memory上,选了8kB的大小,以为足够了。但事实证明,如果要打印很多东西,8kB是不够的,后来我把那些打印的函数都去掉才勉强把代码都放在8kB的空间里。以后应该把Local Memory选大一点,16kB应该差不多,再不行就把代码放DDR上去,那样就需要加一个bootloader的工程。
  因为代码都是存在BRAM中的,所以它可以和bitsteam一起固化,相当于把BRAM初始化为代码。
在这里插入图片描述

  右键点击BlockDesign,选择“Associate ELF Files”,再选择Vitis中编译并且调试好的elf文件。重新生成bitstream,再将新生成的bitstream固化即可。

测试结果

在这里插入图片描述

  依靠SRIO读确实挺慢的,因为我只用了单条链路,而且一包NREAD最多读256字节,一帧640×512的8bit位深度图像就需要1280包。每次FPGA发出请求,到DSP响应也需要很长的时间。所以如果追求传输速率的话,最好还是DSP主动向FPGA发数据。现在这么做的好处只是能够让DSP可以不干预数据的传输。
  第一帧显示的图是较模糊的。
在这里插入图片描述
  第二帧显示的图是较清晰。
在这里插入图片描述

  • 3
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
Core name: Xilinx LogiCORE Serial RapidIO Version: 5.5 Release Date: April 19, 2010 ================================================================================ This document contains the following sections: 1. Introduction 2. New Features 3. Supported Devices 4. Resolved Issues 5. Known Issues 6. Technical Support 7. Other Information (optional) 8. Core Release History 9. Legal Disclaimer ================================================================================ 1. INTRODUCTION For the most recent updates to the IP installation instructions for this core, please go to: http://www.xilinx.com/ipcenter/coregen/ip_update_install_instructions.htm For system requirements: http://www.xilinx.com/ipcenter/coregen/ip_update_system_requirements.htm This file contains release notes for the Xilinx LogiCORE IP Serial RapidIO v5.5 solution. For the latest core updates, see the product page at: http://www.xilinx.com/rapidio/ 2. NEW FEATURES - ISE 12.1 software support - Designed to RapidIO Interconnect Specification v2.1 - Virtex-6 LXT/HXT/SXT 5.0 Gbps support - Spartan-6 3.125 Gbps and 4x support - Expanded simulator support - Support for ML505, ML605 and SP605 boards (see Release Notes AR for details) 3. SUPPORTED DEVICES - Virtex-6 LXT/HXT/SXT/CXT - Spartan-6 LXT - Virtex-5 LXT/FXT/SXT - Virtex-4 FX 4. RESOLVED ISSUES - PHY does not properly pass CRF bit to Buffer - Version fixed : v5.5 - CR# 519603 - Updated PHY to properly pass CRF - GT settings for Spartan-6 and Virtex-6 updated based on characterization - Version fixed : v5.5 - PORT_INITIALIZED toggles indefinitely - Version fixed : v5.5 - CR# 551271 - GT wrappers updated so that the core will detect invalid data until RESETDONE asserts. - Processing Element Features CAR implemented incorrectly - Version fixed : v5.5 - CR# 528369 - Part of the PEF CAR was implemented in the PHY configuration space, now it is merged into the LOGIO configuration space as directed by the spec. See core User Guide for map of configuration space. - Recommended modifications to Example Design reset scheme - Version fixed : v5.5 - CR# 533208, 533209, 533212 - Updated reset sequence, see AR# 33574 for specifics. - Example design "implement.bat" file has error - Version fixed : v5.5 - CR# 533796 - Corrected syntax for NGDBuild command. - Virtex-6 clock modules not using production MMCM settings - Version fixed : v5.4rev1 - CR#546021 - Using outdated values from the clocking wizard in clock modules. - Buffer BRAM using READ_FIRST mode - Version fixed : v5.4rev1 - CR#546424 - Using READ_FIRST mode for buffer BRAMs - need to update to WRITE_FIRST mode for Spartan-6 and Virtex-6 based on characterization. - VHDL example design simulation error when CRF bit de-selected - Version fixed : v5.4rev1 - CR# 532020 - Updated example design so that CRF signals not added when CRF support is disabled. - Virtex-6 bring-up issues - Version fixed : v5.4 - CR#527725, CR#525309, CR#531695 - Using integer values for the MMCM_ADV, regenerated Virtex-6 wrappers based on general hardware characterization results, revised reset sequence. Please see core Release Notes for updates. - GUI settings incorrect or not properly reflected in hardware. - Version fixed : v5.4 - CR#507334, CR#528369, CR#528370 / AR#32122 - The following register fields were corrected: Re-transmit Suppression mask, Logical Layer extended features pointer, DeviceVendorID. - Latches inferred in VHDL example design - Version fixed: v5.2 - CR#509670 / AR#32189 - Added intermediate values for partial register and combinational assignments. - lnk_trdy_n does not assert in evaluation core simulations - Version fixed : v5.1rev1 - CR#493479 / AR#31864 - Modified initial state in evaluation cores. - PHY won't generate stand-alone due to missing module - Version fixed : v5.1rev1 - CR#493162 / AR#31834 - Shared file between buffer and log added to buffer file list. - Virtex-4 core has long initialization time - Version fixed : v5.1rev1 - CR#481684 / AR#31617 - Virtex-4 initSM modified to prevent branch to silent when RX PCS resets in DISCOVERY state. - LogIO local arbitration doesn't account for valid causing re-arbitration prior to legitimatepacket completion. - Version fixed : v5.1 - CR#478748 - Valid used to gate mresp_eof_n and iresp_eof_n for local arbitration. - A ireq_dsc_n asserted for an undefined packet type does not get propogated by the logical layer. - Version fixed : v5.1 - CR#478541 - undefined packet type decode now passes dsc to buffer allowing packet to be dropped. - 16-bit deviceID cores may see a maintenance response transaction presented but not validated on the IResp interface resulting in a lost transaction. by the logical layer. - Version fixed : v5.1 - CR#474894 - Fixed issue when the maintenance response is followed immediatly by a single DWord SWrite packet. - SourceID not configureable for IReq port. - Version fixed : v5.1 - CR#473938 - Added ireq_src_id port to logical layer. All transmit source IDs should now be configureable and all received destination IDs observable. - Write enables into LogIO registers aren't allowing partial register writes. - Version fixed : v5.1 - CR#473441 - Write enables now implementedfor all LogIO registers allowing byte-wise writes of CSRs such as the deviceID register and BAR. - Message response transaction received as a user defined packet type using 16-bit device IDs appears as a corrupted packet on the IResp interface. - Version fixed : v5.1 - CR#473400, CR#473693 - Fixed LogIO RX to properly handle all user-defined types. - PHY core does not dsc upon retry when coincident with TX packet eof resulting in potential buffer lock-up - Version fixed : v4.4rev2 - CR#478246 / AR#31407 - lnk_tdst_dsc_n now asserted for all retry and error scenarios. - Retry of packet being sent causes packet to get stuck in buffer - Version fixed : v4.4rev2 - CR#477217 / AR#31318 - No longer applicable, v5.1 introduces new buffer. - Core accepts muddled packet when reinitializing during packet receipt - Version fixed : v4.4rev1 - CR#477115 / AR#31308 - Core PNAs packet in receipt when link goes down. - Core LCSBA implementation removes 64MB of possible addressing space. - Version fixed : v4.4 - CR#472992 / AR#30939 - Use 10-bit mask with full 34-bit address for LCSBA intercept. - CRC error on stalled packet - Version fixed : v4.4 - CR#469678 / AR#30940 - Fixed condition which loaded in new CRC sequence on a stall just after sof received by PHY. This is a non-concern for Xilinx buffer users. - Virtex-4 4x core may intermittenly train down to 1x mode - Version fixed : v4.4 - CR#467616 / AR#30314 - Modified oplm_pcs_rst_sequence.v file supplied with the core to register asynchronous TXLOCK and RXLOCK signals. - Re-initialization not forced following a change to Port Width Override - Version fixed : v4.4 - CR#459427 / AR#30323 - Modified PHY Layer to detect a change in the port width override field and reinitialize when updated. - Messaging packets providing incorrect treq_byte_count value - Version fixed : v4.4 - CR#467116 / AR#30320 - Modified Logical Layer to properly decode Messaging size field. Modified testbench to properly check byte count for messaging type packets. - 8-bit SWrite transactions usign 16-bit deviceIDs suffer lost eofs - Version fixed : v4.4 - CR#467668 / AR#30322 - Modified Logical Layer to properly forward eof through the pipeline. - Some Logical Layer CARs are not being set correctly in the core. - Version fixed : v4.4 - CR#458414 / AR#30054 - The following Logical Layer CARs are not being set correctly in the core: - Assembly Information CAR (offset 0xC) - ExtendedFeaturesPtr portion - Processing Element Features CAR (offset 0x10) - Switch Port Information CAR (offset 0x14) - Destination Operations CAR (offset 0x1C) - Switch Route Table Destination ID Limit CAR (offset 0x34) - Core does not have functionality to enable the user to drop unintended packets based on Device ID. - Version fixed: v4.3. - CR#455552 - Added a new port called deviceid which indicates the current Device ID value stored in the Base Device ID CSR. - Receive side buffer design may corrupt packets - user may see corrupted packets from the logical layer when many small packets cause the status FIFO to fill. - Version fixed: v4.2 - CR#447884 / AR#29263 - No longer applicable, v5.1 introduces new buffer. - Repeated, transmitted packet accepted control symbols referencing the same AckID cause loss of AckID sync - The user will see this as potentially duplicated received packets which ultimately result in a port error condition. - Version fixed: v4.2 - CR#444561 / AR#29233 - Modified the transmit encoder to send a single packet accepted symbol per back-to-back control symbol. - Stomped packet sent after RFR (Restart-from-Retry)control symbol - The user will occasionally see error recovery on a retry which will affect system bandwidth. - Version fixed: v4.2 - CR#435188 / AR#24837 - Modified the PHY interface to kill a packet if discontinued on eof and prevent entry to the buffer. 5. KNOWN ISSUES The following are known issues for v5.5 of this core at time of release: - NGDBuild errors when using ISE GUI unless XST Keep Hierarchy set to Soft - Version to be fixed : Fix Not Scheduled - CR#534514 / AR#33528 - Please reference the Answer Record for additional information and recommendations. - Virtex-4 FX 3.125G, 4x core may not meet timing. - Version to be fixed : Fix Not Scheduled - CR#506364 / AR#32195 - Please reference the Answer Record for additional information and recommendations. - Unable to traindown to x1 mode in Lane 2. - Version to be fixed : Fix Not Scheduled - CR#457109 / AR#30023 - Traindown in Lane 0 works successfully but the Serial RapidIO endpoint is unable to traindown to Lane 2. The RocketIO transceivers only allow traindown to the channel bonding master. - Core reinitialization during error recovery causes recoverable protocol error. - Version to be fixed : Fix Not Scheduled - CR#457885 / AR#30021 - This is an corner condition that could occur if core is forced to reinitialize (i.e. - force_reinit) while it is in the process of error recovery. If this condition occurs, packets will be sent during recovery's quiet period. This situation is recoverable. - Post-Synplicity synthesis implementation runs may exhibit ucf failures - Version to be fixed : Fix Not Scheduled - CR#447782 / AR#29522 - Synplicity generated net names are not consistent with XST generated names and may not be consistent between core types. The .ucf file must be edited in these failure cases. Please reference the Serial RapidIO v5.1 web Release Notes for suggested work around. - PNA cause field may occasionally reflect a reserved value - Version to be fixed : Fix Not Scheduled - CR#436767 / AR#24982 - The cause field is for debug purposes only and will not affect functionality. Occurrence is rare and requires alignment of multiple control symbols. - Control Symbols may be lost on reinit - Version to be fixed : Fix Not Scheduled - CR#436768 / AR#24970 - This is an unusual and ultimately recoverable error. Set the "Additional Link Request Before Fatal" value on the Physical Configuration page of the GUI to "4" in order to prevent a lost Link Request or Link Response from causing the core to enter the port error state. - Logical Rx does not support core side stalls - Version to be fixed : Fix Not Scheduled - CR#436770 / AR#24968 - The rx buffer must provide packets to the logical layer without buffer induced stall cycles. The buffer reference design provided with the core is a store and forward buffer and complies with this rule. The most recent information, including known issues, workarounds, and resolutions for this version is provided in the IP Release Notes Guide located at www.xilinx.com/support/documentation/user_guides/xtp025.pdf 6. TECHNICAL SUPPORT To obtain technical support, create a WebCase at www.xilinx.com/support. Questions are routed to a team with expertise using this product. Xilinx provides technical support for use of this product when used according to the guidelines described in the core documentation, and cannot guarantee timing, functionality, or support of this product for designs that do not follow specified guidelines. 7. OTHER INFORMATION - N/A 8. CORE RELEASE HISTORY Date By Version Description ================================================================================ 04/2010 Xilinx, Inc. 5.5 5.0 Gbps support 03/2010 Xilinx, Inc. 5.4 Revision 1 11.5 support/Patch Release 09/2009 Xilinx, Inc. 5.4 Spartan-6 support 06/2009 Xilinx, Inc. 5.3 Virtex-6 support 04/2009 Xilinx, Inc. 5.2 11.1i support 11/2008 Xilinx, Inc. 5.1 Revision 1 Patch Release 09/2008 Xilinx, Inc. 5.1 New Buffer LogiCore 07/2008 Xilinx, Inc. 4.4 Revision 2 Patch Release 07/2008 Xilinx, Inc. 4.4 Revision 1 Patch Release 06/2008 Xilinx, Inc. 4.4 Bug Fixes 03/2008 Xilinx, Inc. 4.3 10.1i support 10/2007 Xilinx, Inc. 4.2 9.2i support 02/2007 Xilinx, Inc. 4.1 9.1i support 02/2006 Xilinx, Inc. 3.1 Revision 1 Patch Release 01/2006 Xilinx, Inc. 3.1 8.1i support ================================================================================ 9. Legal Disclaimer (c) Copyright 2006 - 2010 Xilinx, Inc. All rights reserved. This file contains confidential and proprietary information of Xilinx, Inc. and is protected under U.S. and international copyright and other intellectual property laws. DISCLAIMER This disclaimer is not a license and does not grant any rights to the materials distributed herewith. Except as otherwise provided in a valid license issued to you by Xilinx, and to the maximum extent permitted by applicable law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON- INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and (2) Xilinx shall not be liable (whether in contract or tort, including negligence, or under any other theory of liability) for any loss or damage of any kind or nature related to, arising under or in connection with these materials, including for any direct, or any indirect, special, incidental, or consequential loss or damage (including loss of data, profits, goodwill, or any type of loss or damage suffered as a result of any action brought by a third party) even if such damage or loss was reasonably foreseeable or Xilinx had been advised of the possibility of the same. CRITICAL APPLICATIONS Xilinx products are not designed or intended to be fail- safe, or for use in any application requiring fail-safe performance, such as life-support or safety devices or systems, Class III medical devices, nuclear facilities, applications related to the deployment of airbags, or any other applications that could lead to death, personal injury, or severe property or environmental damage (individually and collectively, "Critical Applications"). Customer assumes the sole risk and liability of any use of Xilinx products in Critical Applications, subject only to applicable laws and regulations governing limitations on product liability. THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS PART OF THIS FILE AT ALL TIMES.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小裘HUST

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值