Contents_FPGA_Programming_and_Hardware_Essentials
Contents_FPGA_Programming_and_Hardware_Essentials
books books
books
(m mod 10);
an MSc in Automatic Control
g
if(rising_ed
board packed with features like memory, user LEDs, push-buttons, and
Segment <= N
Engineering, and a PhD in Digital
flexible I/O ports. It’s the ideal starting point for anyone wanting to learn Signal Processing. He has worked
about FPGAs and Hardware Description Languages (HDLs). in various industrial organizations {
before returning to academic life. } (3) = ‚1‘) i <= i +
elsif(digits
In this book, you’ll get hands-on with the VHDPlus programming
language—a simpler version of VHDL. We’ll work on practical projects Prof. Ibrahim is the author of over 70
if(i = 36
);
(m/10 mod 10
technical books and has published
using the MAX1000, helping you gain the skills and confidence to unleash { {
Segment <= N
more than 200 technical articles on
your creativity. microcontrollers, microprocessors, i <=
and related fields. He is a Chartered
} digi
(2) = ‚1‘)
elsif(digits
Get ready for an exciting journey! You’ll explore a variety of projects Electrical Engineer and a Fellow of
that highlight the true power of FPGAs. Let’s turn your ideas into reality the Institution of Engineering and Digi
;
{ /100 mod 10)
Technology. Additionally, he is a
and embark on your FPGA adventure—your journey starts now!
n t < = N ( m }
certified Arduino professional.
Seg m e
}
Exciting Projects You’ll Find in This Book
} (1) = ‚1‘) }
> Arduino-Driven BCD to > Ultrasonic Distance
elsif(digits
00 mod 10);
7-Segment Display Decoder Measurement
> Use an Arduino Uno R4 > Measure distances using an { < = N ( m / 1 0
to supply BCD data to the ultrasonic sensor, display- Segmen t
decoder, counting from 0 to 9 ing the results on a 4-digit }
with a one-second delay. 7-segment LED.
ge(CLK))
if(rising_ed
> Multiplexed 4-Digit Event > Electronic Lock
Counter > Build a simple electronic lock
{
i <= i + 1; )
> Create an event counter that using combinational logic
if(i = 36000
displays the total count on a gates with push buttons and
4-digit display, incrementing an LED output.
> Temperature Sensor {
& digits(3);
with each button press.
> PWM Waveform with Fixed > Monitor ambient tempera- i <= 0; gits(2 d o w n t o 0 )
digits <= di its;
Duty Cycle ture with a TMP36 sensor Elektor International Media
Dogan Ibrahim
Dogan Ibrahim
● All rights reserved. No part of this book may be reproduced in any material form, including photocopying, or
storing in any medium by electronic means and whether or not transiently or incidentally to some other use of this
publication, without the written permission of the copyright holder except in accordance with the provisions of the
Copyright Designs and Patents Act 1988 or under the terms of a licence issued by the Copyright Licencing Agency
Ltd., 90 Tottenham Court Road, London, England W1P 9HE. Applications for the copyright holder's permission to
reproduce any part of the publication should be addressed to the publishers.
● Declaration
The author and publisher have made every effort to ensure the accuracy of the information contained in this book.
They do not assume, or hereby disclaim, any liability to any party for any loss or damage caused by errors or
omissions in this book, whether such errors or omissions result from negligence, accident, or any other cause.
The author expresses his sincere gratitude to Arrow Electronics and Trenz Electronic for granting permission to
include various tables, figures, and program codes in this book.
Elektor is the world's leading source of essential technical information and electronics products for pro engineers,
electronics designers, and the companies seeking to engage them. Each day, our international team develops and delivers
high-quality content - via a variety of media channels (including magazines, video, digital media, and social media) in
several languages - relating to electronics design and DIY electronics. www.elektormagazine.com
●4
Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Chapter 1 • Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.2.6 Accelerometer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
4.2.2 Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
●5
4.4.1 Declarations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
4.4.2 Assignments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
4.4.3 Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
4.5.1 If..Else..Elsif . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
4.5.3 For . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
4.5.4 While . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
4.5.5 Wait . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
4.5.6 Step . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
4.6.1Main . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
4.6.2 Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
4.6.3 Thread . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
4.6.4 Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
5.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
●6
5.13 Project 12 – BCD to seven-segment display decoder counter with Arduino Uno R4 79
7.3 Project 1 – Controlling the on-board LEDs with serial communication . . . . . . . . . 122
●7
10.5 Project 1 – Port expander using the I2C bus on MAX1000 FPGA . . . . . . . . . . . . 142
15.3 Project 1 – Displaying a message using the NIOS II processor as Arduino . . . . . 178
●8
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200
●9