Architecting High-Performance Embedded Systems - Jim Ledin - E-Book

Architecting High-Performance Embedded Systems E-Book

Jim Ledin

0,0
34,79 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

Modern digital devices used in homes, cars, and wearables contain highly sophisticated computing capabilities composed of embedded systems that generate, receive, and process digital data streams at rates up to multiple gigabits per second. This book will show you how to use Field Programmable Gate Arrays (FPGAs) and high-speed digital circuit design to create your own cutting-edge digital systems.
Architecting High-Performance Embedded Systems takes you through the fundamental concepts of embedded systems, including real-time operation and the Internet of Things (IoT), and the architecture and capabilities of the latest generation of FPGAs. Using powerful free tools for FPGA design and electronic circuit design, you’ll learn how to design, build, test, and debug high-performance FPGA-based IoT devices. The book will also help you get up to speed with embedded system design, circuit design, hardware construction, firmware development, and debugging to produce a high-performance embedded device – a network-based digital oscilloscope. You’ll explore techniques such as designing four-layer printed circuit boards with high-speed differential signal pairs and assembling the board using surface-mount components.
By the end of the book, you’ll have a solid understanding of the concepts underlying embedded systems and FPGAs and will be able to design and construct your own sophisticated digital devices.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB
MOBI

Seitenzahl: 481

Veröffentlichungsjahr: 2021

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Architecting High-Performance Embedded Systems

Design and build high-performance real-time digital systems based on FPGAs and custom circuits

Jim Ledin

BIRMINGHAM—MUMBAI

Architecting High-Performance Embedded Systems

Copyright © 2021 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or revfile:///C:/Users/josephr/OneDrive - Packt/1. Distribution Team - Kindle etc/Distribution checks/08-01-21/9781789955965.epubiews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

Group Product Manager: Wilson D'souza

Associate Publishing Product Manager: Sankalp Khattri

Senior Editor: Rahul Dsouza

Content Development Editor: Nihar Kapadia

Technical Editor: Nithik Cheruvakodan

Copy Editor: Safis Editing

Project Coordinator: Neil D'mello

Proofreader: Safis Editing

Indexer: Priyanka Dhadke

Production Designer: Joshua Misquitta

First published: January 2021

Production reference: 1060121

Published by Packt Publishing Ltd.

Livery Place

35 Livery Street

Birmingham

B3 2PB, UK.

ISBN 978-1-78995-596-5

www.packt.com

Packt.com

Subscribe to our online digital library for full access to over 7,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website.

Why subscribe?

Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionalsImprove your learning with Skill Plans built especially for youGet a free eBook or video every monthFully searchable for easy access to vital informationCopy and paste, print, and bookmark content

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at packt.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details.

At www.packt.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks.

Contributors

About the author

Jim Ledin is the CEO of Ledin Engineering, Inc. Jim is an expert in embedded software and hardware design, development, and testing. He is also accomplished in embedded system cybersecurity assessment and penetration testing. He has a B.S. degree in aerospace engineering from Iowa State University and an M.S. degree in electrical and computer engineering from the Georgia Institute of Technology. Jim is a registered professional electrical engineer in California, a Certified Information System Security Professional (CISSP), a Certified Ethical Hacker (CEH), and a Certified Penetration Tester (CPT).

I would like to thank Mike Anderson for his thoughtful technical review of this book. I would also like to thank Nihar Kapadia and all of the staff at Packt for their competent assistance in completing this book during a very challenging year.

About the reviewer

Mike Anderson is currently a senior project lead and embedded systems architect for The Aerospace Corporation, based in Chantilly, VA. With over 40 years in the embedded and real-time computing industry, Mike works with a number of Real-Time Operating System (RTOS) offerings for Internet of Things (IoT) devices. However, his focus over the past decade is primarily embedded Linux on a number of CPU architectures. Mike is a regular speaker at the Embedded Linux Conference, Sensors Expo, and other Linux-, embedded systems-, and IoT-oriented conferences. His ongoing projects include work with mesh wireless topologies, AI/ML on satellites, 6LoWPAN, and working as a mentor for multiple high school robotics with the FIRST Robotics Program.

I'd like to thank my family for their infinite patience with my taking the time to review this book. I feel that it's time well spent for the future of the industry.

Packt is searching for authors like you

If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea.

Table of Contents

Preface

Section 1: Fundamentals of High-Performance Embedded Systems

Chapter 1: Architecting High-Performance Embedded Systems

