Professional Documents
Culture Documents
Efficient Testbenches
using muxAndDecEx1
combinational logic example
Dr Fearghal Morgan
VHDL for efficient testbenches www.appliedVHDL.com Applied VHDL Training Course, Dr Fearghal Morgan, V2007.1 p1
VHDL For Efficient Testbenches (TBs)
Learning outcomes
On completion of this module, you should be able to :
muxAndDecEx1
decOut decOut
VHDL for efficient testbenches www.appliedVHDL.com Applied VHDL Training Course, Dr Fearghal Morgan, V2007.1 p3
Basic muxAndDecEx1 Testbench
VHDL for efficient testbenches www.appliedVHDL.com Applied VHDL Training Course, Dr Fearghal Morgan, V2007.1 p4
Basic muxAndDecEx1 Testbench
Simulation Waveform
VHDL for efficient testbenches www.appliedVHDL.com Applied VHDL Training Course, Dr Fearghal Morgan, V2007.1 p5
Alternative Stimulus Generation
Various efficient VHDL behavioural modelling language constructs
are available to generate stimulus to test a VHDL model, e.g.,
• for loop
• defining stimulus array & indexing the array to apply stimulus
• reading stimulus data directly from a file
VHDL for efficient testbenches www.appliedVHDL.com Applied VHDL Training Course, Dr Fearghal Morgan, V2007.1 p6
Stimulus Generation using for loop
muxAndDecEx1 example : use for loop to create 8 stimulus sets
Convert integer loop index to a signal vector using VHDL function.
VHDL for efficient testbenches www.appliedVHDL.com Applied VHDL Training Course, Dr Fearghal Morgan, V2007.1 p7
for loop Syntax
Use Edit > language templates > VHDL > for loop statement
VHDL for efficient testbenches www.appliedVHDL.com Applied VHDL Training Course, Dr Fearghal Morgan, V2007.1 p8
Functions in VHDL
Functions (and procedures) are used widely in VHDL
VHDL for efficient testbenches www.appliedVHDL.com Applied VHDL Training Course, Dr Fearghal Morgan, V2007.1 p9
Conversion Functions in VHDL
Use Edit > language templates > VHDL > conversion functions
vector size
VHDL for efficient testbenches www.appliedVHDL.com Applied VHDL Training Course, Dr Fearghal Morgan, V2007.1 p10
Viewing VHDL
function models
work library (compiled
project files)
IEEE libraries
VHDL for efficient testbenches www.appliedVHDL.com Applied VHDL Training Course, Dr Fearghal Morgan, V2007.1 p11
Viewing ieee.std_logic_arith library inModelsim
VHDL for efficient testbenches www.appliedVHDL.com Applied VHDL Training Course, Dr Fearghal Morgan, V2007.1 p12
Conversion Functions in VHDL
Use Edit > language templates > VHDL > conversion functions
Function
defined in arith
library Function overloading :
Specific function used depends
Library package on argument types
must be
referenced in Functions are applied using a VHDL
VHDL library assignment, e.g., <=
description
VHDL for efficient testbenches www.appliedVHDL.com Applied VHDL Training Course, Dr Fearghal Morgan, V2007.1 p13
Stimulus Generation using Array
• muxAndDecEx1: define two 8 element 4-bit arrays
• Use for loop to index each array element and assign mux input values
• No type conversion is required
VHDL for efficient testbenches www.appliedVHDL.com Applied VHDL Training Course, Dr Fearghal Morgan, V2007.1 p14
Use of VHDL Variables for Testbench Stimuli
• Always consider using variables to generate stimulus patterns in TBs
• Variables (very similar to signals) can only be defined and used
within a process (not accessible outside process)
• Variable can be used to efficiently define stimulus data inside process
before assigning the stimulus to a signal
• Variables can simplify data processing
VHDL for efficient testbenches www.appliedVHDL.com Applied VHDL Training Course, Dr Fearghal Morgan, V2007.1 p15
File based Stimulus Generation
• Use fileIO library
• Read each line in a stimulus file (until end of file reached)
• muxAndDecEx1 example : assign each bit to the muxEx1 inputs in turn
stimDat.txt
VHDL for efficient testbenches www.appliedVHDL.com Applied VHDL Training Course, Dr Fearghal Morgan, V2007.1 p16
File based simulation output
• Messages can be written to the simulator transcript during
execution.
e.g., report “message”;
VHDL for efficient testbenches www.appliedVHDL.com Applied VHDL Training Course, Dr Fearghal Morgan, V2007.1 p17
VHDL For Efficient Testbenches