Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology...

55
Introduction to FPGA technology and programmable logic FYS4220/9220 Reading: chapter 1 in Zwolinski J. K. Bekkeng, 3.7.2011 Lecture #1

Transcript of Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology...

Page 1: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Introduction to FPGA technology

and programmable logic

FYS4220/9220

Reading: chapter 1 in ZwolinskiJ. K. Bekkeng, 3.7.2011

Lecture #1

Page 2: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Lecturer

Jan Kenneth Bekkeng (Senior Scientist FFI, Ass. prof-II

UIO)

Email: – j.k.bekkeng[at]fys.uio.no

Sounding rockets

T&E

Page 3: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Goals

Learn digital design using programmable logic

circuits (FPGA and CPLD)– Circuits

– Design tools

– Design methods

Learn VHDL to program hardware (FPGAs and

CPLDs) for use in e.g. embedded systems

Page 4: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Curriculum (VHDL & FPGA part)

Lectures (and other handout material)

Laboratory exercises

Textbook:– Digital System Design with VHDL, 2nd Edition (by Mark Zwolinski)

The textbook readings complement

the lectures!

Page 5: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Laboratory exercises

Lab 1:

– Switches, LEDs, counters, debouncer, testbenches

Lab 2:

– Use of components and packages, LPMs, FSM (vending machine)

Lab 3:

– Control of ADC (state machine), timing

Lab 4: Mandatory for PhD students only

– NIOS II processor in FPGA (other projects may be possible)

Altera Laboratory Exercises

Page 6: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Laboratory exercises

Room V442, Physics building

Teaching assistant available from 10.15 to 14.00 for guidance

on the lab days

Lab availability (without guidance):

– The lab at V442 is available Monday - Friday

Read the lab text and the corresponding manuals, and try to

find solutions before you come to the lab.

All mandatory labs (3 labs for FYS4220, 4 labs for FYS9220)

must be approved in order to take the exam

– All labs must be approved before 1. December

Note that Quartus II Web Edition and

Modelsim-Altera Starter Edition software

can be downloaded for free from the

Altera web page: Altera Free software

Page 7: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Other Recommended books for

VHDL

The Designer's Guide to VHDL, Volume 3, Third

Edition (by Peter J. Ashenden)

Page 8: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

What is an embedded system?

“An embedded system is designed to perform one

or a few dedicated functions .

Often has real-time computing constraints.

By contrast, a general-purpose computer, such as a

personal computer (PC), is designed to be flexible

and to meet a wide range of end-user needs.

Embedded systems are controlled by one or more

main processing cores that are typically either

microcontrollers, digital signal processors (DSP) or

FPGAs

Page 9: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Examples of ”embedded systems”

MP3 player

Digital camera

Washing machine

GPS mottaker

Blu-ray / DVD player

Page 10: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Examples of FPGA use

Aerospace

Defence

Medicine

Imaging / Image processing

Digital signal processing

ASIC prototyping

Software defined Radio

Software defined GPS

Pico satellite (OBC)

Air-to-Air missile

NSM

Page 11: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Page 12: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

What is an FPGA?

FPGA = Field Programmable Gate Array

Logic Array Blocks (LABs)– Each LAB contains a given number of Logic Elements (LE)

Page 13: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Cyclone II LE

Page 14: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Cyclone II Family Summary

Page 15: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Altera circuit families

Page 16: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

FPGA advantages

High reliability

High determinism

High performance

True parallelism

Reconfigurability

FPGAs in DAQ-systems (”intelligent DAQ”)

DAQ-cards with a programmable FPGA

Multi-rate sampling

User defined processing in the FPGA

FPGA based hardware timing/synchronization

NI R-series FPGA DAQ

DAQ = Data Acquisition

Page 17: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Examples on use of FPGAs

High-speed control

Intelligent DAQ

Digital communication protocols

Sensor simulation

Onboard processing and data reduction

Co-processing

Hardware In the Loop (HIL)-testing