Technical requirements

Elements of embedded systems

Power source 5

Digital processing6

Software and firmware 7

Specialized circuitry8

Input from the environment8

Output to the environment 9

Operating in real time

Periodic operation12

Event-driven operation13

Real-time operating systems14

FPGAs in embedded systems

Digital logic gates16

Flip-flops19

Elements of FPGAs20

FPGA synthesis22

Hardware design languages22

The benefits of using FPGAs in embedded system designs25

Xilinx FPGAs and development tools26

Summary

Chapter 2: Sensing the World

Technical requirements

Introducing passive, active, and smart sensors

Applying analog-to-digital converters

The types of sensors used in embedded systems

Light36

Temperature37

Pressure37

Humidity38

Fluid flow38

Force39

Ultrasonic39

Audio39

Magnetic40

Chemical40

Ionizing radiation41

Radar41

Lidar41

Video and infrared42

Inertial43

GPS43

Communicating with sensors

GPIO44

Analog voltage48

I2C50

SPI51

CAN bus52

Wireless54

Processing sensor data

Summary

Chapter 3: Operating in Real Time

Technical requirements

What does real-time mean?

Attributes of a real-time embedded system

Performing multiple tasks60

Rate-monotonic scheduling69

Understanding key RTOS features and challenges

Mutexes70

Semaphores72

Queues72

Event flags73

Timers73

Dynamic memory allocation74

Deadlock76

Priority inversion77

Popular real-time operating systems

embOS83

FreeRTOS83

INTEGRITY84

Neutrino84

µc/OS-III84

VxWorks85

Summary

Section 2: Designing and Constructing High-Performance Embedded Systems

Chapter 4: Developing Your First FPGA Program

Technical requirements

Using FPGAs in real-time embedded system designs

Block RAM and distributed RAM91

FPGA I/O pins and associated features92

Specialized hardware resources94

Processor cores95

FPGA implementation languages

VHDL95

Verilog97

Block diagrams98

C/C++99

The FPGA development process

Defining system requirements101

Allocating functionality to the FPGA102

Identifying required FPGA features102

Implementing the FPGA design103

Testing the implementation105

Developing your first FPGA project

Project description106

Installing the Vivado tools107

Creating a project110

Creating VHDL source files112

Testing the logic behavior120

Defining I/O signals127

Creating a top-level VHDL file129

Synthesizing and implementing the FPGA bitstream130

Downloading the bitstream to the board133

Programming the bitstream to onboard flash memory135

Summary

Chapter 5: Implementing systems with FPGAs

Technical requirements

The FPGA compilation process

Design entry142

Logic synthesis147

Design optimization149

High-level synthesis153

Optimization and constraints160

Algorithm types most suitable for FPGA implementation

Algorithms that process high-speed data streams162

Parallel algorithms163

Algorithms using nonstandard data sizes163

Kicking off the oscilloscope FPGA project

Project description164

Baseline Vivado project165

Summary

Chapter 6: Designing Circuits with KiCad

Technical requirements

Introducing KiCad

Basic KiCad procedures

Placing and connecting circuit components182

Creating component symbols190

Developing the project schematic diagram

Adding text annotations196

Adding signal labels197

Adding global labels197

Creating differential signal pairs198

Creating offboard connections198

Symbol annotation and electrical rules checking199

Laying out the PCB

Prototyping the circuit board

Summary

Chapter 7: Building High-Performance Digital Circuits

Technical requirements

Circuit board assembly tools and procedures

Optical magnification214

Tweezers216

Flux217

Solder218

Electrostatic discharge protection219

Hand soldering220

Solder wick222

Solder paste application223

Reflow soldering227

Preparing for assembly and placing parts

Reflow soldering and hand soldering

Hand soldering234

Post-assembly board cleaning and inspection

Summary

Section 3: Implementing and Testing Real-Time Firmware

Chapter 8: Bringing Up the Board for the First Time

Technical requirements

Preparing for power-up

Supplying power to the board244

Checking our circuit's basic functionality

Testing the board power supplies247

Testing the analog amplifiers250

Testing the ADC253

Adapting the circuit in case of problems

Cutting PCB traces261

Installing solder jumpers and jumper wires262

Removing components263

Adding components264

Generating the ADC encoder clock and 1 KHz calibration signal265

Summary

Chapter 9: The Firmware Development Process

Technical requirements

Designing and implementing the FPGA algorithm

Digital oscilloscope system overview272

