FPGAs for bits & giggles

Similar documents
FPGA Design. Part I - Hardware Components. Thomas Lenzi

FPGA Design with VHDL

Field Programmable Gate Arrays (FPGAs)

L12: Reconfigurable Logic Architectures

Why FPGAs? FPGA Overview. Why FPGAs?

L11/12: Reconfigurable Logic Architectures

RELATED WORK Integrated circuits and programmable devices

Laboratory 1 - Introduction to Digital Electronics and Lab Equipment (Logic Analyzers, Digital Oscilloscope, and FPGA-based Labkit)

EEM Digital Systems II

Reconfigurable Architectures. Greg Stitt ECE Department University of Florida

ENGG2410: Digital Design Lab 5: Modular Designs and Hierarchy Using VHDL

Combinational vs Sequential

Electrical and Telecommunications Engineering Technology_TCET3122/TC520. NEW YORK CITY COLLEGE OF TECHNOLOGY The City University of New York

Microprocessor Design

DIGITAL FUNDAMENTALS

CSE140L: Components and Design Techniques for Digital Systems Lab. CPU design and PLDs. Tajana Simunic Rosing. Source: Vahid, Katz

Chapter 7 Memory and Programmable Logic

CPS311 Lecture: Sequential Circuits

IE1204 Digital Design. F11: Programmable Logic, VHDL for Sequential Circuits. Masoumeh (Azin) Ebrahimi

We are here. Assembly Language. Processors Arithmetic Logic Units. Finite State Machines. Circuits Gates. Transistors

CDA 4253 FPGA System Design FPGA Architectures. Hao Zheng Dept of Comp Sci & Eng U of South Florida

IE1204 Digital Design F11: Programmable Logic, VHDL for Sequential Circuits

CSE140L: Components and Design Techniques for Digital Systems Lab. FSMs. Tajana Simunic Rosing. Source: Vahid, Katz

Objectives. Combinational logics Sequential logics Finite state machine Arithmetic circuits Datapath

CSCB58 - Lab 4. Prelab /3 Part I (in-lab) /1 Part II (in-lab) /1 Part III (in-lab) /2 TOTAL /8

CPE 200L LABORATORY 3: SEQUENTIAL LOGIC CIRCUITS UNIVERSITY OF NEVADA, LAS VEGAS GOALS: BACKGROUND: SR FLIP-FLOP/LATCH

Saving time & money with JTAG

Digital Circuits 4: Sequential Circuits

Step 1 - shaft decoder to generate clockwise/anticlockwise signals

Digital Systems Design

Rensselaer Polytechnic Institute Computer Hardware Design ECSE Report. Lab Three Xilinx Richards Controller and Logic Analyzer Laboratory

PHYSICS 5620 LAB 9 Basic Digital Circuits and Flip-Flops

6.3 Sequential Circuits (plus a few Combinational)

COE328 Course Outline. Fall 2007

VHDL Design and Implementation of FPGA Based Logic Analyzer: Work in Progress

March 13, :36 vra80334_appe Sheet number 1 Page number 893 black. appendix. Commercial Devices

CS8803: Advanced Digital Design for Embedded Hardware

Digital Electronics II 2016 Imperial College London Page 1 of 8

Computer Systems Architecture

COMP12111: Fundamentals of Computer Engineering

Modeling Latches and Flip-flops

Laboratory Exercise 7

The basic logic gates are the inverter (or NOT gate), the AND gate, the OR gate and the exclusive-or gate (XOR). If you put an inverter in front of

Individual Project Report

High Performance Carry Chains for FPGAs

Unit 11. Latches and Flip-Flops

Modeling Latches and Flip-flops

LFSRs as Functional Blocks in Wireless Applications Author: Stephen Lim and Andy Miller

1. Convert the decimal number to binary, octal, and hexadecimal.

Performance Evolution of 16 Bit Processor in FPGA using State Encoding Techniques

CSE Latches and Flip-flops Dr. Izadi. NOR gate property: A B Z Cross coupled NOR gates: S M S R Q M

Inside Digital Design Accompany Lab Manual

CHAPTER 4: Logic Circuits

Contents Circuits... 1

Synchronous Sequential Logic

Lecture 6: Simple and Complex Programmable Logic Devices. EE 3610 Digital Systems

Introduction to Digital Logic Missouri S&T University CPE 2210 Exam 3 Logistics

