Beruflich Dokumente
Kultur Dokumente
c 2002-2012
Copyright
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 efficient 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 flip-flops are inferred.
To know how tristate elements are inferred.
c 2002-2012
Copyright
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-specific 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
c 2002-2012
Copyright
Gate-level
netlists
Design
attributes
3 of 59
c 2002-2012
Copyright
4 of 59
Data in
Combinational
logic
c 2002-2012
Copyright
Control signals
5 of 59
c 2002-2012
Copyright
6 of 59
a:
b:
c:
d:
e:
c 2002-2012
Copyright
int 1;
int 2;
int 3;
int 4;
integer;
------
7 of 59
0
1
x[3:0]
2
3
s[1:0]
8 of 59
c 2002-2012
Copyright
9 of 59
c 2002-2012
Copyright
a
b
t1
z
c
d
t2
10 of 59
t1
t2
t1
11 of 59
v
s4
12 of 59
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.
c 2002-2012
Copyright
13 of 59
14 of 59
c 2002-2012
Copyright
15 of 59
.
.
.
FOR j IN zrange LOOP
IF temp = j THEN
z(j) <= d;
ELSE
z(j) <= 0;
END IF;
END LOOP
END PROCESS dm;
END ARCHITECTURE rtl;
a[0]
z[3]
a[1]
z[2]
z[1]
z[0]
temp
temp
temp
temp
=
=
=
=
0
1
2
3
c 2002-2012
Copyright
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
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
specified and no default output values are defined 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.
c 2002-2012
Copyright
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
s
y
c 2002-2012
Copyright
18 of 59
c 2002-2012
Copyright
e
x
19 of 59
z
y
x
b
c 2002-2012
Copyright
0
0
1
f
v
20 of 59
IN bit;
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;
c 2002-2012
Copyright
a
b
1
1
21 of 59
22 of 59
priority
sel[0:3]
z[0:2]
z[2]
z[0]
z[1]
23 of 59
en
clk qn
qn
24 of 59
clk qn
25 of 59
m
n
q
d
clk qn
26 of 59
z[0]
clk qn
z[1]
clk qn
inc
27 of 59
c 2002-2012
Copyright
28 of 59
c 2002-2012
Copyright
a[3:0]
b[3:0]
c[3:0]
d[3:0]
x[3:0]
s[1:0]
29 of 59
outputs
En
a2
a1
a0
y5
y4
y3
y2
y1
y0
c 2002-2012
Copyright
30 of 59
c 2002-2012
Copyright
31 of 59
a[2:0]
a[0]
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;
c 2002-2012
Copyright
a[2]
o"01";
o"02";
o"04";
o"10";
o"20";
o"40";
y <= o"00";
y[0]
y[1]
y[2]
y[3]
y[4]
y[5]
y[5:0]
32 of 59
33 of 59
z[0]
d
clk qn
en
VDD
current_state[1]
z[1]
d
clk qn
en
c 2002-2012
Copyright
34 of 59
c 2002-2012
Copyright
y <=
y <=
y <=
y <=
NULL;
1;
2;
3;
4;
35 of 59
36 of 59
.
.
.
pc: PROCESS (screencolor, number, a) IS
VARIABLE y var: unsigned (3 DOWNTO 0) := "0000";
BEGIN
CASE screencolor IS
WHEN red
=>
y var := a;
WHEN green
=>
y var := a + 1;
WHEN blue
=>
CASE number IS
WHEN "00"
=> y var := a;
WHEN "01"
=> y var := a + 1;
WHEN "10"
=> y var := a + 2;
WHEN OTHERS => NULL;
END CASE;
WHEN OTHERS =>
y var:= a + 1;
END CASE;
y <= y var;
END PROCESS pc;
END ARCHITECTURE rtl;
37 of 59
Inferring Flip-Flops
A flip-flop is inferred in a process if the following conditions are all
satisfied:
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 flip-flops.
Examples of using clock edge detection conditions:
WAIT UNTIL
WAIT UNTIL
IF clock =
IF falling
c 2002-2012
Copyright
38 of 59
clk
qn
ARCHITECTURE ff OF ff IS
BEGIN
f: PROCESS (clk) IS
BEGIN
IF rising edge (clk) THEN
s <= NOT x;
END IF;
END PROCESS f;
END ARCHITECTURE ff;
c 2002-2012
Copyright
39 of 59
PROCESS IS BEGIN
WAIT UNTIL clock condition;
-- Synchronous logic described which is
-- executed when clock level or edge occurs.
END PROCESS pw;
c 2002-2012
Copyright
40 of 59
UNTIL
UNTIL
UNTIL
UNTIL
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 flip-flops.
c 2002-2012
Copyright
41 of 59
42 of 59
c 2002-2012
Copyright
43 of 59
reg_a[3]
qn
clk
data[2]
reg_a[2]
qn
en
data[1]
reg_a[1]
qn
data[0]
reg_a[0]
qn
c 2002-2012
Copyright
44 of 59
d
clock
qn
reset
c 2002-2012
Copyright
set
d
clock
qn
45 of 59
46 of 59
47 of 59
48 of 59
.
.
PROCEDURE counting( SIGNAL load: bit; SIGNAL start, stop:
SIGNAL count: INOUT unsigned) IS
BEGIN
IF load = 1 THEN
count <= start;
ELSIF count < stop THEN
count <= count + 1;
ELSE
count <= count + 0;
END IF;
END PROCEDURE counting;
BEGIN
pc: PROCESS (clock, reset) IS BEGIN
IF reset = 1 THEN
count <= (OTHERS => 0);
ELSIF clock = 1 and clockevent THEN
counting (load, start, stop, count);
END IF;
END PROCESS pc;
END ARCHITECTURE rtl;
c 2002-2012
Copyright
unsigned;
49 of 59
u/inc
0
[c]
1
[c]
d
d/dec
Notes:
When an input is not specified on an FSM, it is a dont care.
When an output is not specified on an FSM, it is a zero value.
c 2002-2012
Copyright
50 of 59
51 of 59
.
.
ns: PROCESS (current state,
CASE current state IS
WHEN 0 =>
c <= 0; -- Moore
IF u = 1 THEN
inc <= 1; dec
ELSE
inc <= 0; dec
END IF;
WHEN 1 =>
c <= 1;
IF d = 1 THEN
inc <= 0; dec
ELSE
inc <= 0; dec
END IF;
END CASE;
END PROCESS ns;
END ARCHITECTURE fsm;
c 2002-2012
Copyright
u, d) IS BEGIN
output
<= 0; next state <= 1;
<= 0; next state <= 0;
52 of 59
inc
dec
u
d
clk
in0
in1
sel
0
1
out
qn
reset
reset
c 2002-2012
Copyright
53 of 59
c 2002-2012
Copyright
54 of 59
55 of 59
d_in[3:0]
d_in(3)
d_out(3)
d_in(2)
d_in(1)
d_out(2)
d_in(3)
d_in(2)
d_in(1)
d_in(0)
en
c 2002-2012
Copyright
d_out(1)
d_out(0)
d_out[3:0]
56 of 59
c 2002-2012
Copyright
57 of 59
c 2002-2012
Copyright
58 of 59
clk qn
c 2002-2012
Copyright
latchout
clk qn
0'
q
qn
d
clock
ffout
qn
59 of 59