+ All Categories
Home > Documents > 模拟与数字电路 Analog and Digital Circuits · 2021. 7. 20. · Input Output Input Output...

模拟与数字电路 Analog and Digital Circuits · 2021. 7. 20. · Input Output Input Output...

Date post: 13-Aug-2021
Category:
Upload: others
View: 1 times
Download: 0 times
Share this document with a friend
32
第 七讲: Verilog 、 FPGA 介绍 Lecture 7: Introduction on Verilog & FPGA 讲: 陈迟晓 Instructor : Chixiao Chen 课程主页 扫一扫 模拟与数字电路 Analog and Digital Circuits
Transcript
Page 1: 模拟与数字电路 Analog and Digital Circuits · 2021. 7. 20. · Input Output Input Output Lower-level ... •Special chip purpose-built for an application •E.g., ... •FPGA

第 七 讲 : Verilog 、 FPGA 介绍

Lecture 7: Introduction on Verilog & FPGA

主 讲 : 陈 迟 晓

Instructor : Chixiao Chen课程主页 扫一扫

模拟与数字电路

Analog and Digital Circuits

Page 2: 模拟与数字电路 Analog and Digital Circuits · 2021. 7. 20. · Input Output Input Output Lower-level ... •Special chip purpose-built for an application •E.g., ... •FPGA

提纲

• 复习

• Verilog always 块结构

• Verilog语法续

• Verilog 应用举例

• FPGA简介

Page 3: 模拟与数字电路 Analog and Digital Circuits · 2021. 7. 20. · Input Output Input Output Lower-level ... •Special chip purpose-built for an application •E.g., ... •FPGA

基于下列Verilog代码求模块逻辑,并化简

Page 4: 模拟与数字电路 Analog and Digital Circuits · 2021. 7. 20. · Input Output Input Output Lower-level ... •Special chip purpose-built for an application •E.g., ... •FPGA
Page 5: 模拟与数字电路 Analog and Digital Circuits · 2021. 7. 20. · Input Output Input Output Lower-level ... •Special chip purpose-built for an application •E.g., ... •FPGA
Page 6: 模拟与数字电路 Analog and Digital Circuits · 2021. 7. 20. · Input Output Input Output Lower-level ... •Special chip purpose-built for an application •E.g., ... •FPGA
Page 7: 模拟与数字电路 Analog and Digital Circuits · 2021. 7. 20. · Input Output Input Output Lower-level ... •Special chip purpose-built for an application •E.g., ... •FPGA
Page 8: 模拟与数字电路 Analog and Digital Circuits · 2021. 7. 20. · Input Output Input Output Lower-level ... •Special chip purpose-built for an application •E.g., ... •FPGA
Page 9: 模拟与数字电路 Analog and Digital Circuits · 2021. 7. 20. · Input Output Input Output Lower-level ... •Special chip purpose-built for an application •E.g., ... •FPGA
Page 10: 模拟与数字电路 Analog and Digital Circuits · 2021. 7. 20. · Input Output Input Output Lower-level ... •Special chip purpose-built for an application •E.g., ... •FPGA
Page 11: 模拟与数字电路 Analog and Digital Circuits · 2021. 7. 20. · Input Output Input Output Lower-level ... •Special chip purpose-built for an application •E.g., ... •FPGA
Page 12: 模拟与数字电路 Analog and Digital Circuits · 2021. 7. 20. · Input Output Input Output Lower-level ... •Special chip purpose-built for an application •E.g., ... •FPGA
Page 13: 模拟与数字电路 Analog and Digital Circuits · 2021. 7. 20. · Input Output Input Output Lower-level ... •Special chip purpose-built for an application •E.g., ... •FPGA
Page 14: 模拟与数字电路 Analog and Digital Circuits · 2021. 7. 20. · Input Output Input Output Lower-level ... •Special chip purpose-built for an application •E.g., ... •FPGA
Page 15: 模拟与数字电路 Analog and Digital Circuits · 2021. 7. 20. · Input Output Input Output Lower-level ... •Special chip purpose-built for an application •E.g., ... •FPGA
Page 16: 模拟与数字电路 Analog and Digital Circuits · 2021. 7. 20. · Input Output Input Output Lower-level ... •Special chip purpose-built for an application •E.g., ... •FPGA
Page 17: 模拟与数字电路 Analog and Digital Circuits · 2021. 7. 20. · Input Output Input Output Lower-level ... •Special chip purpose-built for an application •E.g., ... •FPGA
Page 18: 模拟与数字电路 Analog and Digital Circuits · 2021. 7. 20. · Input Output Input Output Lower-level ... •Special chip purpose-built for an application •E.g., ... •FPGA

