Altera Home Page
文档资料 许可
在线购买 下载

  主页   |   产品   |   支持   |   最终市场   |   技术中心   |   教育与活动   |   公司介绍   |   在线购买  
  mySupport   |   器件   |   软件   |   IP   |   设计范例   |   参考设计  

 产品
      MAX/MAX II
      Stratix/Stratix GX
      Nios II
  
 功能
      算法
      存储器
      总线及I/O
      逻辑
      接口与外设
      DSP
      通信
      PLL & Clocking
  
 设计输入方法
      Quartus II软件工程
      Tcl
      VHDL
      Verilog HDL
      C Code 范例
      DSP Builder
      TimeQuest
   片内调试
  
 仿真工具
      Mentor Graphics ModelSim
      Cadence NCsim
      Synopsys VCS
  
 旧范例
      图形编辑器
      AHDL
  

Verilog HDL: Magnitude

For a vector (a,b), the magnitude representation is the following:

vector (a,b)

A common approach to implementing these arithmetic functions is to use the Coordinate Rotation Digital Computer (CORDIC) algorithm. The CORDIC algorithm calculates the trigonometric functions of sine, cosine, magnitude, and phase using an iterative process. It is made up of a series of micro-rotations of the vector by a set of predetermined constants, which are powers of two. Using binary arithmetic, this algorithm essentially replaces multipliers with shift and add operations. In a Stratix device, it is possible to calculate some of these arithmetic functions directly, without having to implement the CORDIC algorithm.

This design example calculates the magnitude of a 9-bit signed vector (a,b) using a pipelined square root function. To calculate the sum of the squares of the input (a2 + b2), the DSP block can be configured in the Two-Multipliers Adder mode. The square root function is implemented using an iterative algorithm, which is similar to the long division operation. The binary numbers are paired off, and subtracted by a trial number. Depending if the remainder is positive or negative, each bit of the square root is determined and the process is repeated. This square root function does not require memory and is implemented in logic cells only.

In this example, the output precision of the square root function is set to 10. It is possible to increase the precision of the output but this will increase the utilization of logic cells. For more details, see the Implementing High-Performance DSP Functions in Stratix & Stratix GX Devices chapter of the Stratix Device Handbook.

For more information on the square root function, please refer to the Altera IP MegaStoreTM.

A license is required in order for this design example to work properly. For more information, please refer to the README file.

Download the files used in this example:

The use of this design is governed by, and subject to, the terms and conditions of the Altera Hardware Reference Design License Agreement.

Files in the download include:

  • magnitude.v - Top-level design file
  • square_numbers.tdf - Calculates the sum of squares of the input using DSP blocks
  • root_pipeline_wrapper.tdf - Pipelined version of the square root macro

Before you can use the design example, you must copy and paste the license information
from the file sqroot_license.txt into your license file for the Quartus II software.

Figure 1 shows the Magnitude top-level block diagram.

Figure 1. Magnitude Top-Level Block Diagram

Figure 1. Magnitude Top-Level Block Diagram

Table 1 contains a listing of Magnitude design example ports and parameters.

Table 1. Magnitude Design Example Port & Parameter Listing
Port Name Type Description
vectorX[8..0]
vectorY[8..0]
Input The input is a 9-bit signed vector
clk Input Clock
clken Input Clock enable
aclr Input Asynchronous clear
magnitude[9..0] Output If clken is high, the function will calculate the magnitude based on the input vectorX, and vectorY. Otherwise, it will remain idle.
Parameter Type Description
IN_PREC Integer Input bit precision feeding into the square root macro
OUT_PREC Integer Output bit precision from the square root macro
PIPELINE String This parameter controls the architecture of the square root macro. If set to "YES", it includes pipeline stages in the square root macro. If set to "NO", the square root macro becomes a single-cycle combinatorial function.

For more information on using this example, go to:

Design Examples Disclaimer

These design examples may only be used within Altera Corporation devices and remain the property of Altera. They are being provided on an “as-is” basis and as an accommodation; therefore, all warranties, representations, or guarantees of any kind (whether express, implied, or statutory) including, without limitation, warranties of merchantability, non-infringement, or fitness for a particular purpose, are specifically disclaimed. Altera expressly does not recommend, suggest, or require that these examples be used in combination with any other product not provided by Altera.

  请填写反馈意见