Programmable Logic Design I

Copyright 2011 by Enoch Hwang, Ph.D. and Global Specialties. All rights reserved. Printed in Taiwan.

Sequential Digital Design. Laboratory Manual. Experiment #3. Flip Flop Storage Elements

MUHAMMAD NAEEM LATIF MCS 3 RD SEMESTER KHANEWAL

FPGA Based Implementation of Convolutional Encoder- Viterbi Decoder Using Multiple Booting Technique

Solution to Digital Logic )What is the magnitude comparator? Design a logic circuit for 4 bit magnitude comparator and explain it,

CAD for VLSI Design - I Lecture 38. V. Kamakoti and Shankar Balachandran

Flip-flop and Registers

CSE115: Digital Design Lecture 23: Latches & Flip-Flops

NH 67, Karur Trichy Highways, Puliyur C.F, Karur District UNIT-III SEQUENTIAL CIRCUITS

Lab #10 Hexadecimal-to-Seven-Segment Decoder, 4-bit Adder-Subtractor and Shift Register. Fall 2017

Chapter. Synchronous Sequential Circuits

Lecture 2: Basic FPGA Fabric. James C. Hoe Department of ECE Carnegie Mellon University

Laboratory Exercise 7

HDL & High Level Synthesize (EEET 2035) Laboratory II Sequential Circuits with VHDL: DFF, Counter, TFF and Timer

Design and implementation (in VHDL) of a VGA Display and Light Sensor to run on the Nexys4DDR board Report and Signoff due Week 6 (October 4)

Slide Set 7. for ENEL 353 Fall Steve Norman, PhD, PEng. Electrical & Computer Engineering Schulich School of Engineering University of Calgary

S.K.P. Engineering College, Tiruvannamalai UNIT I

FPGA-BASED EDUCATIONAL LAB PLATFORM

Chapter 6. Flip-Flops and Simple Flip-Flop Applications

Design and Implementation of SOC VGA Controller Using Spartan-3E FPGA

Digital. Digital. Revision: v0.19 Date: : / 76

Chapter 4. Logic Design

Faculty of Electrical & Electronics Engineering BEE3233 Electronics System Design. Laboratory 3: Finite State Machine (FSM)

UNIT IV. Sequential circuit

Chapter Contents. Appendix A: Digital Logic. Some Definitions

9 Programmable Logic Devices

12-bit Wallace Tree Multiplier CMPEN 411 Final Report Matthew Poremba 5/1/2009

CHAPTER 4: Logic Circuits

Computer Architecture and Organization

Sequential Logic. Introduction to Computer Yung-Yu Chuang

Digital Fundamentals: A Systems Approach

Altera s Max+plus II Tutorial

Prototyping an ASIC with FPGAs. By Rafey Mahmud, FAE at Synplicity.

First Name Last Name November 10, 2009 CS-343 Exam 2

The reduction in the number of flip-flops in a sequential circuit is referred to as the state-reduction problem.

EECS150 - Digital Design Lecture 18 - Circuit Timing (2) In General...

Design and analysis of microcontroller system using AMBA- Lite bus

CS6201 UNIT I PART-A. Develop or build the following Boolean function with NAND gate F(x,y,z)=(1,2,3,5,7).

ECSE-323 Digital System Design. Datapath/Controller Lecture #1

CS/EE 6710 Digital VLSI Design CAD Assignment #3 Due Thursday September 21 st, 5:00pm

VHDL Upgrading of a TNT2 card

EE292: Fundamentals of ECE

Transcription:

FPGAs for bits & giggles (or, As much of a hacky guide to how FPGAs work and how to use them as will fit into 30-60 minutes ) Matt Evans Make, Hack, Void May 30, 2011 1 / 30

What is an FPGA? Definition Field-Programmable Gate Array A flexible logic device used in building digital electronic circuits A gate array is an array of generic digital logic that can be configured into many different designs. Fixed gate arrays exist: The ZX Spectrum s ULA was an early example. Here, field-programmable means it arrives from the factory blank, and the connections between gates are designed & configured by the designer/user. You do not actually have to be in a field, but they do work on farms as well. 2 / 30