结构化的Verilog 与模块的级联调用

out[0] <= #10 in[0];for (int i = 1; i < 16; i ++){ out[i] <= #10 in[i-1] & in[i];}

Input Output

Input Output

Lower-level component

Lower-level component

Higher-level component

Page 19: 模拟与数字电路 Analog and Digital Circuits · 2021. 7. 20. · Input Output Input Output Lower-level ... •Special chip purpose-built for an application •E.g., ... •FPGA

级联调用举例

• 已知一个3-8线译码器的Verilog模块,请

用使用该module和若干基础逻辑门实现的

一个4-16线译码器

Page 20: 模拟与数字电路 Analog and Digital Circuits · 2021. 7. 20. · Input Output Input Output Lower-level ... •Special chip purpose-built for an application •E.g., ... •FPGA

可编程逻辑门阵列 FPGA简介

• Field-Programmable Gate Array

• Can be configured to act like any circuit by HDL

• Can do many things, but we focus on computation acceleration

Page 21: 模拟与数字电路 Analog and Digital Circuits · 2021. 7. 20. · Input Output Input Output Lower-level ... •Special chip purpose-built for an application •E.g., ... •FPGA

FPGA vs. CPU/GPUs• GPU – The other major accelerator for parallel Computing

• CPU/GPU hardware is fixed• “General purpose”

• we write programs (sequence of instructions) for them

• FPGA hardware is not fixed• “Special purpose”

• Hardware can be whatever we want

• Will our hardware require/support software? Maybe!

• Optimized hardware is very efficient• GPU-level performance**

• 10x power efficiency (300 W vs 30 W)

Page 22: 模拟与数字电路 Analog and Digital Circuits · 2021. 7. 20. · Input Output Input Output Lower-level ... •Special chip purpose-built for an application •E.g., ... •FPGA

Fine-Grained Parallelism of Special-Purpose Circuits

• Example -- Calculating gravitational force: 𝐺×𝑚1×𝑚2

(𝑥1−𝑥2)2+(𝑦1−𝑦2)

2

• 8 instructions on a CPU → 8 cycles**

• Much fewer cycles on a special purpose circuit

A = G × m1

B = A × m2

C = x1 - x2

D = C2

E = y1 - y2

F = E2

G = D + F

Ret = B / G

A = G × m1 × m2 B = (x1 - x2)2 C = (y1 - y2)2

D = B + C

Ret = B / G

4 cycles with basic operations

3 cycles with compound operations

Ret = (G × m1 × m2) / ((x1 - x2)2 + (y1 - y2)2)

1 cycle with even further compound operations

May slow down clock

Page 23: 模拟与数字电路 Analog and Digital Circuits · 2021. 7. 20. · Input Output Input Output Lower-level ... •Special chip purpose-built for an application •E.g., ... •FPGA

How Is It Different From ASICs

• ASIC (Application-Specific Integrated Circuit)• Special chip purpose-built for an application

• E.g., ASIC bitcoin miner, Intel neural network accelerator

• Function cannot be changed once expensively built

• + FPGAs can be field-programmed• Function can be changed completely whenever

• FPGA fabric emulates custom circuits

• - Emulated circuits are not as efficient as bare-metal• ~10x performance (larger circuits, faster clock)

• ~10x power efficiency

Page 24: 模拟与数字电路 Analog and Digital Circuits · 2021. 7. 20. · Input Output Input Output Lower-level ... •Special chip purpose-built for an application •E.g., ... •FPGA