Page 18: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Why use FPGA in an embedded

system?

Develop a low cost DSP system

Scalability

System integration (system on chip)

True parallelism

Many I/O (Input/Output) lines

Note: All Altera IP’s can be used free of charge for universities!

DSP = Digital Signal Processor

Page 19: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

System Integration – System On a

Chip (SOC)

Replace several DSP’s with a single chip

Integrate several different system components on a single chip

A circuit design demanding e.g.10 FPGAs a few years ago can no fit into a single FPGA

DSP Processor

General

Purpose

Processor

FPGA

Custom

Interface

Logic

DSP LogicNios

Processor

Custom

Interface

Logic

Spare gates

SOPC

Page 20: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Ex: Inertial Reference Unit

(IRU)Roll (X)

Pitch (Y)Yaw (Z)

Roll

Page 21: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

IRU PCBs

Roll PCB Pitch /Yaw PCB

DAQ PCB Power & I/O PCB

FPGA

Page 22: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Development kit used in the lab

Page 23: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Programmable logic

FPGA

CPLD

Circuit manufacturers:– Altera (www.altera.com)

– Xilinx (www.xilinx.com)

Tools:– QUARTUS II (Altera)

– Modelsim Altera (Mentor VHDL simulator)

– NIOS II Embedded design suite (+ C2H compiler)

– DSP builder (Altera)

– ISE (Xilinx)

CPLDFPGA

Flash

Page 24: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Design using FPGA/CPLD

Page 25: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Examples of programming

languages for programmable logic

VHDL

SystemC

Handel-C

Verilog (mainly used for ASICs, VHDL is better for

FPGAs)

Schematic tools (e.g. in Quartus II)

Page 26: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Page 27: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics27

IP Integration

Altera System-Level Design Tools

Software

Development

System

Integration

DSP Algorithm

Development

SOPC = System-On-a-Programmable-Chip

Page 28: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Altera DSP Builder

Interface between Quartus II (Altera) and MATLAB/Simulink (Mathworks)

Library Add On to Simulink

Automatic Generation of VHDL design From a MATLAB/Simulink Representation

Creates HDL Code

Page 29: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Automatic code generation

Page 30: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Automatic code generation

Page 31: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

LabVIEW FPGA

LabVIEW from National Instrument (NI) can be used to

program (graphically) NI’s RIO (RIO = Reconfigurable

I/O) cards

Requires license on NI LabVIEW and NI FPGA Module

Can write/import VHDL code

Page 32: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Circuit technologies

Programmable logic device (PLD):

Simple Programmable Logic Device (SPLD)

Complex Programmable Logic Devices (CPLD)

Field Programmable Gate Array (FPGA)

Application Specific Integrated Circuit (ASICs)

System On Chip (SoC)

Page 33: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

When to use FPGAs / CPLDs

Usually the first choice for digital logic, except for:

– Very simple designs

– Large production volumes (ASIC better)

– Very complex designs

• e.g. mixed signal (analog and digital on the same chip)

• Very high speed or need for very low power

consumption

Can replace microcontrollers in designs with:

– A demand for many I/O lines

– Need for flexible I/O

– Requirements for parallel processing /fast processing

– High requirements on timing/triggering

Page 34: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

The difference between a

processor and programmable

logic

A processor is programmed with instructions

A programmable logic circuit is programmed with a

circuit description

A programmable logic circuit contains configurable

blocks with logics and configurable connection lines

between these blocks

Page 35: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Programmable logic

Page 36: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

CPLD - Complex

Programmable Logic Device

Programming technology: non-volatile memory, such

as EEPROM or FLASH.– Configuration stored in the circuit (even without power)

– High voltage (EEPROM) or logic voltage (FLASH)

Used in ”small and medium size” designs

Circuit family example: MAX II from Altera– Up to 1270 LE

Page 37: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Page 38: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

FPGA - Field Programmable

Gate Array

Typically contains more logic then a CPLD

Have many flip-flops (memory elements)