What is an FPGA? (2) Ways of building digital electronic circuits include: Valves (Hot, unreliable, huge) Discrete transistors (Better, but still pretty huge) Silicon chips Mass-produced discrete logic, e.g. 74xxx-series logic (You ll need a lot of wire) Make your own custom silicon chip (Great! But you d better be a millionaire) Make your own ULA/Gate Array (You ll still need to make thousands) Buy a programmable mass-produced chip, and customise it (Cheap and good!) 3 / 30

What is an FPGA? (2) 2011-05-30 FPGAs for bits & giggles What is an FPGA? (2) Ways of building digital electronic circuits include: Valves (Hot, unreliable, huge) Discrete transistors (Better, but still pretty huge) Silicon chips Mass-produced discrete logic, e.g. 74xxx-series logic (You ll need a lot of wire) Make your own custom silicon chip (Great! But you d better be a millionaire) Make your own ULA/Gate Array (You ll still need to make thousands) Buy a programmable mass-produced chip, and customise it (Cheap and good!) Custom logic can solve probs microcontrollers can t; you can t use a microcontroller to bit-bang a PC bus.custom circuits tend to be faster than general circuits programmed to perform tasks.can design custom peripherals to interface to whatever you like, process whatever you like. BCD :-)

Programmable Logic Devices (PLDs) Mass-produced ( cheap) chips designed to be soft-configured by the designer. Programmable = configurable logic functions, not software-driven Device Era Capacity Cost Volatile PAL/PLA/GAL 1970s-1990s Low Low CPLD 1980s- Medium Low FPGA 1980s- High Medium Mostly Smaller PLDs often used for glue logic Larger PLDs often used for core datapath logic 5 / 30

Why use an FPGA? As a low-to-medium volume replacement for designing an ASC: Chip manufacture is v. expensive VLS design tools are v. expensive too! (e.g. $100K per person per year) Not worth it unless you ship a million! Xilinx/Altera/Lattice/etc. make FPGAs in high volumes FPGA unit cost lower than ASC for small to medium volumes FPGA design tools free (beer) or cheap (ish $3K) 6 / 30

Why else? Their reprogrammability opens up new uses! Excellent for prototyping future products (e.g. ARM/BM/ntel prototype new CPUs on FPGAs) FPGAs in the actual product Media equipment new firmware can implement new video processing/smoothing/scaling algorithms Fixing bugs in products Field upgrades/added features Reconfigurable computing (Hot research topic!) Fun and retrocomputing: pen Graphics Project (pen video card) Minimig (C= Amiga recreation) fpgaarcade.com (Retro arcade machines) opencores.org 7 / 30

Some example uses for FPGAs SG magesync PC card (Low requirements, lowish volume) My oscilloscope (First production run, not worth making an ASC yet) CERN s LHC detector/acquisition circuitry Jodrell Bank radio telescope SG Altix RASC (Supercomputing with algorithm-in-fpga accelerator) Crypto cruncher systems (Parallel brute-force work) Network switching (Reconfigure protocol support) 8 / 30

Some example uses for FPGAs 2011-05-30 FPGAs for bits & giggles Some example uses for FPGAs SG magesync PC card (Low requirements, lowish volume) My oscilloscope (First production run, not worth making an ASC yet) CERN s LHC detector/acquisition circuitry Jodrell Bank radio telescope SG Altix RASC (Supercomputing with algorithm-in-fpga accelerator) Crypto cruncher systems (Parallel brute-force work) Network switching (Reconfigure protocol support) 1. SG card: Low volume, low requirements, simple FPGA is cheap 2. LHC detectors: Hundreds of them, lowish-volume, massive parallel DSP 3. Jodrell Bank has custom DSP/receiver circuitry. Very low-volume... Maybe other telescopes to, too. 4. SG RASC: FPGA brick; an HPC application could move some of the algorithm into hardware which appeared in the shared-memory fabric, could stream data through it. 5. Even though absolute perf not as high as real silicon (x00mhz) can still process massive amounts of data by repeating the circuit 10x, 100x. (parallelism) 6. Low-med volume appliances, sometimes even high-value appliances (where flexibility outweighs cost), e.g. those requiring reconfiguration flexibility

How do they work? Several different vendors but most FPGAs have similar principles of operation: Matrix structure of Configurable Logic Blocks (s) Configurable interconnect between them Power up blank, configure from flash RM Very flexible / pads (LVTTL, LVDS, PC, HSTL, gigabit transceivers) Dedicated primitive blocks: Dual-port RAM, multipliers, etc. Clock distribution networks Regular delays Tools can analyse timing 10 / 30

