VHDL Slides
VHDL Slides
E. Casas, Page 1 of 56
November 4, 1998
Introduction to VHDL
E. Casas, Page 2 of 56
November 4, 1998
VHDL
a Very complicated Hardware Description Language
luckily, only a small subset is needed for design VHDL is used for design (covered this morning) and simulation (covered this afternoon)
Introduction to VHDL
E. Casas, Page 3 of 56
November 4, 1998
Outline
Introduction (AND gate)
Vectors and Buses Selected Assignment (3-to-8 decoder) Conditional Assignment (4-to-3 priority encoder) Sequential Circuits (ip-op) State Machines (switch debouncer) Signed and Unsigned Types (3-bit counter)
University of British Columbia
Introduction to VHDL
E. Casas, Page 4 of 56
November 4, 1998
Introduction to VHDL
E. Casas, Page 5 of 56
November 4, 1998
Introduction to VHDL
E. Casas, Page 6 of 56
November 4, 1998
VHDL Syntax
not case sensitive
comments begin with -statements end with ; signal/entity names: letter followed by letters, digits, _ details on library and use statements later
Introduction to VHDL
E. Casas, Page 7 of 56
November 4, 1998
the entity declares the input and output signals the architecture describes what the device does every statement in the architecture executes concurrently
Introduction to VHDL
E. Casas, Page 8 of 56
November 4, 1998
Introduction to VHDL
E. Casas, Page 9 of 56
November 4, 1998
Exercise (Expressions)
Exercise: Write the VHDL description of a half-adder, a circuit that computes the sum, sum, and carry, carry, of two one-bit numbers, a and b.
Introduction to VHDL
E. Casas, Page 10 of 56
November 4, 1998
Vectors
one-dimensional arrays used to model buses
a : std_logic_vector (3 downto 0) ;
a <= "0010" ;
Introduction to VHDL
E. Casas, Page 11 of 56
November 4, 1998
Vector Operations
can take slices (e.g. x(3 downto 2))
can concatenate (e.g. a & b) logic operators (e.g. a and b) apply bit-by-bit
Introduction to VHDL
E. Casas, Page 12 of 56
November 4, 1998
Exercise (Vectors)
Exercise: Write a VHDL expression that shifts x, an 8bit std logic vector declared as x : std logic vector (7 downto 0) ;, left by one bit and sets the least-signicant bit to zero.
Introduction to VHDL
E. Casas, Page 13 of 56
November 4, 1998
Selected Assignment
models operation of multiplexer
one value selected by controlling expression can implement arbitrary truth table always use an others clause we can declare local signals in architectures
Introduction to VHDL
E. Casas, Page 14 of 56
November 4, 1998
Introduction to VHDL
E. Casas, Page 15 of 56
November 4, 1998
Introduction to VHDL
E. Casas, Page 16 of 56
November 4, 1998
Introduction to VHDL
E. Casas, Page 17 of 56
November 4, 1998
Conditional Assignment
models if/then/else, but is concurrent
expressions tested in order only value for rst true condition is assigned
Introduction to VHDL
E. Casas, Page 18 of 56
November 4, 1998
Introduction to VHDL
E. Casas, Page 19 of 56
November 4, 1998
= = = =
1 1 1 1
Introduction to VHDL
E. Casas, Page 20 of 56
November 4, 1998
4-to-3 Encoder
Introduction to VHDL
E. Casas, Page 21 of 56
November 4, 1998
Introduction to VHDL
E. Casas, Page 22 of 56
November 4, 1998
Sequential Circuits
the process statement can generate ip-ops or registers
Introduction to VHDL
E. Casas, Page 23 of 56
November 4, 1998
Introduction to VHDL
E. Casas, Page 24 of 56
November 4, 1998
Introduction to VHDL
E. Casas, Page 25 of 56
November 4, 1998
Schematic of dff
the synthesized result:
Introduction to VHDL
E. Casas, Page 26 of 56
November 4, 1998
Introduction to VHDL
E. Casas, Page 27 of 56
November 4, 1998
State Machines
use combinational logic to compute next state and outputs
Introduction to VHDL
E. Casas, Page 28 of 56
November 4, 1998
Introduction to VHDL
E. Casas, Page 29 of 56
November 4, 1998
raw=1
01 raw=0 output 0 0 1
10
raw=1
Introduction to VHDL
E. Casas, Page 30 of 56
November 4, 1998
Introduction to VHDL
E. Casas, Page 31 of 56
November 4, 1998
Introduction to VHDL
E. Casas, Page 32 of 56
November 4, 1998
Introduction to VHDL
E. Casas, Page 33 of 56
November 4, 1998
Schematic of Debouncer
Introduction to VHDL
E. Casas, Page 34 of 56
November 4, 1998
Introduction to VHDL
E. Casas, Page 35 of 56
November 4, 1998
Arithmetic Types
allow us to treat logic values as numbers
arithmetic and comparison operators available multiply and divide may not synthesize
Introduction to VHDL
E. Casas, Page 36 of 56
November 4, 1998
Introduction to VHDL
E. Casas, Page 37 of 56
November 4, 1998
Introduction to VHDL
E. Casas, Page 38 of 56
November 4, 1998
Introduction to VHDL
E. Casas, Page 39 of 56
November 4, 1998
Introduction to VHDL
E. Casas, Page 40 of 56
November 4, 1998
Components
allows design re-use
like an entity, a component denes interface, not functionality denitions usually saved in packages (les) packages are stored in libraries (directories)
Introduction to VHDL
E. Casas, Page 41 of 56
November 4, 1998
package flipflops is component rs port ( r, s : in bit ; q : out bit ) ; end component ; end flipflops ;
Introduction to VHDL
E. Casas, Page 42 of 56
November 4, 1998
Introduction to VHDL
E. Casas, Page 43 of 56
November 4, 1998
Using Components
a component instantiation statement:
places a copy of the component in the design is a concurrent statement describes how the component connects to other signals is structural design
Introduction to VHDL
E. Casas, Page 44 of 56
November 4, 1998
-- define an xor2 component in a package library ieee ; use ieee.std_logic_1164.all ; package xor_pkg is component xor2 port ( a, b : in std_logic ; x : out std_logic ) ; end component ; end xor_pkg ;
Introduction to VHDL
E. Casas, Page 45 of 56
November 4, 1998
Introduction to VHDL
E. Casas, Page 46 of 56
November 4, 1998
Introduction to VHDL
E. Casas, Page 47 of 56
November 4, 1998
Introduction to VHDL
E. Casas, Page 48 of 56
November 4, 1998
Introduction to VHDL
E. Casas, Page 49 of 56
November 4, 1998
Type Declarations
can declare new signal types (e.g. new bus widths, enumeration types for state machines)
Introduction to VHDL
E. Casas, Page 50 of 56
November 4, 1998
package dsp_types is type mode is (slow, medium, fast) ; subtype sample is std_logic_vector (7 downto 0) ; end dsp_types ;
Introduction to VHDL
E. Casas, Page 51 of 56
November 4, 1998
Tri-State Buses
tri-state (high-impedance) often used in buses
Introduction to VHDL
E. Casas, Page 52 of 56
November 4, 1998
Introduction to VHDL
E. Casas, Page 53 of 56
November 4, 1998
Introduction to VHDL
E. Casas, Page 54 of 56
November 4, 1998
Introduction to VHDL
E. Casas, Page 55 of 56
November 4, 1998
Introduction to VHDL
E. Casas, Page 56 of 56
November 4, 1998