Before we start working with FPGA, it's important to understand what it actually is.

Surprisingly, even people who have been working with FPGA for a long time often don't fully grasp its nature.

Some of them still think they're coding for a processor like ARM, AVR, or DSP when they write FPGA code.

This is a common misunderstanding, and we're here to clear that up today.

So, it's crucial to address these misconceptions right from the start and try to eliminate them before we dive in deep.

More...

## What Exactly Is an FPGA?

On the surface, it might look similar to other chips and circuits, but if we dig deeper, it's quite distinct.

To gain a better understanding of FPGAs, let's consider an example. The entire concept of an FPGA can be explained through this example.

Imagine we have a logic function, F = AB + ABÌ…CÌ… + BÌ…C, and our task is to implement it. Typically, there are two approaches to achieving this.

## 1- Direct Implementation Using Logic Gates

In the figure below, you can see the truth table for this function that displays the outputs for various input combinations.

For example, if the inputs are 000, the output is 0. On the right side, you can see the implementation of this three-valued function using logic gates.

Now, if we use the input values highlighted in red, we expect to get the same output as in the truth table. It's easy to verify that if we input 101, the output will be 1.

## 2- Using Memory Blocks

Now, let's explore the second approach - using memory blocks. This is where things get really exciting!

Based on our knowledge of Logic Circuits, you know that **any logic function can be implemented using a memory block.**

To illustrate, let's stick with our ongoing example. Here, we're aiming to implement the function defined by the above truth table.

Given that the function has a single-bit output, we need a memory block with single-bit cells.

Since our three variables can generate eight different combinations, an eight-cell memory block is required. This block will have three address lines.

The next step to implement the function using this memory is mapping our inputs A, B, and C to the address lines of the memory block.

The data output of the memory block matches the output of our function.

However, to configure this memory so that it matches our desired function, we need to copy the outputs from the truth table to the memory block.

As you can see, we've copied the outputs into the memory cells in the same order.

Now, if we provide the same input combination as before, specifically 101, cell number 5 (marked with a gray background) is selected, and its value becomes the output.

In this case, the output is 1, which matches what we expected based on the truth table.

## Basic Definition of an FPGA

What we've just implemented are known as Look-up Tables or LUTs. LUTs are small memory blocks used to implement logic functions.

Now, you might be wondering, **"How does all of this tie into FPGAs?"**

Well, an FPGA is essentially a huge collection of these look-up tables, and inside an FPGA, there are literally thousands or even millions of them.

When it comes to implementing a complex circuit, the first step is to **break it down into smaller logic functions.**

Each of these smaller functions is then **implemented using a look-up table** that resides within the FPGA.

These look-up tables are then **interconnected using wires,** forming the main circuit. This is the basic definition of an FPGA, which reflects its core concept.

However, it's important to note that the structure of these look-up tables slightly varies within an FPGA.

Let's take a closer look.

## Look-Up Table Structure in FPGAs

In an FPGA, a lookup table is actually built using SRAM. The outputs of your function, determined by the truth table, are stored in the SRAM.

And to access the lookup table, we use a bunch of multiplexers, which are controlled by the inputs of your function.

Going back to the earlier example, let's say we label our inputs as A, B, and C. If we input 101 or 5, we anticipate that cell #5 will be selected.

To verify this, let's follow the path of the output, F, through these multiplexers.

At the output multiplexer, the control input (aka select line) is set to 1. As a result, the second input is connected to the output.

This means that 'F' is connected to this second input point, which is then routed to the next multiplexer.

Here, the control input is 0, so the first input is connected to the output. This path leads us to this multiplexer.

The control input for this one is 1, connecting its second input to the output.

This happens to be cell #5 in the SRAM, where the corresponding output has already been stored.

This means that the value of 1 is carried through the red line to become the output 'F'. As a result, the lookup table is effectively created inside the FPGA.

A typical FPGA contains thousands of look-up tables. A larger circuit is divided into smaller functions, and each of these smaller functions is implemented within a separate look-up table.

These look-up tables are then interconnected to create the final circuit.

But how do we interconnect these look-up tables within an FPGA?

## Interconnecting Wires Within an FPGA

Remember, we're working with an integrated circuit, so we can't simply insert wires into it.

Instead, we have an array of pre-installed wires running between these look-up tables, and we can utilize these wires to make the necessary connections between the LUTs.

These interconnection wires are organized into horizontal and vertical routing channels positioned between the rows and columns of the LUTs.

These wires allow the LUTs to be connected in various ways.

But connecting these wires requires a strategic approach. We have horizontal and vertical wires intersecting at various points.

At these intersections, there are switch matrix networks that can be programmed digitally. We can connect each horizontal wire to a vertical one, and we can also establish connections to neighboring look-up tables.

By doing this, we can create different paths and connect look-up tables as required by our circuit. This is how we can design different routes in an FPGA and interconnect each look-up table to another.

## FPGA Hardware Resources

In its essence, an FPGA doesn't come with predefined functions. Rather, it offers a plethora of **hardware resources.**

These resources include the look-up tables and the interconnecting wires. We populate the LUTs with appropriate data and establish connections to create various digital circuits of different sizes.

Look-up tables and interconnecting wires are the main hardware resources inside FPGAs, but these hardware resources aren't the only ones present in FPGAs.

There are additional hardware resources within an FPGA, which we'll talk about in our upcoming video.