VHDL Slide Nectec PDF
VHDL Slide Nectec PDF
ASIC
A B
C
RTL code
ASIC
Test synthesis
Each major component is modeled at the
A B
gate level and the design is simulated again
for timing, functionality and performance.
C
ASIC
Layout synthesis
RTL
Logic
Layout
Slower More detailed
simulation/entry
VHDL Application Workshop page 10
The Benefits of Using VHDL
n Design at a higher level
u Find problems earlier
n Implementation independent
u Last minute changes
u Delay implementation decisions
n Flexibility
u Re-use
u Choice of tools, vendors
n Language based
u Faster design capture
u Easier to manage
component
Entity VHDL Entity
architecture architecture
configuration Compiler configuration
package package
VHDL 93 ! Can now optionally include the reserved word entity after the reserved
word end in the entity declaration
VHDL Application Workshop page 16
Entity declaration example
entity MUX is
IN0
port ( IN0, IN1, SEL : in bit;
OUTPUT : out bit );
IN1 OUTPUT
end MUX; SEL
VHDL 93 ! Can now optionally include the reserved word architecture after the
reserved word end in the entity declaration
n Package declaration
u Subprogram declarations
u Type declarations
u Component declarations
u Deferred constant declaration
n Package Body
u Subprogram body
u Defered constant value
A N_SUM
SUM
B
u1 u2
N_CARRY2
n In package “ Std_Logic_1164”
n “std_logic” has same values as “std_ulogic”
std_logic std_ulogic
std_logic_vector std_ulogic_vector
entity AND2 is
port ( A_BIT, B_BIT : in bit;
Z_BIT : out bit );
end AND2;
architecture RTL of AND2 is
begin A_BIT
Z_BIT <= A_BIT and B_BIT; B_BIT
Z_BIT
end RTL;
Equivalent to
A_BUS(2)
B_BUS(2) Z_BUS(2)
A_BUS(1)
Z_BUS(3) <= A_BUS(3) and B_BUS(3); B_BUS(1) Z_BUS(1)
Z_BUS(2) <= A_BUS(2) and B_BUS(2);
Z_BUS(1) <= A_BUS(1) and B_BUS(1);
A_BUS(0)
Z_BUS(0)
B_BUS(0)
Z_BUS(0) <= A_BUS(0) and B_BUS(0);
entity ADDER is
port ( A, B : in integer range 0 to 7 ;
Z : out integer range 0 to 15 ) ; a b
end ADDER;
architecture ARITHMETIC of ADDER is +
begin
Z <= A + B ;
end ARITHMETIC; z
Syntax : if
if condition then
sequential_statements
...
end if; condition ture
Sequential
Example Statements
false
if (A = ‘1’) then
COUNT := COUNT + 1 ;
end if; end if
...
else
sequential_statements false condition ture
end if;
Sequential Sequential
if (A = ‘1’) then
COUNT := COUNT + 1 ; end if
else
COUNT := COUNT - 1 ;
end if;
Sequential
condition ture
Statements
Example Sequential
Statements
if (A = ‘1’) then
COUNT := COUNT + 1 ;
false
end if;
Z <= C + X;
n Concurrent X <= A + B;
n Order independent
n What you write is what you get . . .
A
+ X
B
+ Z
C
Y
X <= X + Y;
+ X
Z <= A + B;
Z <= C + D; A
+
B ? Z
C
+
D
n Enumerated types
n Subtypes
n Composite types
u Arrays
u Array of array
u Record
Beware !
Sythesis tools usually offer a way to map each enumeration to a bit pattern
aggregates
BYTE <= ( 7 => ‘1’, 5 downto 1 => ‘1’, 6 => B_BIT, OTHERS => ‘0’ );
Beware !
Some low cost synthesis tools may not support aggregates
Syntax :
subtype subtype_name is base_type range range_constraint;
Example
type WORD is array (31 downto 0) of bit;
subtype NIBBLE is WORD range 3 downto 0;
subtype BYTE is WORD range 7 downto 0;
subtype MY_BUS is WORD range 15 downto 0;
Example
type WORD8 is array (1 to 8) of bit; Equivalent statements
type WORD8 is array (integer range 1 to 8) of bit;
type BYTE is array (7 downto 0) of bit;
type WORD is array (31 downto 0) of bit;
type MEMORY is array (0 to 4095) of word;
type T_CLOCK_TIME is array (3 downto 0) of integer;
Beware !
n Size of arrary on left and right must be equal
Beware !
The slice direction must be the same as the signal declaration
BYTE(5 downto 2) <= A_BUS;
Z_BUS(0 to 1) <= ‘0’ & B_BIT;
VHDL Application Workshop page 110
Multi-Dimensional Arrays
b7 b6 b5 b4 b3 b2 b1 b0
Parity (ODD)
data nibble A
‘1’ (high byte)
type T_PACKAGE is record
BYTE_ID : bit;
PARITY : bit;
ADDRESS : integer range 0 to 3;
DATA : bit_vector (3 downto 0 );
end record;
signal TX_DATA, RX_DATA : T_PACKAGE;
...
RX_DATA <= TX_DATA;
TX_DATA <= ( ‘1’, ‘0’, 2, “0101”);
TX_DATA.ADDRESS <= 3;
Reference name record
VHDL Application Workshop page 113
Overloading
std_ulogic_vector
std_ulogic_vector n Re-define operators
+
std_ulogic_vector n Different data types
n Called in context
std_ulogic_vector
std_ulogic_vector
+
integer
integer
std_ulogic_vector
+
std_ulogic_vector
Sensitivity list
process (A, B, SEL) process (EN, D)
begin begin
if (SEL = ‘1’) then if (EN = ‘1’) then
Z <= A; Q <= D;
else end if;
Z <= B; end process;
end if;
end process;
What is the value of Q if EN = ‘0’ ?
VHDL Library
Simulation
Library Synthesis
n Sophisticated testbench
u Models environment around design
Testbench Design to u Talks to design
(environment) verify
u Evolves towards boards model
Testbench Design to
(environment) verify
Testbench Design to
(environment) verify
input
Testbench Design to
(environment) verify
input
n Can output to
u Simulator output (assertion)
u File (textIO)
Testbench Design to
(environment) verify
input
Visualised
Output
VHDL Application Workshop page 141
Results for Comparion
n Compare results for different
Testbench Design to simulations
(environment) verify n Essential for large designs
input u Studying waveforms very
tedious !
n If comparing gbetween
abstraction levels
Compare (diff) u (Behavioural/RTL, RTL/Gates)
u Output sequence of data values
u Time independent
Visualised Known good
Output results
Results for
analysis
Manufacturing
test vectors
Synthesize
Gate-level
Model Simulate Test Bench
Timing
Model Simulate
VHDL Application Workshop page 146
2 to 1 Multiplexer
Library IEEE;
use IEEE.Std_logic_1164.all;
Synthesized Circuit
entity MUX_2_1 is
port ( A, B : in std_logic;
SEL : in std_logic;
Q : out std_logic );
end MUX_2_1;
architecture B of MUX_2_1 is
begin
Q <= A when (SEL = '0') else B;
end B;