How do they work? 2011-05-30 FPGAs for bits & giggles How do they work? Several different vendors but most FPGAs have similar principles of operation: Matrix structure of Configurable Logic Blocks (s) Configurable interconnect between them Power up blank, configure from flash RM Very flexible / pads (LVTTL, LVDS, PC, HSTL, gigabit transceivers) Dedicated primitive blocks: Dual-port RAM, multipliers, etc. Clock distribution networks Regular delays Tools can analyse timing 1. This talk is Xilinx-centric! Principles are common though. 2. s perform the logic functions, contain flip-flops (STRAGE) 3. Some have internal flash, others external RM chips, can upload from host processor too. 4. Excellent interfacing possibilities; can drive fast buses (e.g. video panels, PC) even with modest FPGAs. With more exotic you can do PCe, multi-gigabit ethernet, etc. 5. n ASC you d make custom blocks; either impossible or v. inefficient to make with s so vendors usually have dedicated primitives scattered around. FASTER, SMALLER. 6. Talk about regular (well-characterised) propagation delays, setup/hold times on latches; tools will tell you how fast you can run your design. R specify constraints.

FPGA chip structure in Lego TM * R A M Clocks * R A M * R A M * R A M 12 / 30

R Xilinx Spartan3E detail (Stolen from the Spartan3E datasheet) Functional Descrip WS D 13 / 30

. R DS312-2 (v3.6) May 29, 2007 Product Specification WS WF[4:1] D D D www.xilinx.com DS312-2_32_042007 Notes: 1. ptions to invert signal polarity as well as other options that enable lines for various functions are not shown. 2. The index i can be 6, 7, or 8, depending on the slice. The upper SLCEL has an F8MUX, and the upper SLCEM has an F7MUX. The lower SLCEL and SLCEM both have an F6MUX. 2011-05-30 FPGAs for bits & giggles Xilinx Spartan3E detail Xilinx Spartan3E detail (Stolen from the Spartan3E datasheet) Functional Descrip 1. Will cover functions later LUT = output function of the inputs 2. LUTs 4-input here, each has 4x4input LUTs, 2 latches 3. Contemporary Spartan6/Virtex7 has 6 input LUTs 4. Wakes up blank bitstream configures operation Figure 15: Simplified Diagram of the Left-Hand SLCEM

. R Xilinx Spartan 3E bird s eye view Functional Description WS D D D WF[4:1] DS312-2_32_042007 15 / 30

Xilinx FPGA features ver time, more specialised functional blocks have been added: Family BRAM DSP PCe MemCtrl Gigabit Spartan Spartan-2E Spartan-3E Virtex-4 Virtex-5 Spartan-6 More new features: ADCs, PowerPC & ARM Cortex CPU cores/socs 16 / 30

K, so how do you do stuff? 1. Find your FPGA hardware (e.g. starter kit) 2. Sketch your design on paper. Do not just start hacking! :-) 3. Describe logic in: Verilog VHDL Schematic 4. Simulate, simulate, simulate, go to step 2 5. Xilinx Webpack SE used to build bitstream : Verilog/VHDL compiled; functions inferred (e.g. adders, multipliers, RAM) UCF file maps physical pins to signal names Logic Place And Routed, mapped to target device Final layout condensed into configuration bitstream 6. Program FPGA in-situ. Finish, rejoice, or go to step 2 :-) 17 / 30

Let s make something Quick example of designing something with: Spartan-3 Starter Board Verilog Xilinx s free Webpack SE design software (on x86 Linux!) verilog simulator & GTKWave...and a very short course on digital logic design :-) This won t be a complete course in Verilog because: 1. There isn t time 2. don t know all of Verilog :-) 18 / 30

MHV201: Combinatorial logic Class of logic where a boolean function on a set of signals produces another set of signals. No storage (latches/flip-flops), only logic gates. Example: Decode a 4-bit BCD digit (0-9) into 7 segment signals for an LED display a bit3 0 bit2 0 bit1 1 bit0 0 R AND XNR NAND a b c d e f g f e g b c d 19 / 30

