Docsity

Behavioral Simulation & Hardware Testing of Floating Point Operators & Motion Control IP, Assignments of History

Partial preview of the text

Download Behavioral Simulation & Hardware Testing of Floating Point Operators & Motion Control IP and more Assignments History in PDF only on Docsity!

A Library of IP Cores for FPGA based

Motion Control using Floating Point

Arithmetic

A Thesis Submitted

in Partial Fulfillment of the Requirements

for the Degree of

Master of Technology

by

Ruchi Srivastava (Y8104054)

to the

Department of Electrical Engineering

Indian Institute of Technology Kanpur

June 2010

Certificate

This is to certify that that the work contained in the thesis titled " A library of IP Cores for FPGA based Motion Control using Floating Point Arithmetic" by Ruchi Srivastava (Y8104054) has been carried out under my supervision and this work has not been submitted elsewhere for any degree.

Professor^ (Dr.S~hi)^ 113/6/;-

Department of Electrical Engineering Indian Institute of Technology Kanpur, India

lIT Kanpur June, 2010

Table of Contents

  • List of Figures
  • List of Tables
  • Abbreviations
  • Chapter-1
  • Introduction
    • 1.1 Motivation
    • 1.2 Objective
    • 1.3 Organization
    • 1.4 Basic Information
      • 1.4.1 FPGA
      • 1.4.2 VHDL
      • 1.4.3 Motion Control System
      • 1.4.4 Floating Point Numbers
  • Chapter-2
  • Floating Point Library
    • 2.1 Floating Point Arithmetic Operators
    • 2.2 Common Design Features
    • 2.3 Floating Point Multiplier
      • 2.3.1 Algorithm & Design
      • 2.3.2 Implementation
    • 2.4 Floating Point Adder
      • 2.4.1 Algorithm & Design
      • 2.4.2 Implementation
    • 2.5 Floating Point Square-root Operator
      • 2.5.1 Algorithm & Design
      • 2.5.2 Implementation
    • 2.6 Synthesis and Test Results
  • Chapter-3
  • Motion Control IP Cores Library
    • 3.1 FPGA based position control loop
    • 3.2 Library Elements
    • 3.3 Bi-Quad Core
      • 3.3.1 Bi-Quad Core Implementation
    • 3.4 PID Controller Core
      • 3.4.1 PID Core Implementation
      • 3.5.1 Requirement
      • 3.5.2 Method
      • 3.5.2 Oscillator Core Implementation
      • 3.6.1 Requirement
      • 3.6.2 Demodulation Method
      • 3.6.3 PSD Core Implementation
  • Chapter-4
  • Design Verification and Test Results
    • 4.1 Synthesis Results
      • 4.1.1 Resource utilization
      • 4.1.2 Speed
    • 4.2 Behavioral Simulation & Hardware Testing...............................................................
      • 4.2.1 Test Setup
      • 4.2.2 Testing of FP operators
      • 4.2.3 Testing of Motion Control IP Cores
  • Chapter-5
  • Conclusions and Future Work
    • 5.1 Achievements
    • 5.2 Future work
  • References
  • Appendix-A
    • A.1 Intellectual Property (IP) Core
    • A.2 Digital Filters............................................................................................................
  • Appendix-B
    • B.1 Test Results of FP Multiplier
    • B.2 Test Results of FP Adder
    • B.3 Test Results of FP Square-root Operator
  • Fig.1.1 : Generic architecture of an FPGA …………………………………………………. List of Figures
  • Fig.1.2 : Summary of VHDL Design Flow…………………………………………………..
  • Fig.1.3 : Representation of a Typical Motion/Servo Control System………………………..
  • Fig.1.4 : Arrangement of bits in single precision Floating Point format…………………….
  • Fig.2.1 : FP Multiplier – Top Level Block Diagram………………………………………....
  • Fig.2.2(a) : FP Multiplier Pipe Line stages and Data Flow………………………………….
  • Fig.2.2(b) : File structure of FP Multiplier Core…………………………………………….
  • Fig.2.3 : FP Adder –Top Level Block Diagram……………………………………………..
  • Fig.2.4(a) : FP Adder Pipe line stages and Data Flow……………………………………….
  • Fig.2.4(b) : File structure of FP Adder Core…………………………………………………
  • Fig.2.5 : FP Square Root Operator Top Level Block Diagram………………………………
  • Fig.2.6(a) : FP Square Root Operator Pipe Line Stages and Data Flow……………………..
  • Fig.2.6(b) : File structure of FP Square Root Operator Core………………………………...
  • Fig.3.1 : FPGA based position control loop………………………………………………….
  • Fig.3.2 : Bi-quad Structure…………………………………………………………………...
  • Fig.3.3 : Bi-quad Core Block Diagram & I/O mapping with Difference Equation………….
  • Fig.3.4 : PID Core Block Diagram & I/O mapping with Difference Equation………………
  • Fig.3.5 : Oscillator Core Block Diagram & I/O mapping with Difference Equation (DE)….
  • Fig.3.6 : PSD Core Block Diagram & I/O mapping with Difference Equation (DE)…….....
  • Fig.3.7(a) : Functionality of PSD Core………………………………………………………
  • Fig.3.7(b) : File Structure of PSD Core……………………………………………………...
  • Fig.3.8 : Accumulator Core Block Diagram & I/O mapping with Difference Equation…….
  • Fig.3.9 : RSS Core Block Diagram & I/O mapping with Difference Equation……………...
  • Fig.4.1 : The Test Set-up……………………………………………………………………..
  • Fig.4.2(a) : LPF Bode Magnitude Plot (As per Design Specifications)……………………..
  • Fig.4.2(b) : LPF Bode Magnitude Plot (Obtained from Test Results)………………………
  • Fig.4.3 : LPF Output Waveforms at 50Hz, 100Hz, 2.5kHz (clock-wise) & Gain Error……
  • Fig.4.4(a) : HPF Bode Magnitude Plot (As per Design Specifications)……………………..
  • Fig.4.4(b) : HPF Bode Magnitude Plot (Obtained from Test Results)………………………
  • Fig.4.5 : HPF Output Waveforms at 10Hz, 100Hz, 2kHz (clock-wise) & Gain Error……...
  • Fig.4.6(a) : BPF Bode Magnitude Plot (As per Design Specifications)……………………..
  • Fig.4.6(b) : BPF Bode Magnitude Plot (Obtained from Test Results)………………………
  • Fig.4.7 : BPF Output Waveforms at 50Hz, 500Hz, 5kHz (clock-wise) & Gain Error……..
  • Fig.4.8(a) : BRF Bode Magnitude Plot (As per Design Specifications)…………………….
  • Fig.4.8(b) : BRF Bode Magnitude Plot (Obtained from Test Results)……………………..
  • Fig.4.9 : BRF Output Waveforms at 50Hz, 500Hz, 5kHz (clock-wise) & Gain Error……..
  • Fig.4.10 : Simulink Model of PID Controller……………………………………………….
  • Fig.4.11(a) : Simulink Model Response for PID Controller (Test Case #1)………………..
  • Fig.4.11(b) : Modelsim Simulation Results for PID Controller (Test Case #1)…………….
  • Fig.4.11(c) : Test Results for PID Controller (Test Case #1)………………………………..
  • Fig.4.12(a) : Simulink Model Response for PD Controller (Test Case #2)…………………
  • Fig.4.12(b) : Modelsim Simulation Results for PD Controller (Test Case #2)……………..
  • Fig.4.12(c) : Test Results for PD Controller (Test Case #2)………………………………..
  • Fig.4.13(a) : Simulink Model Response for PI Controller (Test Case #3)………………….
  • Fig.4.13(b) : Modelsim Simulation Results for PI Controller (Test Case #3)………………
  • Fig.4.13(c) : Test Results for PI Controller (Test Case #3)………………………………….
  • Fig.4.14 : Quadrature Phase Relation between Sine and Cos for different frequencies….…
  • Fig.4.15 : Performance of PSD Core for sinusoidal modulating input (0.1V, 100 Hz)……..
  • Fig.4.16 : Performance of PSD Core for a modulating input of constant amplitude of 1V…
  • Table 1.1 : Special Numbers…………………………………………………………..…….. List of Tables
  • Table 2.1 : Exception Handling……………………………………………………………...
  • Table 3.1 : Bi-Quad Core State Description………………………………..………………..
  • Table 3.2 : PID Core State Description…………………………………………...………….
  • Table 3.3 : Oscillator Core State Description…………………………………………..……
  • Table 3.4 : PSD Core State Description……………………………………………………..
  • Table 3.5 : Accumulator Core State Description…………………………………………….
  • Table 3.6 : RSS Core State Description……………………………………………………...
  • Table 4.1 : Resource Utilization for FP Operators…………………………………………...
  • Table 4.2 : Resource Utilization of Motion Control IP Cores……………………………….
  • Table 4.3 : Post PAR Timing analysis for FP Operators…………………………………….
  • Table 4.4 : Post PAR Timing details of Motion Control IP Cores…………………………..
  • Table 4.5 : Filter Transfer Function………………………………………………………….
  • Table 4.6 : Filter Coefficients………………………………………………………………..
  • Table 4.7 : LPF Performance………………………………………………………………...
  • Table 4.8 : LPF - Gain Error…………………………………………………………………
  • Table 4.9 : HPF Performance………………………………………………………………..
  • Table 4.10 : HPF - Gain Error……………………………………………………………….
  • Table 4.11 : BPF - Frequency Error…………………………………………………………
  • Table 4.12 : BPF - Gain Error……………………………………………………………….
  • Table 4.13 : BRF - Frequency Error…………………………………………………………
  • Table 4.14 : BRF - Gain Error……………………………………………………………….
  • Table 4.15 : PID Core Input Coefficients……………………………………………………
  • Table 4.16 : PID Core Performance………………………………………………………….
  • Table 4.16(a) : Amplitude Error……………………………………………………………..
  • Table 4.16(b) : Frequency Error……………………………………………………………..
  • Table 4.16(c) : Quadrature Phase Error……………………………………………………...
  • Table 4.17 : PSD Core Performance…………………………………………………………

Abstract

Programmable Logic Devices such as Field Programmable Gate Arrays (FPGAs) are being considered by increasing number of designers in various fields of application such as telecommunication, video, signal processing and motor control systems. FPGAs have the potential of enabling both software as well as hardware customization as per design needs. They are re-configurable in nature; improve control system performance by supporting faster execution rates and offer reliability of a dedicated hardware circuitry.

The concept of ‗IP cores‘ and re-usable designs can considerably reduce the development time, effort and cost. Leading FPGA vendors are offering IP cores in parameterized form which is not editable as the HDL code is usually not available. Whereas multiple IP libraries are available related to applications like signal processing, telecommunication and industrial bus interfaces etc. but a library specifically developed to cater to the need of motion control applications is not available.

The present work attempts to fill this gap. The focus is on developing a library of IP cores, written in editable HDL format, for essential basic elements of motion control system. The cores use floating point arithmetic for greater precision and accuracy which becomes important when precise control or precise positioning of poles/zeros is required. The floating point operators are also written in HDL format to make the cores portable across different platforms, technologies and foundries. The standard IEEE binary single precision floating point format is followed and the standard VHDL language is used to describe the code.

The design was carried out using Xilinx ISE Design Suite 11.3 and synthesized using XST synthesis tool offered by Xilinx. Behavioral simulations were carried out using ModelSim SE-64 6.4b and algorithms were evaluated using MATLAB R2008a. Finally, the design was validated on Spartan-3E FPGA (xc3s500e-4fg320) using Spatan-3E starter hardware kit.

Abbreviations

ASIC Application Specific Integrated Circuit Bi-quad Bi-quadratic BPF Band Pass Filter BRF Band Reject Filter CAD Computer Aid Design CLB Configurable Logic Block DAC Digital to Analog Converter DE Difference Equation DSP Digital Signal Processor FFT Fast Fourier Transform FIR Finite Impulse Response FP Floating Point FP format Single Precision Binary FP format as per IEEE 754 (2008) Standard FPGA Field Programmable Gate Array HDL Hardware Description Language HPF High Pass Filter IIR Infinite Impulse Response I/O Input/Output IOB Input Output Block IP Intellectual Property LPF Low Pass Filter LSB Least Significant Bit LUT Look Up Table LVDT Linear Variable Differential Transducer MSB Most Significand Bit MULT Multiplier NaN Not a Number NR Newton Raphson PAR Place And Route PD Proportional and Derivative PI Proportional and Integral PID Proportional Integral and Derivative PLD Programmable Logic Device

Chapter-

Introduction

1.1 Motivation

For years, industrial motor control applications used general-purpose electronic devices such as microcontrollers (MCUs) and DSPs. These devices are designed with fixed hardware, leaving software as the only method for designers to update designs. Such systems do not support any kind of hardware re-programming once the design is frozen. Programmable Logic Devices (PLDs) such as Field Programmable Gate Array (FPGA) can solve this problem by enabling both software and hardware customization as per the design needs. The term ―field programmable‖ means re-configuring the hardware for specific applications even after the product has been installed in the field. In addition to making design reconfigurable, FPGAs also improve the system performance and reliability.

FPGAs use dedicated hardware for processing logic and do not have an operating system. When a control application for an FPGA device is compiled, the result is a highly optimized silicon implementation that provides true parallel processing with the performance and reliability benefits of dedicated hardware circuitry. Since there is no operating system on the FPGA, the code is implemented in a way that ensures maximum performance and reliability.

In general, the speed of the control system impacts its performance, stability, robustness and disturbance rejection characteristics. Faster control systems are typically more stable, easier to tune, and less susceptible to changing conditions and disturbances. FPGA based implementation offers inherent parallelism of hardware which helps in achieving deterministic closed loop control at extremely fast loop rates in contrast to typical processor based designs which are slower due to their sequential nature.

Motion control systems often need precise control of certain variables or precise positioning of poles and zeros to achieve certain functionality. This makes the choice of arithmetic (either

fixed or floating point) very important before implementing the design. Fixed point arithmetic though easier to use, suffers with limited precision and limited dynamic range of data, therefore causing loss of precision. Floating point arithmetic involves exponents to represent the numbers and therefore supports greater dynamic range of data. Since, the data representation in floating point format is more exact, it ensures greater accuracy.

Implementation of floating point arithmetic is possible in FPGAs as their highly programmable and flexible nature does not bind them with any specific kind of arithmetic unlike some micro processors or DSPs which may or may not support floating point arithmetic.

In addition to re-programmability, FPGAs also support design re-usability which is a common feature of software programs. The concept of re-using pre-developed, fully tested unit of logic, commonly known as ‗Intellectual Property (IP) core‘, helps in rapid proto- typing. This in turn helps in cutting down the development cost, efforts and time.

The IP cores can reduce the development cost only when written using a standard hardware description language (HDL) such as VERILOG or VHDL and are available in soft form, which means the behavioral description of the core is available in HDL form and can be edited if required. The leading FPGA vendors like Xilinx or Altera provide IP cores in parameterized form which involves structural description of the core and allows only the parameters of the design to be changed before synthesis, but the HDL is usually not available. Such cores allow certain flexibility, but prohibit the use of the core with other FPGA vendors or ASIC foundries. This hampers the design portability, flexibility and cost effectiveness.

A review conducted by Dubey et.al.[1] and Monmasson et.al.[2] gives insight about the increasing use of PLDs in motion control. The idea of IP cores for motion control was mooted by Pimentel and Le-Huy [3], [4] and some commercial organizations [5] are now marketing motion-control specific cores, but none of them address the need of floating point arithmetic.

Refer Appendix-A which describes about IP cores in detail.

1.4 Basic Information

This section provides some basic information regarding FPGAs, HDL, floating point format and basic elements of a closed loop motion control system.

1.4.1 FPGA 1

Field Programmable Gate Arrays (FPGAs) belong to the wide family of programmable logic components. FPGAs can be defined as a matrix of configurable logic blocks (combinatorial and/or sequential), linked to each other by an interconnection network that is also entirely reprogrammable. Memory cells control the logic blocks as well as the connections so that the component can fulfill the required application specifications. Several configurable technologies exist. Among these, only those which are reprogrammable (Flash EPROM, SRAM) are of interest since they allow the same flexibility of a microprocessor. The generic architecture of this type of FPGA is presented in Fig. 1.

Fig. 1.1: Generic architecture of an FPGA [7]

(^1) Refer [7],[8]

This architecture is composed of a matrix of configurable logic blocks (CLBs), which is bordered by a ring of configurable input/output blocks (IOBs). Finally, all these resources communicate among themselves through a programmable interconnection network.

Some of the basic components in an FPGA are described below [8].

a) Configurable Logic Block (CLBs)

The CLB is the basic logic unit in an FPGA. Exact numbers and features vary from device to device, but every CLB consists of a configurable switch matrix with 4 or 6 inputs, some selection circuitry (MUX, etc.), and flip-flops. The switch matrix is highly flexible and can be configured to handle combinatorial logic, shift registers or RAM.

b) Interconnect

While the CLB provides the logic capability, flexible interconnect routing routes the signals between CLBs and to and from I/Os. Routing comes in several flavors, from that designed to interconnect between CLBs to fast horizontal and vertical long lines spanning the device to global low-skew routing for clocking and other global signals. The design software makes the interconnect routing task hidden to the user unless specified otherwise, thus significantly reducing design complexity.

c) Input/output Blocks (IOBs)

The Input /Output Block (IOB) provides a programmable, unidirectional or bidirectional interface between a package pin and the FPGA‘s internal logic. Each IOB supports bidirectional data flow plus 3-state operation. Today‘s FPGAs provide support for dozens of I/O standards thus providing the ideal interface bridge within a system. I/O in FPGAs is grouped in banks with each bank independently able to support different I/O standards.

1.4.2 VHDL^2

VHDL stands for V HSIC H ardware D escription L anguage. VHSIC is itself an abbreviation for Very High Speed Integrated Circuits. It is the original and first HDL to be standardized by

(^2) Refer [9], [10]

technology, which may not be known at the time of synthesis, or the temperature and process variations, which vary continuously.)

b) Design Flow 4

As mentioned above, one of the major utilities of VHDL is that it allows the synthesis of a circuit or system in a programmable device or in an ASIC. The steps followed during such a project are summarized in Fig. 1.2. The design is started by writing the VHDL code, which is saved in a file with the extension ‗ .vhd ‘ and the same name as its ENTITY‘s name. The first step in the synthesis process is compilation. Compilation is the conversion of the high-level VHDL language, which describes the circuit at the Register Transfer Level (RTL), into a net- list at the gate level. The second step is optimization, which is performed on the gate-level net-list for speed or for area. At this stage, the design can be simulated. Finally, a place-and- route (fitter) software will generate the physical layout for a PLD/FPGA chip or will generate the masks for an ASIC.

(^4) Refer [9]

Fig. 1.2 : Summary of VHDL Design Flow [9]

1.4.3 Motion Control System

Motion control (also referred to as servo control) is used in industrial processes to move a specific load in a controlled fashion. Definitions of motion control vary widely depending on the application. Motion control can refer to simple on-off control or a sequencing of events, controlling the speed of motor, moving objects from one point to another, or precisely constraining the speed, acceleration and position of a system throughout a move.

As shown in Fig. 1.3, in their simplest form electronic closed loop motion control systems consist of a controller, a motor, an amplifier to drive the motor and a sensor that monitors motion. [11]