Adding the deserializer275

Adding a FIFO buffer280

Adding the AXI bus interface283

Adding the MQTT protocol285

Coding style

Naming things291

Comments in code292

Avoid literal numeric values292

Braces, indentation, and vertical spacing292

Prioritize readability and correctness293

Avoid premature optimization294

Avoid implementation-defined behavior294

Avoid unconditional jumps295

Minimize the scope of identifiers295

Indicate that constant things are constant296

Automated code formatters297

Statically analyzing source code

What is static code analysis?297

Static code analysis tools298

Using static code analysis effectively299

Working with existing code299

Begin with only the most severe messages301

Resolving analyzer output messages302

Common source code analyzer messages302

Source code version control

Version control with Git304

Test-driven development

TDD applied to embedded systems305

Summary

Chapter 10: Testing and Debugging the Embedded System

Technical requirements

Designing system-level tests

Requirements-driven testing309

Testing under nominal and off-nominal conditions312

Unit testing versus functional testing313

Negative testing and penetration testing315

Testing in a simulated environment316

Achieving repeatable test results316

Developing a test plan317

Conducting tests and recording results

Identify the data to be collected319

Configuring the system under test320

Executing the test procedures320

Quick-look assessment of test results321

Repeating tests when necessary322

Regression testing existing code322

Ensuring comprehensive test coverage

Requirements traceability matrix324

Tracking code coverage327

Dealing with syntax and compilation errors and warnings330

Working with static code analysis and unit testing331

Define the problem clearly and attempt to duplicate it332

Determine whether the input is correct333

Find ways to gain visibility into the system333

Using a binary search debugging process335

temporarily removing portions of functionality336

Make the smallest program that demonstrates the problem336

Summary of best practices for high-performance embedded system development

Designing for test337

Leave room for growth338

Design hardware with future capabilities in mind338

Developing only the code you need right now339

Maintain strict version control340

Develop unit tests as code is in development341

Begin system-level testing as soon as functionality is present341

Summary

Other Books You May Enjoy

Preface

Modern digital devices used in homes, in cars, and on our persons contain increasingly sophisticated computing capabilities. These embedded systems generate, receive, and process digital data streams at rates of up to multiple gigabits per second. This book teaches you how to use field-programmable gate arrays (FPGAs) and high-speed digital circuit design techniques to create your own cutting-edge digital device designs.

Intended audience for this book

This book is intended for software developers, hardware engineers, Internet of Things (IoT) developers, and anyone else seeking to understand the process of developing high-performance embedded systems. The potential audience includes anyone with an interest in learning about the fundamentals of FPGA development and all aspects of firmware development in C and C++. Readers should have a basic level of familiarity with the C language, digital circuits, and soldering electronic components.

What this book covers

Chapter 1, Architecting High-Performance Embedded Systems, introduces the elements of embedded system architectures and discusses some key system features that are common across a wide variety of embedded applications. An embedded system generally includes at least one microcontroller or microprocessor, sensors, actuators, a power source, and, in many cases, one or more network interfaces. The chapter continues with an exploration of the relationship between embedded systems and the IoT.

Chapter 2, Sensing the World, introduces the principles and implementations of sensors used in a wide variety of embedded applications. Passive sensors measure attributes of the world such as temperature, pressure, humidity, light intensity, and atmospheric composition. Active sensors use energy-emitting technologies such as radar and lidar to detect objects and measure their position and velocity.

Chapter 3, Operating in Real Time, addresses the need for embedded systems to generate real-time responses to inputs measured from sensors and other sources. The concepts of Real-Time Operating Systems (RTOSes) and their key features are introduced, as well as some challenges that commonly occur when implementing multitasking in real-time applications. The chapter concludes with a presentation of the important characteristics of some popular open source and commercial RTOS implementations.

Chapter 4, Developing Your First FPGA Program, begins with a discussion on the effective use of FPGA devices in real-time embedded systems and continues with a description of the functional elements contained within standard FPGAs. The range of FPGA design languages, including Hardware Description Languages (HDLs), block diagram methods, and popular software programming languages including C and C++, is introduced. The chapter continues with an overview of the FPGA development process and concludes with a complete example of an FPGA development cycle, starting with a statement of system requirements and ending with a functional system implemented in a low-cost FPGA development board.

