Lec8 - Slides
Lec8 - Slides
Lecture 8
• library clause:
• Defines the library name that can be reference
• Is a symbolic name to a path/directory
• use clause
• Specifies the package and object in the library that
you have specified in the library clause
• All packages used must be compiled
The WORK library
library work; -- library is where we save our design
use work.all; -- (.vhd file & compiler & simulator etc files)
16
Counters
• Timing Diagram
17
Counters
• After (D-type) flip-flops and registers, arguably the most
important sequential component for digital designs is the
counter
• Note that counters are sometimes implemented using
type integer: this is actually not bad design practice in
itself, but requires moderately advanced VHDL skills
• Type integer is often interpreted as a 32-bit bus by
synthesis tools, creating a 32-bit counter (rarely needed) –
there are strong restrictions on the use of this type for
synthesizable VHDL
• In this module, you should never use type integer for
counters, but always type unsigned
Why do we need
unsigned?
Counters – 8-bit unlimited
entity CNT_8BIT is
port (CLK, EN, RST : in STD_LOGIC;
Q : out UNSIGNED(7 downto 0));
end CNT_8BIT;
25
Shift Registers
26
Shift Registers
27
Serial Shift Register (SR)
Q3 D3 Q2 D2 Q1 D1 Q0 D0 DIN
MSB LSB
< < < <
CLK
28
SS Left Shift – 1
Q3 D3 Q2 D2 Q1 D1 Q0 D0 DIN
MSB LSB
< < < <
CLK
29
SS Left Shift – 2
Q3 D3 Q2 D2 Q1 D1 Q0 D0 DIN
MSB LSB
< < < <
CLK
30
SS Left Shift – 3
Q3 D3 Q2 D2 Q1 D1 Q0 D0 DIN
MSB LSB
< < < <
CLK
31
SS Left Shift – 4
Q3 D3 Q2 D2 Q1 D1 Q0 D0 DIN
MSB LSB
< < < <
CLK
32
Bi-Directional Shift Register (see lecture 4)
Q3 Q2 Q1 Q0
33
Arrays
• An array in VHDL is a type that represents collection of
objects of the same type. Its declaration must include the size
and the type of object:
type myarray is array (31 downto 0) of integer;
signal array1: myarray;
is equivalent to
type my_vector_type is array (31 downto 0) of STD_LOGIC;
signal my_vector : my_vector_type;
and in particular:
array1 <= (others => '0'); -- reset