tag 标签: cord

相关博文
  • 热度 11
    2015-3-24 13:47
    1384 次阅读|
    0 个评论
       引言   在需要硬件实现对数运算的场合 ,其精度和速度是必须考虑的问题。目前硬件实现对数变换的方法主要有查表法、泰勒公式展开法和线性近似法。查表法 所需要的存储单元随着精度的增加或输入值范围的增大而成指数增加;泰勒公式展开法 需要乘法器,面积大不易实现;线性近似法 的精度有限,且需要误差校正电路,实现较难。   本文利用CORD IC算法在FPGA上实现了高速自然对数变换器。CORD IC算法即坐标旋转数字计算方法最初由J.D.Volder 于1959年提出,其基本思想是用一系列与运算基数相关的角度的不断偏摆从而逼近所需旋转的角度。1971年J.S.Walter 提出统一的CORD IC算法,把圆周旋转、直线旋转和双曲旋转统一到同一个CORD IC迭代方程里,为同一硬件实现多功能运算提供了前提。由于它将许多复杂的算术运算化成简单的加法和移位操作,在不影响运算速度和精度的情况下,极大的降低了硬件设计的复杂性,节约了硬件资源。利用CORD IC算法可以直接实现乘法、除法、正余弦函数,反正切函数、双曲函数等,对输入进行适当的初始化可以实现正切、双曲正切、对数和指数等函数。   在数字信号处理领域用的较多的是DSP和FPGA。DSP的优势源于多数信号处理算法的乘-累加运算(MAC)都是非常密集的。FPGA通过多极流水线架构也能够用来实现MAC单元,并且FPGA技术可以通过一个芯片上的多级MAC单元来提供更多的带宽,速度可以比数字信号处理芯片快,并且功耗较低。CORD IC算法完全由移位和加法操作完成,因此利用FPGA可以实现更高的运算速度。本文采用流水线结构在FPGA上实现基于CORD IC的对数变换,可以达到80MHz的处理速度。    CORD IC算法实现自然对数运算   CORD IC算法最初是用于计算三角函数的,后来由于其算法的简单、硬件易于实现等多种优势,而被广泛的用于多种初等函数的运算中(包括三角函数、乘除法运算、指数运算、对数运算等)。本文主要利用CORD IC算法的双曲旋转法实现自然对数运算。   在双曲坐标系下,CORD IC算法的迭代方程为:   由于 ,所以迭代序列必须从n=1开始,为保证迭代序列收敛,因此迭代序列n的取值从第4项开始每隔3n+1项必须重复一次,即n=1,2,3,4,4,5,…,40,40,…。   在向量模式下, 经n次迭代后的输出方程为:   因为   所以令x=t+1,y=t-1   则   所以对于t,如果我们要求lnt,只要做如下初始化:   X=t+1,y=t-1,z=0   则输出z=0.5ln(t),只需要在CORD IC之后做一次左移即可。   如(2)式所示,为保证迭代序列的收敛,|tanh-1(y0/x0)|≤1.1182,因此|y/x|max≈0.8069,n→∞,反双曲正切的定义域为(-1,1),可见函数的输入范围受到了限制。解决的方法是增加n为负数的迭代,改进的算法公式为:   当n≤0时   当n0时   收敛的范围变成   |tanh-1(y/x)|≤θmax   其中      当M=5时,θmax=12.4264,函数tanh-1的范围是 。也就是说此时y/x可以接近于 ,几乎覆盖tanh-1的整个定义域。因此硬件实现过程中可以从-5开始迭代。    对数运算的FPGA实现   CORD IC算法完全由移位和相加完成,很容易在硬件上实现。由于FPGA具有并行处理能力,利用FPGA实现对数变换,速度可以比数字信号处理芯片快,以满足某些高速处理的要求。本文采用的FPGA芯片是Altera公司的cyclone系列芯片EP1C6Q240C8。该芯片内部共有逻辑单元5980个,支持近12万门的设计,内部嵌有约12Kbyte的RAM,包含2个生成时钟的锁相环,最大用户I/O数185个,满足设计要求。    实现方法   预处理单元   欲利用CORD IC方法求自然对数,必须对输入进行初始化,经迭代运算后才能得到对数运算值。该对数变换器的输入为16位数,在预处理单元中将输入分别加减一,并将位宽扩大为40位,最高位作为符号位覆值给第一次迭代的x0和y0,如图1所示,图中s代表符号位。扩大位宽可以提高输出精度。 图1初始迭代值x0,y0    CORD IC单元   CORD IC单元是实现对数变换器的核心。本文利用流水线结构实现CORD IC算法,其结构如图2所示。在设计中,采用由28级CORD IC运算单元组成的流水线结构,为扩大输入范围,从n=-5开始迭代,移位序列为 。前6级根据(3)式进行迭代,后22级根据(4)式进行迭代。经过28级流水线运算后,y变为0,z左移一位就是要求的对数值。每一级电路结构主要包括2个移位寄存器和3个加减法器,这些移位寄存器各自有不同的固定的移位次数,加减法选择由该级中y的最高位(符号位)决定。θn为第n次迭代的旋转角度,并作为常数直接连到了累加器上,不需要存储空间和读取时间。 图2 CORDIC流水线结构    后处理单元   由CORD IC得到的z=1/2ln(t),因此将结果左移一位,并截取高16位作为最终的输出。其中最高位为符号位,最大输入值65535的对数值为11.0903,对应的输出为7FFF,其余输出均除以对应的值即得到相应的对数值。    实验结果   在Quartus II 5.1软件环境下使用Verilog HDL语言完成了上述各算法,并在cyclone系列芯片EP1C6Q240C8上实现。图3 为对数运算时序仿真图。表1为对数运算结果与理论值的比较。 图3对数运算时序仿真图   由表1可看出,该对数运算器的输出误差为10-4数量级。由于采用流水线结构,能够在执行进程的同时输入数据,从而极大的提高了程序的运行效率。该设计需要30个时钟周期获取第一个计算结果,而只需要一个时钟周期来获取随后的计算结果。利用Quartus Ⅱ5.1软件进行时序分析,该运算器的最高频率可达到80MHz。该运算器适用于高速大数据量的数据处理。 表1对数运算结果与理论值的比较    结语   利用对数变换可以将乘除法变换为加减法实现,有利于乘除法在硬件中的实现。由于CORD IC算法完全由移位和相加运算完成,降低了复杂性,易于硬件的实现。笔者利用CORD IC算法在FPGA上设计了一种自然对数变换器。实现过程中采用流水线结构,提高了系统的运行效率。实验结果表明该对数运算器的输出误差为10-4数量级,最高频率可达到80MHz。该运算器适用于高速大数据量的数据处理。    参考文献:   1.  李刚、李秋霞、林凌、李小霞等,动态光谱频域提取的FFT变换精度分析,光谱学与光谱分析,2006,12:2177-2180   2.  Bajard J C,Muller J M.BKM: A new hardware algorithm for complex elementary functions.IEEE Trans computers,1994,43(8):955-963   3.  Hormigo J,Villalba J,Schulte M J.A hardware algorithm for variable precision logarithm //proceedings of the IEEE inter conf on application-specific systems,architectures and processors,2000:215-224   4.  Abed K H,Siferd R E. CMOS VLSI implementation of a low power logarithmic converter. IEEE Trans computers,2003,52(11):1421-1433   5.  Uwe Meyer-Baese.Digital SignalProcessing with Field Programmable Gate Arrays .Tsinghua University Press. 2006:79-87   6.  J.S.Walther. A unified algorithm for elementary functions. in proc.Spring Joint Comput.Conf.,1971:379-385   7.  Chih-Hsiu Lin and An-Yeu Wu.Mixed-Scaling-Rotation CORDIC(MSR-CORDIC) Algorithm and Architecture for High-Performance Vector Rotational  DSP Applications. IEEE Transactions on circuits and systems-I:REGULAR PAPERS, 2005,52(11):2385-2396   8.  Xiaobo Hu,Ronald G. Harber,Expanding the range of convergence of the CORDIC algorithm. IEEE Transactions on computers, 1991,40(1):13-21   9.  Altera公司,“Cyclone FPGA Family data Sheet”
  • 热度 21
    2014-10-9 19:22
    2462 次阅读|
    0 个评论
    It's autumn in New England in the United States. The leaves are turning to red, orange, and gold, my roses are in their second bloom, and it's time to remove the air conditioner from the window. On September 22, I opened the window to remove the air conditioner as I've done many times before. For the first time, the air conditioner fell out.   Too often, we focus on the latest and greatest processor, mobile device, or other "cool" product. But sometimes, simple things such as strain relief take on significance and save the day, especially for a "cool" product such as an air conditioner.   The air conditioner never hit the ground. Why? Because with my lightning reflexes, I grabbed the power cord, stopping the fall. Yes, the power cord's strain relief made the difference. There was a thud as the unit hit the side of the house, but it didn't hit the first-floor window directly below.   So here I am with my arm hanging out the second-floor window, holding onto the line cord as the A/C unit dangles. But even with two hands, I had difficulty pulling the unit up. I called for my wife, who came and helped me pull on the cord. The A/C unit came up and I pulled it in.   (Image: Illustration by Daniel Guidera)   There was surprisingly little damage. What's really impressive is that the strain relief of the line cord could hold the weight of the unit and survive the force on it. So, who is the manufacturer of this miraculous air conditioner, anyway? The brand name is Liberty, made in China. Here's a photo of the front-panel controls.     Here's the side-panel label.   As you can see, the physical damage is minimal, just a broken extension panel and a small break where the line cord enters the unit.     I simply had to see the strain relief on the power cord, so I removed the front panel. There, I could see that the strain relief was screwed into the metal chassis.     Next, I removed the control panel to get a look at the connections from the power cord to the circuits inside the unit. They were perfectly intact, thanks to the strain relief. The photo below shows the power cord connected to a large capacitor that reads "35/6 µF."   I then reassembled the unit plugged it into an AC outlet that had a dedicated circuit breaker, and turned it on. It worked, but I won't use it again in its current condition. Close inspection of the power cord revealed some damage, as the photo below shows. There's even a label on the cord telling you not to use it if the internal shielding is visible. The label says:   The conductors inside this cord are covered by shields, which monitor leakage current. THESE SHIELDS ARE NOT GROUNDED. Periodically examine the cord for any damage. DO NOT USE THIS PRODUCT in the event the shield becomes exposed.     Clearly, covering the cut with electrical tape isn't an option here. I'll need either to replace the power cord or use another air conditioner next year. I have one in a closet that hasn't been needed in this house.   What was that about leakage current? To find out, I called Tower Manufacturing of Providence, Rhode Island, maker of the power cord, and spoke to an engineer. The power cord has an LCDI (line-current detection interrupter) at the wall-outlet end. It's essentially a circuit breaker that trips based on leakage current. The LCDI cuts power to the unit if it detects about 5 mA. The engineer explained that LCDIs were developed for air conditioners. The problem grew from power cords that failed over time, sometimes causing fires. People would wrap the power cord around the unit and put it away for the winter. Over time, the cords would develop shorts. The LCDIs comply with UL 1699 .     I asked if the company manufactured assembled AC line cords or just the LCDIs. Tower manufactures line cords for several air conditioner manufacturers, some are completely assembled with terminations (spade lugs) and some without. There are plenty of online sellers of air-conditioner power cords, but Liberty is not an everyday name. A quick look at one seller didn't show the brand name. This one looks promising, but I'll have to gain access to the power cord again for another inspection of the terminations. I have plenty of time for that, given the length of winters here. But, I might just employ the unused air conditioner and let this one go (figuratively, that is). More homework is required. Next year, I'll probably install a support bracket under the unit, regardless of which one I put in the window.   This experience shows the importance of strain relief. Remember that strain relief, connectors, and even screws are important. They may not be "cool," but they can save the day.