Beruflich Dokumente
Kultur Dokumente
Copyright c 2002-2007
1 of 59
Goals
To learn the basics of RTL synthesis. To be able to synthesize a digital system, given its VHDL model. To be able to relate VHDL code to its synthesized output. To appreciate the fact that synthesis is very sensitive to how the VHDL code is written! To learn how to write VHDL code that is efcient at synthesis. To get an idea about the synthesis of integer subtypes. To understand the synthesis of combinational logic. To understand the use of VHDL in synthesizing sequential logic. To get familiar with synthesizable process templates. To learn the cases when latches and ip-ops are inferred. To know how tristate elements are inferred.
Copyright c 2002-2007 VHDL: RTL Synthesis Basics 2 of 59
RTL Synthesis
Synthesis is an automatic method of converting a higher level of abstraction (RTL) to a lower level of abstraction (gate level netlists). Synthesis produces technology-specic implementation from technology-independent VHDL description. Not all VHDL can be used for synthesis. There are the VHDL subset for synthesis and synthesis style description. Synthesis is very sensitive to how the VHDL code is written! Gate level netlists Technology libraries are optimized for RTL The area, speed, description synthesis power, or process testability. Design constraints
Copyright c 2002-2007
Copyright c 2002-2007
4 of 59
Control signals
Copyright c 2002-2007
5 of 59
It is recommended to use RTL code whenever possible as it provides the following: 1. Readable code 2. Ability to use same code for synthesis and simulation 3. Portable code for migration to different technologies 4. Resusable code for later designs
Copyright c 2002-2007
6 of 59
Copyright c 2002-2007
7 of 59
0 1 2 3 s[1:0] x[3:0]
8 of 59
Copyright c 2002-2007
9 of 59
a b c d
t1 z t2
Copyright c 2002-2007
10 of 59
t1
t2
t1
v s4
This code contains a feedback. v is read by the process and then assigned by it. v needs to retain its value for the next process run. Compiler might generate an error, produce the previous circuit, or infer a latch.
Copyright c 2002-2007 VHDL: RTL Synthesis Basics 13 of 59
14 of 59
Copyright c 2002-2007
15 of 59
NORs are used instead of ANDs for area/speed optimizations. When the for-loop is expanded, we get the following IF statements:
IF IF IF IF temp temp temp temp = = = = 0 1 2 3 THEN THEN THEN THEN z(0) z(1) z(2) z(3) <= <= <= <= d; d; d; d; ELSE ELSE ELSE ELSE z(0) z(1) z(2) z(3) <= <= <= <= 0; 0; 0; 0; END END END END IF; IF; IF; IF; 16 of 59
Copyright c 2002-2007
Inferring Latches
A transparent latch will be inferred while synthesizing a process in two situations: 1. Some branches of IF or CASE statements are incompletely specied and no default output values are dened before these two statements. 2. A clock level detection condition is checked in IF or WAIT (or even in signal assignment statement (conditional or selective)). In other words, a latch is inferred if a path through the code exists such that a particular variable or signal is not assigned a new value. The latch will hold the value of that variable or signal. On the other hand, a latch will not be generated if a variable or signal is assigned a value in all branches of the IF or CASE statements.
Copyright c 2002-2007 VHDL: RTL Synthesis Basics
17 of 59
Synthesis of IF Statements
IF statements synthesize to either elementary gates or muxs.
IF s THEN y <= a; ELSE y <= b; END IF;
b s a y
s b a 0 1 y
Copyright c 2002-2007
18 of 59
m f
0 1 r
VHDL: RTL Synthesis Basics
e x
Copyright c 2002-2007
19 of 59
z y x b
0 0 1 v 1 v
Copyright c 2002-2007
20 of 59
ARCHITECTURE model OF ct IS BEGIN p2: PROCESS (a, b, c, x, y, z) IS BEGIN f <= 0; x IF x = 0 THEN y f <= a; z ELSIF y = 0 THEN f <= b; ELSIF z = 1 THEN 0 0 f <= c; END IF; 1 c END PROCESS p2; END ARCHITECTURE model; Copyright c 2002-2007
a b 0 1
0 1
21 of 59
22 of 59
z[2]
z[0] z[1]
23 of 59
en
clk qn
qn
Optimization uses the qn output instead of installing another latch. Rule: Synthesis ignores inertial and transport delays.
Copyright c 2002-2007 VHDL: RTL Synthesis Basics 24 of 59
v d q
clk qn
v is not assigned in the ELSE branch of IF statement. This implies a latch to keep the value of v when b = 1.
Copyright c 2002-2007 VHDL: RTL Synthesis Basics 25 of 59
m n d q
clk qn
No need to latch m since the variable is used after it is dened. A latch is needed for n since its old value is used every process run.
Copyright c 2002-2007 VHDL: RTL Synthesis Basics 26 of 59
z[0]
clk qn
z[1]
clk qn inc
27 of 59
Copyright c 2002-2007
28 of 59
0 1 2 3 s[1:0] x[3:0]
Copyright c 2002-2007
29 of 59
Copyright c 2002-2007
30 of 59
Copyright c 2002-2007
31 of 59
a[1]
. . . CASE a IS WHEN 0 => y <= WHEN 1 => y <= WHEN 2 => y <= WHEN 3 => y <= WHEN 4= > y <= WHEN 5 => y <= WHEN OTHERS => END CASE; END IF; END PROCESS pd; END ARCHITECTURE design;
Copyright c 2002-2007
a[2]
32 of 59
current_state[0]
clk qn en
VDD current_state[1]
z[1] d q
clk qn en
Copyright c 2002-2007
34 of 59
1; 2; 3; 4;
Copyright c 2002-2007
35 of 59
Copyright c 2002-2007
36 of 59
Inferring Flip-Flops
A ip-op is inferred in a process if the following conditions are all satised: A clock edge detection condition is used in IF or WAIT statements. The process sensitivity list includes the clock and nothing else except set and reset signals. No other statements should be written before or after the IF/WAIT statement in the process, except reset and set statements. Multiple IF statements will selectively infer ip-ops. Examples of using clock edge detection conditions:
WAIT UNTIL WAIT UNTIL IF clock = IF falling
Copyright c 2002-2007
clock = 1 AND clockevent; rising edge (clock); 0 AND clockevent THEN edge (clock) THEN
VHDL: RTL Synthesis Basics 38 of 59
q qn
clk
Copyright c 2002-2007
39 of 59
Copyright c 2002-2007
40 of 59
The WAIT statement delays the execution of the whole process until its expression becomes true. This means that all other variable/signal assignment statements in the process will infer ip-ops.
Copyright c 2002-2007
41 of 59
42 of 59
Copyright c 2002-2007
43 of 59
q qn
reg_a[2]
q qn
reg_a[1]
data[0]
q qn
reg_a[0]
Copyright c 2002-2007
44 of 59
d clock
qn reset
set d
clock
qn
45 of 59
47 of 59
Example.28: (Cont.)
unsigned;
49 of 59
Copyright c 2002-2007
50 of 59
u, d) IS BEGIN
Copyright c 2002-2007
52 of 59
in0 in1
sel 0 1 out d q c
qn reset
Copyright c 2002-2007
54 of 59
Copyright c 2002-2007
57 of 59
Copyright c 2002-2007
58 of 59
clk qn
latchout
clk qn
0'
q qn
d clock
q qn
ffout
Copyright c 2002-2007
59 of 59