MHV201: Combinatorial logic 7 segment decoder truth table: in[3:0] a b c d e f g 0000 1 1 1 1 1 1 0 0001 0 1 1 0 0 0 0 0010 1 1 0 1 1 0 1 0011 1 1 1 1 0 0 1 0100 0 1 1 0 0 1 1 0101 1 0 1 1 0 1 1 0110 1 0 1 1 1 1 1 0111 1 1 1 0 0 0 0 1000 1 1 1 1 1 1 1 1001 1 1 1 1 0 1 1 For each output, minimise equations with a Karnaugh map... seg a = in[3] + in[1].in[3] + in[0].in[2] + in[2].in[0]...and draw schematic: b3,b2,b1,b0 AND AND AND R seg_a 20 / 30

MHV201: Combinatorial logic in Verilog Ha! Verilog makes this much easier. The language describes wires, registers (later) and the connections between them. Modular hierarchy: define something then instantiate it N times Performs logic minimisation Can infer Xilinx primitives (e.g. multiply) Used for both hardware description ( RTL ) and test harness/general programming language ( behavioural Verilog ) 21 / 30

Verilog: 7-segment decoder See sources/bcd to 7seg.v, and simulate it with test harness tb/tb 7seg.v 22 / 30

MHV201: Sequential logic (state machines) n a (usually) rising edge of the system clock, a flip-flop can grab its inputs and hold them until told to do it again. A simple counter can be made by combining an incrementer (combinatorial) with flipflops, in a loop: When En=1, ut = 0000, 0001, 0010, 0011... 1110, 1111, 0000 0001 + D Q En ut CLK This is a state machine; it goes through a number of states with well-defined transitions between them. 23 / 30

When En=1, ut = 0000, 0001, 0010, 0011... 1110, 1111, 0000 0001 + D Q En CLK ut MHV201: Sequential logic (state machines) 2011-05-30 FPGAs for bits & giggles MHV201: Sequential logic (state machines) n a (usually) rising edge of the system clock, a flip-flop can grab its inputs and hold them until told to do it again. A simple counter can be made by combining an incrementer (combinatorial) with flipflops, in a loop: This is a state machine; it goes through a number of states with well-defined transitions between them. 1. A flipflop has an enable input. When the enable input goes to 1, the flip flop will LATER latch its input at the next clock edge. (Not at the enable edge!) When it s 0, the flip flop holds its output indefinitely. 2. Haven t said much about the clock so far, but the most common design style is synchronous, where every change of flip flop state is referenced to a common global clock signal.

Verilog: Count to ten See sources/counter.v, and resulting GTKWave! 25 / 30

Build a counter thingy We can put the two together to make the S3 board count to 100, ZMGZ! To make it more interesting (!), we ll have two counters for units & tens, and a carry between them. ther features: The 7-segment LED displays are multiplexed on the S3 board, so we have to alternate between digits quickly. Debounce a button input, to count just once when it s pressed. 26 / 30

Counter thingy AND En counter BCD[3:0] 7seg decoder carry out debouncer En counter BCD[3:0] 7seg decoder 0 1 NT 27 / 30

debouncer AND En carry out En counter counter BCD[3:0] BCD[3:0] 7seg decoder 7seg decoder NT 0 1 Counter thingy FPGAs for bits & giggles 2011-05-30 Counter thingy 1. Clock/reset are not shown on the diagram 2. Button input is all over the place; the debouncer creates a pulse one clock wide when the button is pressed, enabling the counters 3. When the bottom counter gets to 9, its carry out output goes to 1 signalling that next time it s enabled & clocked it will roll over. 4. f the set of counters is enabled and carryout is present, the upper counter is enabled to catch the roll-over from the bottom counter. 5. The LED displays are driven by simply switching the output between digits 0 and 1 (whilst enabling digit 0 or 1) fairly quickly. PV.

Counter thingy (2) See sources/top level.v and simulation with tb/tb toplevel.v Then, we can compile with SE and download via JTAG to the board. Then enjoy the new toy. 29 / 30

Links verilog simulator: http://iverilog.icarus.com/ GTKWave viewer for sim traces: http://gtkwave.sourceforge.net/ Xilinx s/w (free reg. required): http://www.xilinx.com/support/download/index.htm pencores, sourceforge for hardware : http://opencores.org/ FPGA arcade machine builds: http://fpgaarcade.com/ Projects, tutorials: http://fpga4fun.com/ 30 / 30