注:本文为 “FPGA 简介 / 工作原理” 相关文章合辑。
英文引文,机翻未校。
中文引文,未整理去重。
图片受引文原图所限不清晰。
How Does an FPGA Work?
Contributors: Alchitry, Ell C
Introduction
介绍
Let’s start at the beginning. What is an FPGA~? Well, FPGA stands for Field Programmable Gate Array, which isn’t helpful in understanding what they are or do but we had to get that out of the way.
让我们从头开始。什么是 FPGA?嗯,FPGA 代表现场可编程门阵列,这对理解它们是什么或做什么没有帮助,但我们必须把它弄清楚。
FPGAs belong to a class of devices known as programmable logic, or sometimes referred to as programmable hardware. Essentially, an FPGA doesn’t do anything itself but it can be configured to be just about any digital circuit you want. The magic here is that nothing physically changes. You simply load a configuration into the FPGA and it starts behaving like the circuit you wanted. No soldering, no jumper wires, no fuss. An FPGA can then be reconfigured to behave like another circuit, and another, and another. The configuration is RAM based which means it can essentially be reconfigured an unlimited number of times.
FPGA 属于一类称为可编程逻辑的设备,有时也称为可编程硬件。从本质上讲,FPGA 本身不做任何事情,但它可以配置为您想要的几乎任何数字电路。这里的神奇之处在于,物理上没有任何变化。您只需将配置加载到 FPGA 中,它就会开始像您想要的电路一样运行。无需焊接,无需跳线,无需大惊小怪。然后,可以重新配置 FPGA,使其行为像另一个电路,另一个电路,另一个电路。该配置是基于 RAM 的,这意味着它基本上可以无限次地重新配置。
Lattice iCE40 HX FPGA highlighted on the Alchitry Cu Board
Xilinx Artix 7 FPGA highlighted on the Alchitry Au Board
Even though we talk about using FPGAs to create digital circuits, you don’t typically draw schematics to create designs for them. The size and complexity of the circuits FPGAs can contain would become very cumbersome should you actually draw out a schematic. Instead, you can describe the behavior of the circuit you want and the tools will use this to create a circuit that matches that behavior.
尽管我们谈论的是使用 FPGA 来创建数字电路,但您通常不会绘制原理图来为它们创建设计。如果您实际绘制原理图,FPGA 可以包含的电路的大小和复杂性将变得非常繁琐。相反,您可以描述所需的电路行为,工具将使用它来创建与该行为匹配的电路。
In this regard it can feel like programming since you are just typing text. However, the fundamental implementation is drastically different as you are creating hardware.
在这方面,它可能感觉像编程,因为您只是在输入文本。但是,在创建硬件时,基本实现方式截然不同。
If creating hardware with text seems like magic, don’t worry. The way they work is actually quite simple in concept and in this tutorial we are going to really break it down.
如果使用文本创建硬件看起来很神奇,请不要担心。它们的工作方式实际上在概念上非常简单,在本教程中,我们将真正分解它。
Suggested Reading
推荐阅读
In this tutorial we are going to explore what an FPGA is and how they work. I’m going to assume you have a decent understanding of electricity (voltage, current, etc) and binary values. Everything else will be quickly built upon the basics. This is intended as an overview of what an FPGA is and its fundamental design, not a guide to designing your own.
在本教程中,我们将探讨什么是 FPGA 以及它们是如何工作的。我假设你对电力(电压、电流等)和二进制值有很好的理解。其他一切都将很快建立在基础之上。本文旨在概述什么是 FPGA 及其基本设计,而不是设计自己的指南。
If you aren’t familiar with the following concepts, we recommend checking out these tutorials before continuing.
如果您不熟悉以下概念,我们建议您先查看这些教程,然后再继续。
Voltage, Current, Resistance, and Ohm’s Law
电压、电流、电阻和欧姆定律
Learn about Ohm’s Law, one of the most fundamental equations in all electrical engineering.
了解欧姆定律,所有电气工程中最基本的方程之一。
What is Electricity?
什么是电?
We can see electricity in action on our computers, lighting our houses, as lightning strikes in thunderstorms, but what is it? This is not an easy question, but this tutorial will shed some light on it!
我们可以在电脑上看到电的作用,它照亮我们的房屋,闪电在雷雨中闪烁,但电是什么?这不是一个容易回答的问题,但本教程将为你提供一些启示!
Analog vs. Digital
模拟与数字
This tutorial covers the concept of analog and digital signals, as they relate to electronics.
本教程涵盖了与电子学相关的模拟信号和数字信号的概念。
Transistors
晶体管
A crash course in bi-polar junction transistors. Learn how transistors work and in which circuits we use them.
关于双极型晶体管的速成课程。学习晶体管的工作原理以及我们在哪些电路中使用它们。
Digital Circuits and Logic Gates
数字电路和逻辑门
Digital Circuits
数字电路
One caveat of FPGAs is that they can only create digital circuits. Some of the newer FPGAs include on-board analog to digital converters, but even these convert the analog input into a digital signal as soon as possible. But what is a digital circuit?
FPGA 的一个警告是,它们只能创建数字电路。一些较新的 FPGA 包括板载模数转换器,但即使是这些转换器也能尽快将模拟输入转换为数字信号。但什么是数字电路?
In electronics, digital is used to describe circuits that abstract away continuous voltage values in favor of discrete 1s and 0s. The actual voltages used and the thresholds don’t actually matter for the higher level design but you will often see something like 0V being a 0 and 1.2V being a 1 inside the FPGA. If the actual voltage is, say, 0.8V that is close enough to 1.2V to be considered a 1 and everything works the same.
在电子学中,数字用于描述抽象出连续电压值以支持离散 1 和 0 的电路。实际使用的电压和阈值对于更高级别的设计实际上并不重要,但您通常会在 FPGA 内部看到 0V 是 0,1.2V 是 1。例如,如果实际电压为 0.8V,则足够接近 1.2V,可以被视为 1,并且一切正常。
A digital circuit is designed to push the voltages to the extremes which makes them incredibly resilient to noise and other real-world interference. The concept of digital also gives us a way to design complicated behavior into the circuit without having to worry about the lower level design. We get to work in an ideal world. The nitty gritty is taken care of in the design of the simple building blocks that we will be using.
数字电路旨在将电压推至极值,这使得它们对噪声和其他现实世界干扰具有难以置信的抵抗力。数字化的概念还为我们提供了一种在电路中设计复杂行为的方法,而不必担心较低级别的设计。我们在一个理想的世界里工作。在我们将使用的简单构建块的设计中,细节得到了照顾。
These building blocks are logic gates.
这些构建块是逻辑门。
Logic Gates
逻辑门
There are a handful of different logic gates but the most common ones are AND, OR, XOR, and NOT. Each of these takes digital inputs, performs its logical function, and outputs a digital value.
有一些不同的逻辑门,但最常见的是 AND、OR、XOR 和 NOT。它们中的每一个都接受数字输入,执行其逻辑功能,并输出数字值。
An AND gate takes two inputs and outputs a 1 only when the first input and the second input are 1. If either input is 0, the output is 0. The symbol of an AND gate looks like this:
当第一个输入和第二个输入为 1 时,AND 门接受两个输入并输出 a 1。如果任一输入为 0,则输出为 0。AND 门的符号如下所示:
An OR gate takes two inputs and outputs a 1 when either the first input or the second input is 1. Only when both are 0 is the output 0. Here’s the OR gate symbol:
OR 门接受两个输入,当第一个输入或第二个输入为 1 时输出 1。只有当两者都为 0 时,输出才为 0。以下是 OR 门符号:
An XOR gate is similar to an OR gate but only outputs a 1 when either the first input or the second input are 1, but not when both are 1. It can also be thought of as outputting a 1 when the inputs are different. The X in XOR stands for exclusive. Here is its symbol:
XOR 门类似于 OR 门,但仅当第一个输入或第二个输入为 1 时输出 1,而当两者都为 1 时不输出 1。当输入不同时,也可以将其视为输出 1。XOR 中的 X 代表排他性。这是它的象征:
A [NOT](https://en.wikipedia.org/wiki/Inverter_(logic_gate )) gate is the simplest gate. It has one input and simply outputs the opposite of whatever it is. So a 1 becomes a 0 and a 0 becomes a 1.
非门是最简单的门。它有一个输入,并且只是输出与它是什么相反的输入。所以 1 变成 0,0 变成 1。
There are variations of the basic gates known as NAND, NOR, and XNOR. These are simply the standard versions with their outputs inverted.
基本门有多种变体,称为 NAND、NOR 和 XNOR。这些只是标准版本,其输出是反转的。
Just for some extra context, an AND gate, like all logic gates, can be built using transistors. The image below shows an example of how an AND gate could be implemented. The schematic uses NMOS and PMOS MOSFET transistors. This type of design is known as CMOS (complementary metal-oxide semiconductor) and is what is used in most modern circuits.
只是为了提供一些额外的背景信息,像所有逻辑门一样,AND 门可以使用晶体管来构建。下图显示了如何实现 AND 门的示例。原理图使用 NMOS 和 PMOS MOSFET 晶体管。这种类型的设计被称为 CMOS(互补金属氧化物半导体),是大多数现代电路中使用的设计。
Note that the above schematic is actually a NAND gate followed by a NOT gate. This is because CMOS circuits invert the output.
请注意,上述原理图实际上是一个 NAND 门,后面跟着一个 NOT 门。这是因为 CMOS 电路会反转输出。
Multiplexers
多路复用器
Now that we have the basic building blocks from transistor