using fpga in embedded devices

41
1 Using FPGA in Embedded Devices Andriy Smolskyy Consultant, Engineering 29.03.2017

Upload: globallogic-ukraine

Post on 16-Apr-2017

126 views

Category:

Engineering


0 download

TRANSCRIPT

Page 1: Using FPGA in Embedded Devices

1

Using FPGA in Embedded Devices

Andriy SmolskyyConsultant, Engineering29.03.2017

Page 2: Using FPGA in Embedded Devices

2

What is FPGA?

Page 3: Using FPGA in Embedded Devices

3

• Transistor-Transistor Logic - TTL• Programmable Array Logic - PAL• Programmable Logic Device – PLD• Complex PLD – CPLD• FPGA• ASIC

History of Programmable Logic

Page 4: Using FPGA in Embedded Devices

4

Digital Design with TTL LogicTruth table

Page 5: Using FPGA in Embedded Devices

5

Digital Design with TTL LogicTruth table Karnaugh

map

Page 6: Using FPGA in Embedded Devices

6

Digital Design with TTL LogicTruth table Karnaugh

mapLogic

expression

Page 7: Using FPGA in Embedded Devices

7

Digital Design with TTL LogicTruth table Karnaugh

mapLogic

expression Final implementation

Page 8: Using FPGA in Embedded Devices

8

• Logic gates and registers are fixed• Programmable sum of products array and output control

Programmable Array Logic (PAL)Implementation

Advantages• Fewer devices required• Lower cost• Power savings• Simpler to test and debug• Design security (prevent reverse engineering)

• In-system reprogrammability! (in some cases)

Page 9: Using FPGA in Embedded Devices

9

From PAL to Programmable Logic Device (PLD)• Arrange multiple PAL arrays in a single device

Page 10: Using FPGA in Embedded Devices

10

• Combine multiple PLDs in single device with programmable interconnect and I/O

From PLD to Complex PLD (CPLD)Implementation

Advantages• Ample amounts of logic and advanced configurable I/Os

• Programmable routing• Instant on• Non-volatile configuration• Reprogrammable

Page 11: Using FPGA in Embedded Devices

11

Interconnection Problem: Routing Takes Too Much SpaceGlobal Routing Row & Column Routing

Page 12: Using FPGA in Embedded Devices

12

• LUT inputs are mux select lines• FPGA LABs made up of logic elements (LEs) instead of product terms and macrocells

• Solves the Interconnection Problem

FPGA LUT and LAB

Page 13: Using FPGA in Embedded Devices

13

• LABs arranged in an array• Programmable interconnect• Interconnect may span all or part of the array

Field Programmable Gate Array (FPGA)Implementation

Advantages• Easier to create complex functions through LE cascading

• Integration of ready functions and IP blocks: PLLs, memory, arithmetic

• High density, high performance• Fast programming

Page 14: Using FPGA in Embedded Devices

14

• Pros:- Fast time to Market: easy to develop a new

device with specific logic or interfaces- Easy to upgrade device logic, fix bugs in

hardware- Specific devices: reconfigurable DSP, digital

filters• Cons:

- Need to be programmed at power on- It is hard to achieve 100% device utilization

FPGA vs ASIC

• Pros:- Higher performance: consume less

power and can operate faster on higher speed

- Cheaper in mass production- No configuration at power-on required- Smaller chip size

• Cons:- Additional expenses in design

preparation- Impossible to fix hardware bugs

FPGA ASIC

Page 15: Using FPGA in Embedded Devices

15

Software and hardware development aspects

Page 16: Using FPGA in Embedded Devices

16

System on Chip (SoC) + FPGA

Page 17: Using FPGA in Embedded Devices

17

• In general FPGA generated controllers are similar to Microcontrollers’ peripheral devices

• FPGA requires programming of each start, controllers might be not ready at the system start

• Take care with DMA, MMU, virtual memory and caching operations

• In some designs FPGA can control CPU peripheral devices

Software and hardware development aspects

Page 18: Using FPGA in Embedded Devices

18

• Verilog• VDHL• Visual development

FPGA design development

Page 19: Using FPGA in Embedded Devices

19

• Core IP- SDRAM Controllers- Ethernet PHY, Custom

Transceiver PHY- PCIe PHY- SDi, Display Port