Basic FPGA Architecture“Configurable logic block (CLB)”

Programmable interconnect

I/O block 6-InputLook-Up

Table

FF

Latch

Programmable

Input 1 Input 2 Output

0 0 0

0 1 0

1 0 0

1 1 1

Ex) 2-LUT for “AND”

~

Sequential circuitconstruction

Page 25: 模拟与数字电路 Analog and Digital Circuits · 2021. 7. 20. · Input Output Input Output Lower-level ... •Special chip purpose-built for an application •E.g., ... •FPGA

FPGA: Field Programmable Grate Array

• Basic Cell: Look-Up-Table (LUT)

• Basic structure: RAM + Switches/ MUX’s

• Mapping of “any” logic – generate bit table

Page 26: 模拟与数字电路 Analog and Digital Circuits · 2021. 7. 20. · Input Output Input Output Lower-level ... •Special chip purpose-built for an application •E.g., ... •FPGA

Global Fabric

• Interconnection between CLBs:

• CB = connection boxes

• SB = switch boxes

Page 27: 模拟与数字电路 Analog and Digital Circuits · 2021. 7. 20. · Input Output Input Output Lower-level ... •Special chip purpose-built for an application •E.g., ... •FPGA

Basic FPGA Architecture – DSP Blocks

• CLBs act as gates – Many needed to implement high-level logic

• Arithmetic operation provided as efficient ALU blocks• “Digital Signal Processing (DSP) blocks”

• Each block provides an adder + multiplier

“DSP block”

× +/-

Page 28: 模拟与数字电路 Analog and Digital Circuits · 2021. 7. 20. · Input Output Input Output Lower-level ... •Special chip purpose-built for an application •E.g., ... •FPGA

Basic FPGA Architecture – Block RAM

• CLB can act as flip-flops• (~1 bit/block) – tiny!

• Some on-chip SRAM provided as blocks• ~18/36 Kbit/block, MBs per chip

• Massively parallel access to data → multi-TB/s bandwidth

“Block RAM”

Page 29: 模拟与数字电路 Analog and Digital Circuits · 2021. 7. 20. · Input Output Input Output Lower-level ... •Special chip purpose-built for an application •E.g., ... •FPGA

Basic FPGA Architecture – Hard Cores

• Some functions are provided as efficient, non-configurable “hard cores”• Multi-core ARM cores (“Zynq” series)

• Multi-Gigabit Transceivers

• PCIe/Ethernet PHY

• Memory controllers

• …

ARM PCIe

Ethernet

Memory

Page 30: 模拟与数字电路 Analog and Digital Circuits · 2021. 7. 20. · Input Output Input Output Lower-level ... •Special chip purpose-built for an application •E.g., ... •FPGA

FPGA Compilation Toolchain

High-Level HDL Code

Language Compiler

Verilog/VHDL Synthesize Netlist

Map/Place/Route

Bitfile

High-level language vendor tool

FPGA Vendor toolchain (Few open source)

Constraint File

“Which transceiver instance shouldtop_transceiver_01 map to?”And so, so much more…

Cycle-levelSimulation

FunctionalSimulation

Page 31: 模拟与数字电路 Analog and Digital Circuits · 2021. 7. 20. · Input Output Input Output Lower-level ... •Special chip purpose-built for an application •E.g., ... •FPGA

FPGA Accelerator Card Architecture & Cloud

PCIe

FPGA

DRAM

DRAM

1GbE

FMC

40GbE

• “FPGA Mezzanine Card” Expansion• Network Ports, Memory, Storage, PCIe, …

General-Purpose I/O

Pins

Multi-Gigabit Transceivers

• Amazon EC2 F1 instance (1 – 4 FPGAs)• Microsoft Azure, etc…

Page 32: 模拟与数字电路 Analog and Digital Circuits · 2021. 7. 20. · Input Output Input Output Lower-level ... •Special chip purpose-built for an application •E.g., ... •FPGA

课程实验计划


Recommended