Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Contents
Tri-state logic, high-impedance state Z
Variables versus signals in VHDL
The notorius latches
Several synthesis examples here and there
Example codes can be downloaded from the course web
site
Arto Perttula
19.1.2016
About Exam
For-loop in HDL: known bounds, parallel HW, single cycle (or combinatorial delay)
RTL vs. structural is about style: if/for/case vs. instantiations, not necessarily about the abstraction level
Mark signal tansitions clearly and use lines for 1-bit signals
Like this, s hr
Arto Perttula
19.1.2016
19.1.2016
Arto Perttula
19.1.2016
Channel Control
Only two communicating blocks in the simplest case
During transfer
master initiates transfers
slave accepts transfers and responds to them
In some cases, a certain block can act both as master and slave
Many buses are shared multimaster buses
shared = more than 2 units
multimaster = more than 1 master
arbitration mechanism decides which has the ownership
Arto Perttula
19.1.2016
Bidirectional IO Port
logical 0 or 1 value
hi-Z (high-impedance), aka. tri-state
b)
19.1.2016
Arto Perttula
Fig. R. Reese
Conditions (such as if-else and case) are synthesized differently with tri-state logic!
Arto Perttula
19.1.2016
10
1.
2.
19.1.2016
11
Example: tri_state1.vhd
reg_z: process (clk, rst_n)
begin
if rst_n = '0' then
test0_out <= '0';
elsif clk'event and clk = '1'
then
if ctrl_in = '1' then
test0_out <= data_in;
else
test0_out <= 'Z';
end if;
end if;
end process reg_z;
Arto Perttula
19.1.2016
12
tri_state1 HW (OK)
Arto Perttula
19.1.2016
13
Arto Perttula
14
Propagation
Z cannot propagate through flip-flop in real circuit
Z cannot propagate through real logic gates
Physical DFFs or gates output will be undefined if its
input is Z (=floating somewhere between GND and
VDD)
19.1.2016
15
tri_state2.vhd
reg_z _ process -- similar to previous, but
-- intermediate signal test0_r used instead
-- of output. Registers gets either data_in or Z
test0_out <= test0_r;
reg_z_bad: process (clk, rst_n)
begin -- process reg_z
if rst_n = '0' then
test1_out <= '0';
elsif clk'event and clk = '1' then
test1_out <= test0_r;
end if;
end process reg_z_bad;
comb_z_bad: process (test0_r, enable_in)
begin -- process comb_z
test2_out <= test0_r and enable_in;
end process comb_z_bad;
Arto Perttula
19.1.2016
16
Arto Perttula
17
Reading
b
b
Arto Perttula
something_else
19.1.2016
0
18
tri_state3.vhd
test0_out <= std_logic_vector(accu0_r);
test1_out <= std_logic_vector(accu1_r);
test_z_bad : process (clk, rst_n)
begin
if rst_n = '0' then
accu0_r <= (others => '0');
elsif clk'event and clk = '1' then
if data_in /= "ZZZZ" then
accu0_r <= accu0_r
+ signed(data_in);
end if;
end if;
end process test_z_bad;
Arto Perttula
19.1.2016
19
Arto Perttula
19.1.2016
20
tri_state3 HW on Quartus
Arto Perttula
19.1.2016
21
Tri-State Summary
Lets the signal voltage float and some other device may drive it
Assigned by writing Z to the signal/port
Cannot be propagated through real DFFs or gates
Just for chips I/O pins and not between logic modules on chip
Must use separate valid signal to see when signal can be read safely
Arto Perttula
19.1.2016
22
19.1.2016
23
Variables in VHDL
19.1.2016
24
1.
2.
+1
+
sum_v
Arto Perttula
sum_r
if...
19.1.2016
25
19.1.2016
26
comb
Signal assignment:
Recommendations:
2.
Assign signals in every if-branch or give them default value and override it later
It is not recommended to read a value that is written in the same combinatorial process, otherwise, signal
must be on sensitivity list and process must iterate
Write a complete sensitivity list
Variable assignment:
19.1.2016
27
1.
Registers are created for all signal and port assignments unless there is a redundancy that can be merged
with another register
Very simple! Easy to remember and analyze
2.
Variable assignment:
a)
b)
c)
Some will imply many, some will imply one, some will imply none
The designer does not master the HW that he/she is designing
19.1.2016
28
Arto Perttula
19.1.2016
29
19.1.2016
30
31
19.1.2016
32
HW of var2.vhd
Arto Perttula
19.1.2016
34
19.1.2016
35
Arto Perttula
19.1.2016
36
HW of var3.vhd
37
19.1.2016
38
ABOUT LATCHES
Arto Perttula
19.1.2016
39
Various types
Some are unnecessarily difficult to use
19.1.2016
19.1.2016
41
19.1.2016
42
+1
S
X
Q
Latches
G
D
en
Lets say these latches contain some value that we want to increment
ALU
The ALU should read the current latch value Q via input X
It applies the increment operation G = X+1
The incremented value is stored back into the latches
At this point, we have to stop the cycle, so the latch value doesnt get incremented again by accident
One convenient way to break the loop is to disable the latches by driving en=0
Arto Perttula
19.1.2016
43
S
X
Q
Latches
enable
generation
D
en
The problem is exactly when to disable the latches. You have to wait long enough for the ALU to
produce its output, but no longer.
ALU
But different ALU operations have different delays. For instance, arithmetic operations might go through an
adder, whereas logical operations dont.
Changing the ALU implementation, such as using a carry-lookahead adder instead of a ripple-carry adder,
also affects the delay
In general, its very difficult to know how long operations take, and how long latches should be
enabled for
If you take the max. delay you could as well use regular edge-triggered DFF
Arto Perttula
19.1.2016
44
=D latch
transparent
latched
19.1.2016
45
19.1.2016
46
1.
2.
3.
19.1.2016
47
19.1.2016
48
Conclusions
19.1.2016
49