advanced fpga based system design
DESCRIPTION
Advanced FPGA Based System Design. Lecture-5-6 Introduction to VHDL. By: Dr Imtiaz Hussain [email protected]. Outline. Introduction to Hardware Description Languages Recommended Literature Introduction to VHDL Design Flow EDA Tools VHDL Design Examples - PowerPoint PPT PresentationTRANSCRIPT
![Page 2: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/2.jpg)
2
Outline
• Introduction to Hardware Description Languages• Recommended Literature• Introduction to VHDL– Design Flow
• EDA Tools• VHDL • Design Examples• VHDL Code Structure• Examples
![Page 3: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/3.jpg)
3
Recommended Book
• Circuit Design With VHDL By: Volnei A. Pedroni
e-copy available on imtiazhussainkalwar.weebly.com
![Page 4: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/4.jpg)
4
What is Hardware Description Language?
• A hardware description language or HDL is any language for description and design of electronic circuits, and most commonly, digital logic.
• It can describe the circuit's operation, its design and organization, and tests to verify its operation by means of simulation.
![Page 5: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/5.jpg)
5
What is Hardware Description Language?
• There are two primary purposes for hardware description languages
– Modeling of Digital Circuits: Having a model of the circuit allows for simulation and testing of the design for proper operation.
– Hardware description languages are used as one of the first steps in creating large digital integrated circuits.
![Page 6: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/6.jpg)
6
HDLs for Analog Circuit Design
Abbreviation Name Use
AHDL Analog Hardware Descriptive Language
an open analog hardware description language
Verilog-AMS Verilog for Analog and Mixed-Signal
an open standard extending Verilog for analog and mixed analog/digital simulation
![Page 7: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/7.jpg)
7
HDLs for Digital Circuit Design• The two most widely-used and well-supported HDL varieties used in industry
are Verilog and VHDL.
Abbreviation Name UseABEL Advanced Boolean Expression
LanguageHardware description language for implementing Boolean expressions
AHDL Altera HDL a proprietary language from Altera
Verilog verification logics most widely-used and well-supported HDL
![Page 8: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/8.jpg)
8
HDL for Printed Circuit Board (PCB) Design
Abbreviation Name UsePHDL PCB HDL a free and open source HDL for
defining printed circuit board connectivity
![Page 9: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/9.jpg)
9
What is VHDL?• The “V” in VHDL is short of yet another acronym:
VHSIC or Very High-Speed Integrated Circuit. The HDL stands for Hardware Description Language.
• VHDL is a programming language that allows one to
model and develop complex digital systems in a dynamic environment.
• VHDL is intended for circuit synthesis as well as circuit simulation.
![Page 10: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/10.jpg)
10
What is VHDL?• A fundamental motivation to use VHDL (or its competitor,
Verilog) is that VHDL is a standard, technology/vendor independent language, and is therefore portable and reusable.
• The two main immediate applications of VHDL are in the– field of Programmable Logic Devices (including CPLDs
and FPGAs) – and in the field of ASICs (Application Specific Integrated
Circuits).
![Page 11: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/11.jpg)
11
What is VHDL?
• Once the VHDL code has been written, it can be used either to implement the circuit in a programmable device (from Altera, Xilinx, Atmel, etc.) or can be submitted to a foundry for fabrication of an ASIC chip.
• Currently, many complex commercial chips
(microcontrollers, for example) are designed using such an approach.
![Page 12: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/12.jpg)
12
Design Flow
• As mentioned in previous slides, one of the major utilities of VHDL is that it allows the synthesis of a circuit or system in a programmable device (PLD or FPGA) or in an ASIC.
• The steps followed during such a project are summarized in this figure.
![Page 13: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/13.jpg)
13
Design Flow• We start the design
by writing the VHDL code, which is saved in a file with the extension .vhd and the same name as its ENTITY’s name.
![Page 14: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/14.jpg)
14
Design Flow• The first step in the
synthesis process is compilation.
• Compilation is the conversion of the high-level VHDL language, which describes the circuit at the Register Transfer Level (RTL), into a netlist at the gate level.
![Page 15: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/15.jpg)
15
Design Flow• The second step is
optimization, which is performed on the gate-level netlist for speed or for area.
• At this stage, the design can be simulated. Finally, a place and-route (fitter) software will generate the physical layout for a PLD/FPGA chip or will generate the masks for an ASIC.
![Page 16: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/16.jpg)
16
Design Flow
• Finally, a place and-route (fitter) software will generate the physical layout for a PLD/FPGA chip or will generate the masks for an ASIC.
![Page 17: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/17.jpg)
17
EDA Tools
• There are several EDA (Electronic Design Automation) tools available for circuit synthesis, implementation, and simulation using VHDL.
• Some tools (place and route, for example) are offered as part of a vendor’s design suite (e.g., Altera’s Quartus II, which allows the synthesis of VHDL code onto Altera’s CPLD/FPGA chips, or Xilinx’s ISE suite, for Xilinx’s CPLD/FPGA chips).
![Page 18: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/18.jpg)
18
EDA Tools
• Other tools (synthesizers, for example), besides being offered as part of the design suites, can also be provided by specialized EDA companies (Mentor Graphics, Synopsis, Synplicity, etc.).
• Examples of the later group are Leonardo Spectrum (a synthesizer from Mentor Graphics), Synplify (a synthesizer from Synplicity), and ModelSim (a simulator from Model Technology, a Mentor Graphics company).
![Page 19: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/19.jpg)
19
Translation of VHDL Code into a Circuit
• A VHDL code consists of ENTITY and ARCHITECTURE.
• ENTITY is description of I/O pins (ports) of the circuit.
• ARCHITECTURE describes how the circuit should function.
![Page 20: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/20.jpg)
20
Translation of VHDL Code into a Circuit• Consider for example a full adder. • Sum bit is computed as • Cout is obtained from
ENTITY
ARCHITECTURE
incbas
ininout cbcabac ...
![Page 21: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/21.jpg)
21
Translation of VHDL Code into a Circuit
• From the VHDL code a physical circuit is inferred.
• However, there are several ways of implementing the equations described in the ARCHITECTURE.
• The actual circuit will depend on the compiler/optimizer being used and, more importantly, on the target technology.
![Page 22: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/22.jpg)
22
Translation of VHDL Code into a Circuit
• For instance, if our target is a programmable logic device (PLD or FPGA) then two possible results (among many others) for cout are illustrated in following figures.
![Page 23: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/23.jpg)
23
Translation of VHDL Code into a Circuit• On the other hand, if our target technology is an
ASIC, then a possible CMOS implementation, at the transistor level, is that of following figure.
![Page 24: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/24.jpg)
24
Circuit Simulation• Following figure contains the simulation results from
the circuit synthesized with the VHDL code, which implements the full-adder unit.
• The input pins (characterized by an inward arrow with an “I” marked inside) and the output pins (characterized by an outward arrow with an “O” marked inside) are those listed in the ENTITY.
![Page 25: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/25.jpg)
25
Design Example#1
0
0
1
1
F(x, y, z)
1
0
1
0
z
00
10
10
00
yx
0
0
0
1
1
0
1
0
11
11
01
01
),,(...... zyxFzyxzyxzyx
• Develop VHDL Code for following logic.
![Page 26: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/26.jpg)
Design Examples#2
• Develop VHDL Code for BCD to 7 segment Display.
26
![Page 27: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/27.jpg)
27
VHDL Code Structure• As depicted in following figure, a standalone piece of
VHDL code is composed of at least three fundamental sections:
![Page 28: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/28.jpg)
28
VHDL Code Structure: Library Declaration• Contains a list of all libraries
to be used in the design. For example: ieee, std, work, etc.
• A LIBRARY is a collection of commonly used pieces of code. Placing such pieces inside a library allows them to be reused or shared by other designs.
![Page 29: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/29.jpg)
29
VHDL Code Structure: Library Declaration• To declare a LIBRARY (that is, to make it visible to the design)
two lines of code are needed, one containing the name of the library, and the other a use clause, as shown in the syntax below.
• At least three packages, from three different libraries, are usually needed in a design:– ieee.std_logic_1164 (from the ieee library),– standard (from the std library), and– work (work library).
![Page 30: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/30.jpg)
30
VHDL Code Structure: Library Declaration• Their declarations are as follows:
![Page 31: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/31.jpg)
31
VHDL Code Structure: ENTITY• An ENTITY is a list with specifications of all input and output pins
(PORTS) of the circuit. Its syntax is shown below.
• The mode of the signal can be IN, OUT, INOUT, or BUFFER.
• IN and OUT are truly unidirectional pins, while INOUT is bidirectional. BUFFER, on the other hand, is employed when the output signal must be used (read) internally.
• The type of the signal can be BIT, STD_LOGIC, INTEGER, etc.
![Page 32: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/32.jpg)
32
VHDL Code Structure: ENTITY• Finally, the name of the entity can be basically any name, except
VHDL reserved words.
• Let us consider the NAND gate. Its ENTITY can be specified as:
• The meaning of the ENTITY above is the following: – The circuit has three I/O pins, being two inputs (a and b, mode IN) and
one output (x, mode OUT). All three signals are of type BIT. The name chosen for the entity was nand_gate.
![Page 33: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/33.jpg)
33
VHDL Code Structure: ARCHITECTURE• The ARCHITECTURE is a description of how the circuit should
behave (function). Its syntax is the following:
• An architecture has two parts: a declarative part (optional), where signals and constants (among others) are declared, and the code part (from BEGIN down).
• The name of an architecture can be basically any name (except VHDL reserved words), including the same name as the entity’s.
![Page 34: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/34.jpg)
34
VHDL Code Structure: ARCHITECTURE• Let us consider the NAND gate again.
• The meaning of the ARCHITECTURE above is the following: – the circuit must perform the NAND operation between the two input
signals (a, b) and assign (‘‘<=’’) the result to the output pin (x). The name chosen for this architecture was myarch.
• In this example, there is no declarative part, and the code contains just a single assignment.
![Page 35: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/35.jpg)
35
Example• Figure shows the diagram of a D-type flip-flop (DFF),
triggered at the rising edge of the clock signal (clk), and with an asynchronous reset input (rst).
• When rst =1, the output must be turned low, regardless of clk. Otherwise, the output must copy the input (that is, q <= d) at the moment when clk changes from ‘0’ to ‘1’.
![Page 36: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/36.jpg)
36
Example• One thing to remember is that VHDL is inherently
concurrent (contrary to regular computer programs, which are sequential).
• So to implement any clocked circuit (flip-flops, for example) we have to ‘‘force’’ VHDL to be sequential.
• This can be done using a PROCESS, as shown in next slide.
![Page 37: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/37.jpg)
37
Process• A PROCESS is a sequential section of VHDL code. It is
characterized by the presence of IF, WAIT, CASE, or LOOP, and by a sensitivity list .
• A PROCESS must be installed in the main code, and is executed every time a signal in the sensitivity list changes.
• Its syntax is shown below.
![Page 38: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/38.jpg)
38
![Page 39: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/39.jpg)
39
Simulation Results
![Page 40: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/40.jpg)
40
Example#2
• DFF plus NAND Gate
temp
Hint
![Page 41: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/41.jpg)
41
VHDL Code
![Page 42: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/42.jpg)
42
Example#3
• DFF plus NAND Gate and reset input
rst
![Page 43: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/43.jpg)
43
Example#4
• Multiplexers1 s0 Y
0 0 a
0 1 b
1 0 c
1 1 d
dsscssbssassy ........ 21212121
![Page 44: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/44.jpg)
44
VHDL Code
![Page 45: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/45.jpg)
45
WHEN/ELSE Command
• Syntax
• Example
![Page 46: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/46.jpg)
46
Example#5
• Another way to do it
s1 s0 Y
0 0 a
0 1 b
1 0 c
1 1 d
![Page 47: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/47.jpg)
47
VHDL Code
![Page 48: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/48.jpg)
48
WITH WHEN/ELSE Command
• Syntax
• Example
![Page 49: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/49.jpg)
49
![Page 50: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/50.jpg)
50
Example#6
• In multiplexer sel could be an integer
sel Y0 a
1 b
2 c
3 dSel(0:3)
![Page 51: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/51.jpg)
51
Solution-1: WHEN/ELSE Command
![Page 52: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/52.jpg)
52
Solution-2: WITH WHEN/ELSE Command
![Page 53: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/53.jpg)
53
Example#7
s2 s1 s0 y0 0 0 S0 0 1 T0 1 0 U0 1 1 V1 0 0 W1 0 1 X1 1 0 Y1 1 1 Z
MUX
Sel(0:7)
y
S
Z
![Page 54: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/54.jpg)
54
Example#8
• Multiplexer
![Page 55: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/55.jpg)
55
![Page 56: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/56.jpg)
56
Example#9
• Write down VHDL Code of Multiplexer using WHEN/ELSE and WITH WHEN/ ELSE commands.
![Page 57: Advanced FPGA Based System Design](https://reader031.vdocument.in/reader031/viewer/2022012922/5681637f550346895dd46000/html5/thumbnails/57.jpg)
Example#10• Develop VHDL Code using WHEN/ELSE and WITH
WHEN/ELSE for BCD to 7 segment Display.
57