Chapter 5, Implementing Systems with FPGAs, dives into the process of designing and implementing embedded devices with FPGAs. It begins with a description of the FPGA compilation software tools that convert a description of a logic design in a programming language into an executable FPGA configuration. We will discuss the types of algorithms best suited to FPGA implementation and suggest a decision-making approach for determining whether a particular embedded system algorithm is more appropriately implemented using a traditional processor or with an FPGA. The chapter ends with the step-by-step development of a baseline FPGA-based processor project that will be expanded to implement a high-speed digital oscilloscope using circuitry and software developed in later chapters.

Chapter 6, Designing Circuits with KiCad, introduces the excellent open source KiCad electronics design and automation suite. Working in KiCad, you will design a circuit using schematic diagrams and develop a corresponding printed circuit board layout. You'll learn how to turn a circuit board design into a prototype at a very reasonable cost. This chapter includes example schematics for the oscilloscope circuit project you will assemble in the next chapter.

Chapter 7, Building High-Performance Digital Circuits, presents the processes and techniques involved in assembling prototype high-performance digital circuits using surface-mount and through-hole electronic components. A recommended set of tools is identified, including a soldering station, a magnifier or microscope, and tweezers for handling tiny parts. The reflow soldering process is introduced, along with descriptions of some low-cost options for implementing a small-scale reflow capability.

Chapter 8, Bringing Up the Board for the First Time, covers how, having designed, constructed, cleaned, and inspected the printed circuit board, it is now time to apply power – in other words, perform the infamous smoke test. This chapter leads you through the process of carefully providing first-time power to the board and checking basic circuit-level functionality. If you discover any problems, the chapter contains suggested approaches for addressing them. After passing these tests, it is time to add to the FPGA logic and test the digital interface to the oscilloscope board.

Chapter 9, The Firmware Development Process, shows how, now that we have a functioning circuit board, to flesh out the remaining key portions of the FPGA algorithm, including communication with the Analog to Digital Converter (ADC), and continue development of the MicroBlaze processor firmware. When developing firmware, it is important to subject the code to static analysis where possible, which can head off many errors that are otherwise difficult to debug. It is also important to implement a version control system to track the evolution of the code over the project life cycle. We will discuss the importance of developing a comprehensive, at least partially automated test suite to maintain code quality as changes are made. The chapter recommends some free and commercial tools for performing each of these functions.

Chapter 10, Testing and Debugging the Embedded System, discusses how, as the development of our embedded system nears completion, the time arrives to conduct thorough testing in the context in which it will operate. This testing must address the entire expected range of environmental conditions and user inputs, including invalid inputs, to ensure proper operation under all conditions. The chapter concludes with a discussion of recommended debugging procedures and a summary of best practices for high-performance embedded system development.

To get the most out of this book

This book takes full advantage of powerful free commercial and open source software tool suites to develop FPGA algorithms and to design sophisticated printed circuit boards. To follow along with the example project, you will need a specific FPGA development board, the Digilent Arty A7-100. To construct the digital circuits to implement your designs, you will need a set of tools for soldering and desoldering surface mount components. You will also need tools to assist in working with fine-scale parts, such as precision tweezers and a magnifier or microscope.

If you are using the digital version of this book, we advise you to access the code via the GitHub repository (link available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.

Download the example code files

The code bundle for the book is hosted on GitHub at https://github.com/PacktPublishing/Architecting-High-Performance-Embedded-Systems. In case there's an update to the code, it will be updated at this GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: http://www.packtpub.com/sites/default/files/downloads/9781789955965_ColorImages.pdf.

Conventions used

There are a number of text conventions used throughout this book.

Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "The term std_logic refers to a single-bit binary data type."

A block of code is set as follows:

architecture BEHAVIORAL of FULL_ADDER is

begin

S <= (A XOR B) XOR C_IN;

C_OUT <= (A AND B) OR ((A XOR B) AND C_IN);

end architecture BEHAVIORAL;

Any command-line input or output is written as follows:

dism /online /Enable-Feature /FeatureName:TelnetClient

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "Leave the selections at their default values and click Next."

Tips or important notes

Appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book, mention the book title in the subject of your message and email us at [email protected].

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Reviews

Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packt.com.

Section 1: Fundamentals of High-Performance Embedded Systems

This part introduces the basic concepts of embedded systems, real-time computing, and Field Programmable Gate Array (FPGA) devices. It provides a high-level overview of topics that will be covered in detail in later chapters.

This part of the book comprises the following chapters:

Chapter 1, Architecting High-Performance Embedded SystemsChapter 2, Sensing the WorldChapter 3, Operating in Real Time