FPGA course

来源:互联网 发布:tvb直播软件apk 编辑:程序博客网 时间:2024/05/22 06:42

This course is currently a work in progress, but aims to be a quick start for hobbyists new to using FPGAs.


Contents

 [hide]
  • 1 Now available in PDF
  • 2 Why learn to use FPGAs?
  • 3 What I want to do
  • 4 What will you learn?
  • 5 How to contact me
  • 6 Course prerequisites
  • 7 Modules
  • 8 A good free reference book
  • 9 A note to software-coder types
  • 10 Size of projects that are possible to implement in an FPGA
  • 11 Why VHDL?
  • 12 What development board am I basing a course around?

Now available in PDF

To tie in with the release of the GadgetFactory LogicStart Megawing (http://www.gadgetfactory.net/logicstart-megawing) I've migrated this whole project onto GitHub, and made it available in PDF form. To download the full PDF click on https://github.com/hamsternz/IntroToSpartanFPGABook/blob/master/IntroToSpartanFPGABook.pdf?raw=true

Contains all that is here and more, and covers both the Digilent Basys2 and Papilio One + LogicStart development boards. I have two proofreaders working their way though it, so it should be much improved.

Why learn to use FPGAs?

  • For electronics and microcontroller buffs, the programmable logic on an FPGA is the next step closer to "real hardware"
  • The interfacing possibilities are endless - with the right FPGA you can talk to pretty much anything (DVI,HDMI, Fibre Channel, LVDS)
  • Designing, prototyping and debugging of designs is fast. When compared to building complex designs with graph paper, discrete logic chips, breadboards and jumper wires the ability to change a high level design and press the "implement" button is magical
  • Designing and prototyping hardware is cheap - a mid-range laptop and an FPGA development board is all you need for designs that would cost thousands of dollars to build with discrete logic
  • Maybe this will inspire a person with far better ideas than me to create something really cool

What I want to do

I want to help hackers take the plunge, purchase an FPGA development board and get their first projects up and running.

What will you learn?

At the end of the modules you should have achieved the following:

  • Learnt a subset of VHDL, enough to complete most projects
  • Used the simulator to debug issues
  • Used all the components on a Spartan-3E FPGA
    • Logic blocks
    • Block RAM
    • Digital Clock Managers
    • 18x18 multipliers
  • Used nearly all the interfaces on the development board
    • Buttons & Switches
    • LEDs
    • VGA
    • Seven Segment display
    • A PMOD connector
    • PS/2 (although this interface is relatively complex to use)
    • Accessed a project on a FPGA over the USB host port
  • You will have built a few custom interfaces that are not on the board
    • Audio output
    • 3.3V TTL RS-232 to host

This should get you well on the way to implementing your own projects.

How to contact me

Email me at "nospam-hamster@snap.net.nz", after removing the "nospam-" bit. Any feedback is welcome!

Course prerequisites

Here's what I think are the skills required for somebody wanting to learn to program FPGAs:

  • Programming ability in a low level language (e.g. 'C' or assembler)
  • Familiarity with the basic boolean operations (AND, OR, NOT, XOR)
  • An understanding of number representations and binary math
  • Understanding of circuit schematics user in digital designs is very helpful
  • A PC equivalent to a current entry-level model running either Windows XP, Windows 7 or Linux (Dual core CPU with 2GB RAM, 20GB free disk)
  • A broadband connection with an internet plan that enables you to download the multi-GB design software
  • A little bit of microcontroller development experience is useful
  • Around US$79 + p&p to purchase an FPGA development board, and if you are 'no good with hardware' the recommended model is a Digilent Basys2 fromhttp://www.digilentinc.com/Products/Detail.cfm?Prod=BASYS2, as a lot of the projects focus on the eight slide switches and eight LEDs. If you would like do some soldering or can use a breadboard a Papilio One from http://www.papilio.cc/ is a great option.

Modules

Each module has a hands-on project, with the largest similar in size to Papilio S6/Fading counter. This should allow most modules to be completed in an hour.

ModuleTopicProjectModule 1Getting PreparedPurchasing your hardware, downloading and installing the development tools.Module 2Your first designWiring switches to LEDs and downloading your designModule 3Logic operationsImplementing AND, OR, NOT and other operationsModule 4BusesUsing more than one bit at a timeModule 5Binary mathAddition and subtractionModule 6CountingCreating counters and the first use of clock signalsModule 7Timing constraintsHow fast will a design go?Module 8Simulating designsCreating a test bench and running simulationsModule 9Modular designsBuilding a design with multiple componentsModule 10More complex interfacingUsing the seven segment display (if present)Module 11Video outputGenerating a VGA signal.Module 12Using on-chip memorySequencing light flashesModule 13Generating analogue signals in a digital worldBuilding a one-bit DAC to make soundsModule 14Introduction to finite state machinesCreating a combination lockModule 15Clock managementUsing the clock management resourcesModule 16Talking to a PCSending data down an RS232 connectionModule 17Receiving data from a PCReceiving data over a RS232 connectionModule 18Talking to a PC using vendor's APIUsing the vendor's API and librariesModule 19MultiplyingUsing the 18x18 multipliersModule 20Tri state logicAn after-thought

A good free reference book

Snag yourself a copy of "Free Range VHDL". Available at a web browser near you at http://www.freerangefactory.org/

A note to software-coder types

Your mind is presently wired to think about the flow of instructions in a process running in a memory space. It hurts to escape this! You will get horribly confused.

When you get confused, the things to remember are:

  • You are not writing a program.
  • You are designing something akin to a (Very Very Very Very)VLIW CPU that only has a single instruction.
  • Your design works as follows:
    • It has the current state stored in flip-flops and registers
    • It then computes the next state, based on inputs and current state.
    • When the clock ticks it then atomically stores this new state into the state vector.

And that is it - there are no loops (well, not in the sense you think of them now), no "do this then do that", there is no "flow" through the code - it is all concurrent. There is pretty much only one unit of time - a single tick of a clock signal.

It can be quite freaky at times!

The good thing is that as a result of this mind shift you will start thinking more 'superscalar', and the mental paradigm that you write your code in a closer match to the underlying hardware. You may find yourself changing a few small habits that will improve the quality of your code.

The HDL paradigm in a Spreadsheet

Size of projects that are possible to implement in an FPGA

A very low end FPGA board (e.g. the XC3S100 on Digilent's BASYS2-100 http://www.digilentinc.com/Products/Detail.cfm?Prod=BASYS2) is equivalent to approximately 100,000 logic gates - or 25,000 TTL logic chips. The largest FPGA in the same product range has 16 times as many logic elements with an equivalent gate count of 1,600,000 gates.

The easiest way to visualize this is to think in terms of solderless breadboards. A 40mm x 90mm breadboard can comfortably fit three 14 pin 7400 series TTL chips and associated wiring, making a small FPGA equivalent to something like a 4.0m x 7.2m array of breadboards, each populated with three TTL logic chips. This makes that large FPGA equivalent to nearly a basketball court full of breadboards!

This much logic allows you to implement pretty much any design you can envisage.

Why VHDL?

I find that the explicitness of VHDL makes it more explainable. I'm also from outside of the USA - where VHDL seems to be the de facto standard for research and industry.

I find Verilog code a bit like Perl. Sure it is quick to write but it feels very "fast an loose" - it is very hard to tell what the heck is going on.

But for the size of projects in this course use whatever language you like - it is more about the underlying concept than the code.

If you have any questions I can pretty much read either language.

What development board am I basing a course around?

Commercial FPGA boards are available from Digilent, Terasic and others, with prices from around US$80 (for a Terasic DE0-Nano) to maybe US$2,000 or more for a high end development board. For your extra money you not only get a larger and faster FPGA, but you also get RAM, Flash memory, Ethernet interface(s), Audio codecs, HDMI in/out and other goodies.

The low-cost Terasic DE0-nano has too few onboard interfaces to be fun to learn on, and although the Basys2-100 has a VGA connector, PS/2 plug, LEDs and switches the FPGA is too small for anything but the most basic projects - for example it only has a 9KB of on-chip RAM. The Basys2-250 is a bit better, with 24KB of on-chip RAM - which is enough to implement a small 8 bit computer or a Text mode VGA display. The next step up is something like the Terasic DE0 or Digilent Nexys2, at around US$149, which includes a few MB of RAM and Flash and are aimed at "system on programmable chip" users.

An inexpensive FPGA board is the US$50 Papilio One 250K from Gadget Factory (http://www.papilio.cc/index.php?n=Papilio.Hardware). If you are not adept with soldering you will also need something like an "Arcade Mega Wing" (http://www.papilio.cc/index.php?n=Papilio.ArcadeMegaWing) to allow plugging of standard peripherals such as a PS/2 keyboard or a VGA monitor, although a small amount of soldering may be still needed to install the headers.

I've decided on the Digilent Basys2 as my reference board - it has all the items needed to have useful projects, no soldering required, and costs under $100. Also I find that the Xilinx toolset is also very friendly for first time designers.

As I'm in New Zealand I ordered mine from their ANZ distributor - Black Box Consulting (http://www.blackboxconsulting.com.au/). They normally have everything in stock, so not only is it quicker than ordering from Digilent, the international shipping direct from Digilent is really, really, really high. Why is it you can get a Papilio FPGA board from Seeed Studios for $49.99 incl postage, but it costs US$36.66 to ship a $99 order from Digilent? Black Box Consulting charged a reasonable AU$10.00 for shipping.

NOTE: The BASYS2's on-board oscillator is not very stable - it may pay to get something like SGR-8002DC-PCC-ND from Digikey to provide a reference clock that is stable enough to the FPGA's Digital Clock managers to reliably latch on to. This is only required if you want to use frequencies other than the 100MHz, 50MHz or 25MHz that is on the board. The part number in the reference manual is wrong - it is a SMD part!

http://hamsterworks.co.nz/mediawiki/index.php/FPGA_course

原创粉丝点击