Table of Contents
Preface xi
Acknowledgments xiii
1 Logic 1
Logic Gates 1
The NOT Gate 2
The AND Gate 3
The OR Gate 3
NAND and NOR Gates 4
XOR Gates 5
Binary 6
Adding with Logic 7
Flip-Flops 9
Set-Reset Flip-Flop 9
Shift Registers 11
Binary Counters 12
Summary 12
2 FPGAs 13
How an FPGA Works 13
The Elbert 2 15
The Mojo 16
The Papilio 18
Software Setup 20
Installing ISE 20
Installing Elbert Software 22
Installing Mojo Software 23
Installing Papilio Software 24
Project Files 24
Summary 25
3 Drawing Logic 27
A Data Selector Example 27
Step 1 Create a New Project 28
Step 2 Create a New Schematic Source 31
Step 3 Add the Logic Symbols 33
Step 4 Connect the Gates 33
Step 5 Add the IO Markers 35
Step 6 Create a User Constraints File 36
Step 7 Generate the bit File 39
Step 8 Program Your Board 41
Testing the Result 41
A 4-Bit Counter Example 44
Drawing the Schematic 45
Implementation Constraints Files 46
Testing the Counter 48
Summary 48
4 Introducing Verilog 49
Modules 49
Wires, Registers, and Buses 50
Parallel Execution 50
Number Format 50
Data Selector in Verilog 51
A Counter in Verilog 55
Synchronous Logic 58
Summary 58
5 Modular Verilog 59
A Seven-Segment Decoder 60
Button Debouncing 63
Multiplexed Seven-Segment Display and Counter 69
Project Structure 70
Display_7_seg 72
Counter_7_seg 74
User Constraints File 77
Importing Source Code for Modules 77
Setting the Top-Level Module 78
The Three-Digit Version 79
Testing 79
Summary 79
6 Timer Example 81
State Machines 81
State Machine Design 83
Hardware 84
You Will Need 84
Construction 84
Modules 86
User Constraints File 87
The Timer Module 88
Inputs and Outputs 88
Push Buttons 88
Alarm Module Instance 88
Modeling Time and the Display 89
State Machine Implementation 89
Tasks 91
Testing 94
Summary 94
7 PWM and Servomotors 95
Pulse-Width Modulation 95
A PWM Module 96
PWM Module Inputs and Outputs 96
A Tester of the PWM Module 97
Trying It Out 99
Servomotors 100
Hardware 101
You Will Need 101
Construction 101
A Servo Module 104
Summary 107
8 Audio 109
Simple Tone Generation 109
Audio Output from the Mojo 110
A General-Purpose Tone/Frequency Generator 111
The Tone Module 112
The tone_tester Module 113
Testing 114
Playing an Audio File 114
Audio Files 116
RAM 117
The wav_player Module 118
Testing 120
Preparing Your Own Sounds 121
Summary 123
9 Video 125
VGA 125
VGA Timings 128
Drawing Rectangles 129
A VGA Module 130
VGA and the Elbert 2 133
Making Things Move 134
A Memory-Mapped Display 136
Preparing an Image 138
Summary 139
10 What Next 141
Simulation 141
Under the Hood 141
Cores and Soft Processors 143
More on the Papilio 144
More on the Mojo 146
Summary 146
A Resources 149
Buying FPGA Boards 149
Components 149
Other FPGA Boards 150
Web Resources 151
B Elbert 2 Reference 153
ISE New Project Settings 153
Prototype Net Mapping 153
LEDs 153
Three-Digit Display 154
DIP Slide Switches 155
Push Switches 155
VGA 156
Audio and Micro-SD 157
GPIO Pins 158
Header P1 158
Header P6 158
Header P2 159
Header P4 159
Clock 159
C Mojo Reference 161
ISE New Project Settings 161
NET Mapping (IO Shield) 161
LEDs 161
Four-Digit Display 162
Slide Switches 164
Push Buttons 165
Clock Pin 165
Complete UCF for IO Shield 165
D Papilio One Reference 167
ISE New Project Settings 167
LogicStart MegaWing NET Mapping 167
LEDs 168
Four-Digit Display 168
DIP Slide Switches 169
Joystick Switches 169
VGA 170
Audio 171
Analog-to-Digital Converter 171
Clock Pin 172
GPIO Pins 172
Index 173