Circuit examples:– Virtex-series (Xilinx)

– Cyclone and Stratix-series (Altera)

– Stratix V: 28 nm technologi, > 106 LE

Programming technology: usually static memory

(SRAM)– Needs an external configuration circuit with a non-volatile memory

(based on EEPROM/FLASH) which loads the configuration into

the FPGA at power on.

– SRAM memory inside the FPGA stores the circuit configuration

(when the power is on).

FPGA

Flash

Page 39: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Page 40: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Additional support in modern

FPGAs

On-chip memory, e.g. RAM blocks – dual port RAM -> can read and write the RAM in the same clock

cycle

Processor cores (floating point operations possible)

DSP blocks (floating point operations possible)

Multiplier blocks

High speed input/output blocks

PLL (Phase locked loop)

DLL (Delay locked loop)

Intellectual Property (IP)– E.g. FFT, UART

Page 41: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

FPGA vs ASIC

ASIC = Application Specific Integrated Circuit– circuits that are fabricated in a silicon foundry

FPGA advantages – Dramatically reduce the cost of errors (by reprogramming)

– Much cheaper than an ASIC for small volumes

FPGA disadvantages (compared to ASICs)– Lower performance (due to overhead of programmability)

– Higher power consumption

– Same logic requires a lager chip area

Page 42: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Fast calculations – DSP blocks

Page 43: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Reduction of power consumption

Page 44: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Reduction of power consumption

Page 45: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Processor cores in FPGA

Processor cores inside the FPGA

Many designs need a processor, and it is possible to

avoid an external processor chip

Soft core CPU – Programmable logic in the FPGA is used to implement a processor

(when needed) together with other functionality

Hard core CPU – The processor is implemented in the FPGA at the production of the

circuit

Xilinx processor cores for FPGA– Power PC (hard core processor)

– MicroBlaze (soft core processor)

Altera processor core for FPGA– NIOS II (soft core processor)

Page 46: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Soft core processor

Pros:

– Include the processor core only when.

– The number of cores is flexible.

– Can reuse the design in newer generations of

FPGAs in the future.

Cons:

– Slower and simpler than hard processor cores.

– Less area efficient compared to hard cores.

Page 47: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Hardware vs Software

Hardware (digital logic):

– Time critical parts

Software (on the CPU):

– Less time critical parts.

– Interface (Ethernet, RS232, USB, Wi-Fi, etc.)

– Code that normally would have been executed on an external

processor.

Nios II C-to-Hardware Acceleration Compiler (C2H)– “boosts the performance of your time-critical ANSI C functions by

converting them into hardware accelerators in the FPGA”.

– “tool for software engineers who need to increase the performance

of their embedded software applications.”

Page 48: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Intellectual Properties - IPs

With today's large FPGA designs it is almost

impossible to design everything from scratch.

Solution: Use already developed blocks for the parts

of the design where these are available. They are

called Intellectual Properties (IP).

IP types:

– made internally

– available from an FPGA manufacturer

– available from a third part supplier

Page 49: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Altera Embedded

processing

http://www.altera.com/technology/embedded/emb-

index.html

Page 50: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Embedded development tools

Page 51: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Some supported I/O standards

Page 52: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Page 53: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Page 54: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

How to simulate VHDL code

Testbench(stimuli/test input is made using VHDL code)

Waveforms (make a waveform input stimuli

”graphically”)

Page 55: Introduction to FPGA technology and programmable · PDF fileIntroduction to FPGA technology and programmable logic ... Programming technology: ... – circuits that are fabricated

Plasma and Space Physics

Examples of COTS

hardware for embedded systems

National Instruments PXI rack with FPGA-card(s)

and a real-time controller

CompactRIO from NI

BeMicro (from Altera)– Low cost ($49)

– Altera CycloneIII FPGA

– Altera NiosII embedded processor

18-slot PXI Express chassisNI R-series FPGA DAQController with

Windows and/or RT-OS

Real-time processor

and FPGA

COTS = commercial off-the-shelf