• Megafunctions - PLL- I/O- Custom logic blocks

FPGA design development

Page 20: Using FPGA in Embedded Devices

20

High speed data processing: OpenCL in FPGA

Page 21: Using FPGA in Embedded Devices

21

A simple CPU

Page 22: Using FPGA in Embedded Devices

22

Load immediate value into register

Page 23: Using FPGA in Embedded Devices

23

Load memory value into register

Page 24: Using FPGA in Embedded Devices

24

Store register value into memory

Page 25: Using FPGA in Embedded Devices

25

Add two registers, store result in register

Page 26: Using FPGA in Embedded Devices

26

A simple programMem[100] += 42 * Mem[101]

CPU instructions:

R0 Load Mem[100] R1 Load Mem[101] R2 Load #42 R2 Mul R1, R2 R0 Add R2, R0 Store R0 Mem[100]

Page 27: Using FPGA in Embedded Devices

27

Single CPU activity, step by step

Time

Page 28: Using FPGA in Embedded Devices

28

Unroll the CPU hardware…

Space

Page 29: Using FPGA in Embedded Devices

29

… and specialize by position1. Instructions are fixed. Remove

“Fetch”

Page 30: Using FPGA in Embedded Devices

30

… and specialize1. Instructions are fixed. Remove

“Fetch”2. Remove unused ALU operations

Page 31: Using FPGA in Embedded Devices

31

… and specialize1. Instructions are fixed. Remove

“Fetch”2. Remove unused ALU operations3. Remove unused Load / Store

Page 32: Using FPGA in Embedded Devices

32

… and specialize1. Instructions are fixed. Remove

“Fetch”2. Remove unused ALU operations3. Remove unused Load / Store4. Wire up registers properly. And

propagate state.

Page 33: Using FPGA in Embedded Devices

33

… and specialize1. Instructions are fixed. Remove

“Fetch”2. Remove unused ALU operations3. Remove unused Load / Store4. Wire up registers properly. And

propagate state5. Remove dead data

Page 34: Using FPGA in Embedded Devices

34

… and specialize1. Instructions are fixed. Remove

“Fetch”2. Remove unused ALU operations3. Remove unused Load / Store4. Wire up registers properly. And

propagate state5. Remove dead data6. Reschedule!

Page 35: Using FPGA in Embedded Devices

35

FPGA datapath = Your algorithm, in silicon• Build exactly what you need:

- Operations- Data widths- Memory size, configuration

• Efficiency:- Throughput- Latency- Power

Page 36: Using FPGA in Embedded Devices

36

OpenCL FPGA• Host + Accelerator Programming Model• Sequential Host program on microprocessor

• Function offload onto a highly parallel accelerator device

main() { read_data( … ); maninpulate( … ); clEnqueueWriteBuffer( … ); clEnqueueNDRange(…,sum,…); clEnqueueReadBuffer( … ); display_result( … );}

__kernel voidsum(__global float *a, __global float *b, __global float *y){ int gid = get_global_id(0); y[gid] = a[gid] + b[gid];}

Host Code

FPGA Design

User Application

Algorithm

Page 37: Using FPGA in Embedded Devices

37

Loop Pipelining• Analyze any dependencies between iterations

• Schedule these operations• Launch the next iteration as soon as possible

float array[M];

for (int i=0; i < n*numSets; i++){ for (int j=0; j < M-1; j++) array[j] = array[j+1]; array[M-1] = a[i];

for (int j=0; j < M; j++) answer[i] += array[j] * coefs[j];}

At this point, we can launch the next iteration

Page 38: Using FPGA in Embedded Devices

38

Loop Pipelining ExampleWith Loop PipeliningNo Loop Pipelining

Looks almost like parallel thread execution

Page 39: Using FPGA in Embedded Devices

39

Digital Filter

z-1 z-1 z-1 z-1 z-1 z-1 z-1

X X X X X X X X

C0 C1 C2 C3 C4 C5 C6 C7

x(n)

+

y(n)

Page 40: Using FPGA in Embedded Devices

40

• Q&AFPGA in Embedded Devices

Page 41: Using FPGA in Embedded Devices

41

Thank you

Andriy SmolskyyConsultant, [email protected]+380-67-701-8637