SlideShare a Scribd company logo
Test Bench
Dr.R.P.Rao
Test Bench Top Level Model
MUT
Test
Bench
Top Level Model
MUT
Test
Bench
A test bench is usually a simulation-only model used for design verification of some other
model(s) to be synthesized. A test bench is usually easier to develop than a force file when
verifying the proper operation of a complicated model. In its simplest form, a test bench
generates and applies input stimuli to the model under test. The test bench can call the model
under test (MUT) hierarchically, as illustrated in Figure 1a, or it can be a separate model with
another top level hierarchical model calling and interconnecting both the test bench and the
MUT, as illustrated in Figure 1b. It is a bad idea to merge the test bench and MUT in a single non-
hierarchical model since editing the model to remove test bench destroys the design verification
effort by opening the door for design errors. A more sophisticated approach is to have the test
bench monitor the outputs of the MUT and to compare the output responses with expected results
for design verification as illustrated in Figure 1c. With the latter approach, the input stimuli can be
modified based on the output response of the MUT.
a) Test bench as top level model b) Test bench as subcircuit within
higher level model
c) Test bench performing design
verification
Figure 1. Test Bench Hierarchy
The test bench is typically not synthesizable since it must often contain timing information
(delays) that cannot be synthesized into hardware (while the MUT contains no timing
information other than delta delays). There are two types of delays that can be used, inertial
delay and transport delay, with the formats given below. The effect of these two types of delays
can be seen in the timing diagram of Figure 2.
X <= A after 5 ns; -- inertial delay acts as a filter removes pulses less that 5ns
Y <= transport A after 5 ns; -- transport delay passes all pulses
A
X
Y
Time (ns)
0 5 10 15 20
Figure 2. Timing Diagram for Delays
MUT
Test Bench
Dr.R.P.Rao
A simple test bench that will apply a set of test patterns to a MUT is given below where we are
generating a BCD count sequence along with a clock signal to be applied to the MUT:
entity TB is
port (CK: buffer bit;
BCD: out bit_vector(3 downto 0));
end entity TB;
architecture RTL of TB is
signal INIT: bit;
begin
CK <= not CK after 50 ns; -- repetitive patterns
BCD <= “0000”, “0001” after 100ns, “0010” after 200 ns, “0011” after 300 ns,
“0100” after 400 ns, “0101” after 500 ns, “0110” after 600 ns,
“0111” after 700 ns, “1000” after 800 ns, “1001” after 900 ns;
end architecture RTL;
A more sophisticated test bench is given below where the control of the input stimuli to the MUT
is read from an input file (mut.vec) while the output responses from the MUT are written to an
output file (mut.out) with the formats shown below. Note that the write operation is a 3-step
sequence while the read operation is only 1 step as illustrated in Figure 3. Each step in this
example test bench is 10 ns in duration.
Input file format:
w 0 10000000
w 1 00100001
w 2 00000000
w 3 00000000
r 0
r 1
r 2
r 3
e 0
Output file format:
w 0 10000000 10000000
w 1 00100001 00100001
w 2 00000000 00000000
w 3 00000000 00000000
r 0 00000001
r 1 00100001
r 2 10100100
r 3 00000110
ADDR=2-bits
DATIN=8-bits
RW=1-bit
Write Operation Read Operation
RW
Figure 3. Timing Diagram for Example Test Bench Operations
library IEEE;
use IEEE.std_logic_1164.all;
use STD.TEXTIO.all; -- calls package with routines for reading/writing files
entity TEST is
end entity;
architecture RTL of TEST is
signal RW: std_logic; -- read/write control to MUT
signal ADD: std_logic_vector(1 downto 0); -- address to MUT
ADDRADDR & DATIN
RW
Test Bench
3 3/11C. E. Stroud,ECE Dept.,Auburn Univ.
signal DIN,DOUT: std_logic_vector(7 downto 0); -- data to/from MUT
signal STOP: std_logic := ‘0’; -- used to stop reading of vector file at end
component MUT is
port ( RW: in std_logic;
ADDR: in std_logic_vector(1 downto 0);
DATIN: in std_logic_vector(7 downto 0);
DATO: out std_logic_vector(7 downto 0));
end component;
begin
M1: MUT port map (RW, ADD, DIN, DOUT); -- hierarchical connection to MUT
process -- main process for test bench to read/write files
variable DAT: bit_vector(7 downto 0); -- variable for data transfer to/from files
file SCRIPT: TEXT is in "mut.vec"; -- “file pointer” to input vector file
file RESULT: TEXT is out "mut.out"; -- “file pointer” to output results file
variable L: line; -- variable to store contents of line to/from files
variable OP: character; -- operation variable (read/write)
variable AD: integer; -- address variable
begin
if (STOP = ‘0’) then
RW <= '1'; -- set RW to read
READLINE(SCRIPT,L); -- read a line from the input file
READ(L,OP); -- read the operation from the line
READ(L,AD); -- read the address from the line
if (AD = 0) then ADD <= "00";
elsif (AD = 1) then ADD <= "01";
elsif (AD = 2) then ADD <= "10";
else ADD <= "11";
end if;
if (OP = 'w') then
READ(L,DAT); -- read data from the line
for i in 7 downto 0 loop
if (DAT(i) = '0') then DIN(i) <= '0';
else DIN(i) <= '1';
end if;
end loop;
RW <= '1'; -- set RW to 1 for 10 ns
wait for 10 ns;
RW <= '0'; -- set RW to 0 for 10 ns
wait for 10 ns;
RW <= '1'; -- set RW to 1 for 10 ns
wait for 10 ns;
WRITE(L,OP); -- write operation to output line
WRITE(L,' '); -- write a space to output line
WRITE(L,AD); -- write address to output line
WRITE(L,' '); -- write a space to output line
WRITE(L,DAT); -- writes input data to output line
Test Bench
4 3/11C. E. Stroud,ECE Dept.,Auburn Univ.
for i in 7 downto 0 loop
if (DOUT(i) = '0') then DAT(i) := '0'; -- transfer DOUT to DAT
else DAT(i) := '1';
end if;
end loop;
WRITE(L,' '); -- write a space to output line
WRITE(L,DAT); -- write DAT to output line
WRITELINE(RESULT,L); -- write output line to output file
elsif (OP = 'r') then
wait for 10 ns; -- wait for 10 ns to read
WRITE(L,OP); -- write operation to output line
WRITE(L,' '); -- write a space to output line
WRITE(L,AD); -- write address to output line
for i in 7 downto 0 loop
if (DOUT(i) = '0') then DAT(i) := '0'; -- transfer DOUT to DAT
else DAT(i) := '1';
end if;
end loop;
WRITE(L,' '); -- write a space to output line
WRITE(L,DAT); -- write DAT to output line
WRITELINE(RESULT,L); -- write output line to output file
end if;
else
end if;
STOP <= ‘1’; -- will stop read/write of files when ‘e’ encountered
wait for 10 ns; -- wait for 10 ns to read
end process;
end architecture;
Note that you must be careful about trying to open and read results or write vector files
while ModelSim is open. The results file may not be closed until you exit ModelSim.
Similarly, edits made to the input vector file may not be transferred to ModelSim without
closing out the file and/or simulation, and restarting ModelSim.
An alternative to the “STOP” approach used in the example above is the following
construct used in the process:
process -- main process for test bench to read/write files
variable and file declarations
begin
while not (endfile(script)) loop
do test bench stuff
end loop;
end process;
Test Bench
5 3/11C. E. Stroud,ECE Dept.,Auburn Univ.
assert statements check to see if a condition is true or not and displays an error message
general format:
assert BOOLEAN-EXPRESSION
report “STRING” -- reports only if Boolean-expression is false
severity SEVERITY-LEVEL ; -- severity is optional
3 severity-levels: note, warning, error, failure (lowest to highest) –action taken depends
on simulator (typically “note” and “warning” keep running while “error” and “failure”
halt simulation)

More Related Content

What's hot

C# Loops
C# LoopsC# Loops
C# Loops
Hock Leng PUAH
 
Btech i pic u-3 handling input output and control statements
Btech i pic u-3 handling input output and control statementsBtech i pic u-3 handling input output and control statements
Btech i pic u-3 handling input output and control statements
Rai University
 
Bsc cs pic u-3 handling input output and control statements
Bsc cs  pic u-3 handling input output and control statementsBsc cs  pic u-3 handling input output and control statements
Bsc cs pic u-3 handling input output and control statements
Rai University
 
Planet of the AOPs
Planet of the AOPsPlanet of the AOPs
Planet of the AOPsJames Ward
 
Mca i pic u-3 handling input output and control statements
Mca i pic u-3 handling input output and control statementsMca i pic u-3 handling input output and control statements
Mca i pic u-3 handling input output and control statements
Rai University
 
Lab3 testbench tutorial (1)
Lab3 testbench tutorial (1)Lab3 testbench tutorial (1)
Lab3 testbench tutorial (1)
Abhishek Bose
 
C lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshareC lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshare
Gagan Deep
 
Loops IN COMPUTER SCIENCE STANDARD 11 BY KR
Loops IN COMPUTER SCIENCE STANDARD 11 BY KRLoops IN COMPUTER SCIENCE STANDARD 11 BY KR
Loops IN COMPUTER SCIENCE STANDARD 11 BY KR
Krishna Raj
 
Loop c++
Loop c++Loop c++
Loop c++
Mood Mood
 
EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5PRADEEP
 
MATLAB Programming - Loop Control Part 2
MATLAB Programming - Loop Control Part 2MATLAB Programming - Loop Control Part 2
MATLAB Programming - Loop Control Part 2
Shameer Ahmed Koya
 
basic c++(1)
basic c++(1)basic c++(1)
basic c++(1)sajidpk92
 
C++ loop
C++ loop C++ loop
C++ loop
Khelan Ameen
 
Control statements
Control statementsControl statements
Control statements
Kanwalpreet Kaur
 
Object oriented programming18 control structures looping
Object oriented programming18 control structures loopingObject oriented programming18 control structures looping
Object oriented programming18 control structures looping
Vaibhav Khanna
 
C Sharp Jn (3)
C Sharp Jn (3)C Sharp Jn (3)
C Sharp Jn (3)jahanullah
 

What's hot (19)

C# Loops
C# LoopsC# Loops
C# Loops
 
Btech i pic u-3 handling input output and control statements
Btech i pic u-3 handling input output and control statementsBtech i pic u-3 handling input output and control statements
Btech i pic u-3 handling input output and control statements
 
Bsc cs pic u-3 handling input output and control statements
Bsc cs  pic u-3 handling input output and control statementsBsc cs  pic u-3 handling input output and control statements
Bsc cs pic u-3 handling input output and control statements
 
Planet of the AOPs
Planet of the AOPsPlanet of the AOPs
Planet of the AOPs
 
Mca i pic u-3 handling input output and control statements
Mca i pic u-3 handling input output and control statementsMca i pic u-3 handling input output and control statements
Mca i pic u-3 handling input output and control statements
 
Lab3 testbench tutorial (1)
Lab3 testbench tutorial (1)Lab3 testbench tutorial (1)
Lab3 testbench tutorial (1)
 
Os4
Os4Os4
Os4
 
C lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshareC lecture 4 nested loops and jumping statements slideshare
C lecture 4 nested loops and jumping statements slideshare
 
Loops IN COMPUTER SCIENCE STANDARD 11 BY KR
Loops IN COMPUTER SCIENCE STANDARD 11 BY KRLoops IN COMPUTER SCIENCE STANDARD 11 BY KR
Loops IN COMPUTER SCIENCE STANDARD 11 BY KR
 
Loop c++
Loop c++Loop c++
Loop c++
 
EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5EMBEDDED SYSTEMS 4&5
EMBEDDED SYSTEMS 4&5
 
MATLAB Programming - Loop Control Part 2
MATLAB Programming - Loop Control Part 2MATLAB Programming - Loop Control Part 2
MATLAB Programming - Loop Control Part 2
 
basic c++(1)
basic c++(1)basic c++(1)
basic c++(1)
 
C++ loop
C++ loop C++ loop
C++ loop
 
Control statements
Control statementsControl statements
Control statements
 
Object oriented programming18 control structures looping
Object oriented programming18 control structures loopingObject oriented programming18 control structures looping
Object oriented programming18 control structures looping
 
C Sharp Jn (3)
C Sharp Jn (3)C Sharp Jn (3)
C Sharp Jn (3)
 
Semaphores
SemaphoresSemaphores
Semaphores
 
Comp ppt (1)
Comp ppt (1)Comp ppt (1)
Comp ppt (1)
 

Similar to Hd9

Switch Control and Time Delay - Keypad
Switch Control and Time Delay - KeypadSwitch Control and Time Delay - Keypad
Switch Control and Time Delay - Keypad
Ariel Tonatiuh Espindola
 
Instruction_Set.pdf
Instruction_Set.pdfInstruction_Set.pdf
Instruction_Set.pdf
boukomra
 
manual-pe-2017_compress.pdf
manual-pe-2017_compress.pdfmanual-pe-2017_compress.pdf
manual-pe-2017_compress.pdf
Abdo Brahmi
 
Instruction set
Instruction setInstruction set
Instruction set
Lívia Sousa
 
Standard cells library design
Standard cells library designStandard cells library design
Standard cells library design
Bharat Biyani
 
PLC: Uso de funciones de secuenciador SQO en control industrial
PLC: Uso de funciones de secuenciador SQO en control industrialPLC: Uso de funciones de secuenciador SQO en control industrial
PLC: Uso de funciones de secuenciador SQO en control industrial
SANTIAGO PABLO ALBERTO
 
PLSQLmy Updated (1).pptx
PLSQLmy Updated (1).pptxPLSQLmy Updated (1).pptx
PLSQLmy Updated (1).pptx
vamsiyadav39
 
Digital System Design-Switchlevel and Behavioural Modeling
Digital System Design-Switchlevel and Behavioural ModelingDigital System Design-Switchlevel and Behavioural Modeling
Digital System Design-Switchlevel and Behavioural Modeling
Indira Priyadarshini
 
PL-SQL.pdf
PL-SQL.pdfPL-SQL.pdf
PL-SQL.pdf
Anas Nakash
 
Verilog Lecture3 hust 2014
Verilog Lecture3 hust 2014Verilog Lecture3 hust 2014
Verilog Lecture3 hust 2014
Béo Tú
 
8051 MMD Chapter 1.ppt
8051 MMD Chapter 1.ppt8051 MMD Chapter 1.ppt
8051 MMD Chapter 1.ppt
notagain0712
 
Oracle pl sql
Oracle pl sqlOracle pl sql
Oracle pl sql
Durga Rao
 
Matlab m files and scripts
Matlab m files and scriptsMatlab m files and scripts
Matlab m files and scripts
Ameen San
 
Allen Bradley- Micrologix PLC Instructions
Allen Bradley- Micrologix PLC InstructionsAllen Bradley- Micrologix PLC Instructions
Allen Bradley- Micrologix PLC Instructions
NFI - Industrial Automation Training Academy
 
Analog to Digital Converter
Analog to Digital ConverterAnalog to Digital Converter
Analog to Digital Converter
Ariel Tonatiuh Espindola
 
dokumen.tips_verilog-basic-ppt.pdf
dokumen.tips_verilog-basic-ppt.pdfdokumen.tips_verilog-basic-ppt.pdf
dokumen.tips_verilog-basic-ppt.pdf
Velmathi Saravanan
 
Write your own generic SPICE Power Supplies controller models
Write your own generic SPICE Power Supplies controller modelsWrite your own generic SPICE Power Supplies controller models
Write your own generic SPICE Power Supplies controller models
Tsuyoshi Horigome
 
A Lightweight Instruction Scheduling Algorithm For Just In Time Compiler
A Lightweight Instruction Scheduling Algorithm For Just In Time CompilerA Lightweight Instruction Scheduling Algorithm For Just In Time Compiler
A Lightweight Instruction Scheduling Algorithm For Just In Time Compiler
keanumit
 

Similar to Hd9 (20)

Switch Control and Time Delay - Keypad
Switch Control and Time Delay - KeypadSwitch Control and Time Delay - Keypad
Switch Control and Time Delay - Keypad
 
Instruction_Set.pdf
Instruction_Set.pdfInstruction_Set.pdf
Instruction_Set.pdf
 
manual-pe-2017_compress.pdf
manual-pe-2017_compress.pdfmanual-pe-2017_compress.pdf
manual-pe-2017_compress.pdf
 
Csd01
Csd01Csd01
Csd01
 
Instruction set
Instruction setInstruction set
Instruction set
 
Standard cells library design
Standard cells library designStandard cells library design
Standard cells library design
 
PLC: Uso de funciones de secuenciador SQO en control industrial
PLC: Uso de funciones de secuenciador SQO en control industrialPLC: Uso de funciones de secuenciador SQO en control industrial
PLC: Uso de funciones de secuenciador SQO en control industrial
 
PLSQLmy Updated (1).pptx
PLSQLmy Updated (1).pptxPLSQLmy Updated (1).pptx
PLSQLmy Updated (1).pptx
 
Digital System Design-Switchlevel and Behavioural Modeling
Digital System Design-Switchlevel and Behavioural ModelingDigital System Design-Switchlevel and Behavioural Modeling
Digital System Design-Switchlevel and Behavioural Modeling
 
project report
project reportproject report
project report
 
PL-SQL.pdf
PL-SQL.pdfPL-SQL.pdf
PL-SQL.pdf
 
Verilog Lecture3 hust 2014
Verilog Lecture3 hust 2014Verilog Lecture3 hust 2014
Verilog Lecture3 hust 2014
 
8051 MMD Chapter 1.ppt
8051 MMD Chapter 1.ppt8051 MMD Chapter 1.ppt
8051 MMD Chapter 1.ppt
 
Oracle pl sql
Oracle pl sqlOracle pl sql
Oracle pl sql
 
Matlab m files and scripts
Matlab m files and scriptsMatlab m files and scripts
Matlab m files and scripts
 
Allen Bradley- Micrologix PLC Instructions
Allen Bradley- Micrologix PLC InstructionsAllen Bradley- Micrologix PLC Instructions
Allen Bradley- Micrologix PLC Instructions
 
Analog to Digital Converter
Analog to Digital ConverterAnalog to Digital Converter
Analog to Digital Converter
 
dokumen.tips_verilog-basic-ppt.pdf
dokumen.tips_verilog-basic-ppt.pdfdokumen.tips_verilog-basic-ppt.pdf
dokumen.tips_verilog-basic-ppt.pdf
 
Write your own generic SPICE Power Supplies controller models
Write your own generic SPICE Power Supplies controller modelsWrite your own generic SPICE Power Supplies controller models
Write your own generic SPICE Power Supplies controller models
 
A Lightweight Instruction Scheduling Algorithm For Just In Time Compiler
A Lightweight Instruction Scheduling Algorithm For Just In Time CompilerA Lightweight Instruction Scheduling Algorithm For Just In Time Compiler
A Lightweight Instruction Scheduling Algorithm For Just In Time Compiler
 

More from Prakash Rao

PAL
PALPAL
Digital Signal Processing by Dr. R. Prakash Rao
Digital Signal Processing by Dr. R. Prakash Rao Digital Signal Processing by Dr. R. Prakash Rao
Digital Signal Processing by Dr. R. Prakash Rao
Prakash Rao
 
Electromagnetic Theory and Transmission Lines by Dr. R. Prakash Rao
Electromagnetic Theory and Transmission Lines  by Dr. R. Prakash RaoElectromagnetic Theory and Transmission Lines  by Dr. R. Prakash Rao
Electromagnetic Theory and Transmission Lines by Dr. R. Prakash Rao
Prakash Rao
 
VLSI15
VLSI15VLSI15
VLSI15
Prakash Rao
 
VLSI14
VLSI14VLSI14
VLSI14
Prakash Rao
 
VLSI13
VLSI13VLSI13
VLSI13
Prakash Rao
 
VLSI12
VLSI12VLSI12
VLSI12
Prakash Rao
 
VLSI11
VLSI11VLSI11
VLSI11
Prakash Rao
 
VLSI9
VLSI9VLSI9
VLSI8
VLSI8VLSI8
VLSI7
VLSI7VLSI7
VLSI6
VLSI6VLSI6
VLSI5
VLSI5VLSI5
VLSI4
VLSI4VLSI4
VLSI3
VLSI3VLSI3
VLSI2
VLSI2VLSI2
VLSI DESIGN
VLSI DESIGN VLSI DESIGN
VLSI DESIGN
Prakash Rao
 
VLSI10
VLSI10VLSI10
VLSI10
Prakash Rao
 
BIASING OF BJT
BIASING OF BJT BIASING OF BJT
BIASING OF BJT
Prakash Rao
 

More from Prakash Rao (20)

PAL
PALPAL
PAL
 
Digital Signal Processing by Dr. R. Prakash Rao
Digital Signal Processing by Dr. R. Prakash Rao Digital Signal Processing by Dr. R. Prakash Rao
Digital Signal Processing by Dr. R. Prakash Rao
 
Electromagnetic Theory and Transmission Lines by Dr. R. Prakash Rao
Electromagnetic Theory and Transmission Lines  by Dr. R. Prakash RaoElectromagnetic Theory and Transmission Lines  by Dr. R. Prakash Rao
Electromagnetic Theory and Transmission Lines by Dr. R. Prakash Rao
 
VLSI15
VLSI15VLSI15
VLSI15
 
VLSI14
VLSI14VLSI14
VLSI14
 
VLSI13
VLSI13VLSI13
VLSI13
 
VLSI12
VLSI12VLSI12
VLSI12
 
VLSI11
VLSI11VLSI11
VLSI11
 
VLSI9
VLSI9VLSI9
VLSI9
 
VLSI8
VLSI8VLSI8
VLSI8
 
VLSI7
VLSI7VLSI7
VLSI7
 
VLSI6
VLSI6VLSI6
VLSI6
 
VLSI5
VLSI5VLSI5
VLSI5
 
VLSI4
VLSI4VLSI4
VLSI4
 
VLSI3
VLSI3VLSI3
VLSI3
 
VLSI2
VLSI2VLSI2
VLSI2
 
VLSI DESIGN
VLSI DESIGN VLSI DESIGN
VLSI DESIGN
 
VLSI10
VLSI10VLSI10
VLSI10
 
Fet
FetFet
Fet
 
BIASING OF BJT
BIASING OF BJT BIASING OF BJT
BIASING OF BJT
 

Recently uploaded

Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
Pipe Restoration Solutions
 
LIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.pptLIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.ppt
ssuser9bd3ba
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
Vaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdfVaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdf
Kamal Acharya
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
PrashantGoswami42
 
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSETECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
DuvanRamosGarzon1
 
Democratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek AryaDemocratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek Arya
abh.arya
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
karthi keyan
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
Intella Parts
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdf
Kamal Acharya
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
Divya Somashekar
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
Jayaprasanna4
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 

Recently uploaded (20)

Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
LIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.pptLIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.ppt
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
Vaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdfVaccine management system project report documentation..pdf
Vaccine management system project report documentation..pdf
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
 
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSETECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
 
Democratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek AryaDemocratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek Arya
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
Forklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella PartsForklift Classes Overview by Intella Parts
Forklift Classes Overview by Intella Parts
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdf
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 

Hd9

  • 1. Test Bench Dr.R.P.Rao Test Bench Top Level Model MUT Test Bench Top Level Model MUT Test Bench A test bench is usually a simulation-only model used for design verification of some other model(s) to be synthesized. A test bench is usually easier to develop than a force file when verifying the proper operation of a complicated model. In its simplest form, a test bench generates and applies input stimuli to the model under test. The test bench can call the model under test (MUT) hierarchically, as illustrated in Figure 1a, or it can be a separate model with another top level hierarchical model calling and interconnecting both the test bench and the MUT, as illustrated in Figure 1b. It is a bad idea to merge the test bench and MUT in a single non- hierarchical model since editing the model to remove test bench destroys the design verification effort by opening the door for design errors. A more sophisticated approach is to have the test bench monitor the outputs of the MUT and to compare the output responses with expected results for design verification as illustrated in Figure 1c. With the latter approach, the input stimuli can be modified based on the output response of the MUT. a) Test bench as top level model b) Test bench as subcircuit within higher level model c) Test bench performing design verification Figure 1. Test Bench Hierarchy The test bench is typically not synthesizable since it must often contain timing information (delays) that cannot be synthesized into hardware (while the MUT contains no timing information other than delta delays). There are two types of delays that can be used, inertial delay and transport delay, with the formats given below. The effect of these two types of delays can be seen in the timing diagram of Figure 2. X <= A after 5 ns; -- inertial delay acts as a filter removes pulses less that 5ns Y <= transport A after 5 ns; -- transport delay passes all pulses A X Y Time (ns) 0 5 10 15 20 Figure 2. Timing Diagram for Delays MUT
  • 2. Test Bench Dr.R.P.Rao A simple test bench that will apply a set of test patterns to a MUT is given below where we are generating a BCD count sequence along with a clock signal to be applied to the MUT: entity TB is port (CK: buffer bit; BCD: out bit_vector(3 downto 0)); end entity TB; architecture RTL of TB is signal INIT: bit; begin CK <= not CK after 50 ns; -- repetitive patterns BCD <= “0000”, “0001” after 100ns, “0010” after 200 ns, “0011” after 300 ns, “0100” after 400 ns, “0101” after 500 ns, “0110” after 600 ns, “0111” after 700 ns, “1000” after 800 ns, “1001” after 900 ns; end architecture RTL; A more sophisticated test bench is given below where the control of the input stimuli to the MUT is read from an input file (mut.vec) while the output responses from the MUT are written to an output file (mut.out) with the formats shown below. Note that the write operation is a 3-step sequence while the read operation is only 1 step as illustrated in Figure 3. Each step in this example test bench is 10 ns in duration. Input file format: w 0 10000000 w 1 00100001 w 2 00000000 w 3 00000000 r 0 r 1 r 2 r 3 e 0 Output file format: w 0 10000000 10000000 w 1 00100001 00100001 w 2 00000000 00000000 w 3 00000000 00000000 r 0 00000001 r 1 00100001 r 2 10100100 r 3 00000110 ADDR=2-bits DATIN=8-bits RW=1-bit Write Operation Read Operation RW Figure 3. Timing Diagram for Example Test Bench Operations library IEEE; use IEEE.std_logic_1164.all; use STD.TEXTIO.all; -- calls package with routines for reading/writing files entity TEST is end entity; architecture RTL of TEST is signal RW: std_logic; -- read/write control to MUT signal ADD: std_logic_vector(1 downto 0); -- address to MUT ADDRADDR & DATIN RW
  • 3. Test Bench 3 3/11C. E. Stroud,ECE Dept.,Auburn Univ. signal DIN,DOUT: std_logic_vector(7 downto 0); -- data to/from MUT signal STOP: std_logic := ‘0’; -- used to stop reading of vector file at end component MUT is port ( RW: in std_logic; ADDR: in std_logic_vector(1 downto 0); DATIN: in std_logic_vector(7 downto 0); DATO: out std_logic_vector(7 downto 0)); end component; begin M1: MUT port map (RW, ADD, DIN, DOUT); -- hierarchical connection to MUT process -- main process for test bench to read/write files variable DAT: bit_vector(7 downto 0); -- variable for data transfer to/from files file SCRIPT: TEXT is in "mut.vec"; -- “file pointer” to input vector file file RESULT: TEXT is out "mut.out"; -- “file pointer” to output results file variable L: line; -- variable to store contents of line to/from files variable OP: character; -- operation variable (read/write) variable AD: integer; -- address variable begin if (STOP = ‘0’) then RW <= '1'; -- set RW to read READLINE(SCRIPT,L); -- read a line from the input file READ(L,OP); -- read the operation from the line READ(L,AD); -- read the address from the line if (AD = 0) then ADD <= "00"; elsif (AD = 1) then ADD <= "01"; elsif (AD = 2) then ADD <= "10"; else ADD <= "11"; end if; if (OP = 'w') then READ(L,DAT); -- read data from the line for i in 7 downto 0 loop if (DAT(i) = '0') then DIN(i) <= '0'; else DIN(i) <= '1'; end if; end loop; RW <= '1'; -- set RW to 1 for 10 ns wait for 10 ns; RW <= '0'; -- set RW to 0 for 10 ns wait for 10 ns; RW <= '1'; -- set RW to 1 for 10 ns wait for 10 ns; WRITE(L,OP); -- write operation to output line WRITE(L,' '); -- write a space to output line WRITE(L,AD); -- write address to output line WRITE(L,' '); -- write a space to output line WRITE(L,DAT); -- writes input data to output line
  • 4. Test Bench 4 3/11C. E. Stroud,ECE Dept.,Auburn Univ. for i in 7 downto 0 loop if (DOUT(i) = '0') then DAT(i) := '0'; -- transfer DOUT to DAT else DAT(i) := '1'; end if; end loop; WRITE(L,' '); -- write a space to output line WRITE(L,DAT); -- write DAT to output line WRITELINE(RESULT,L); -- write output line to output file elsif (OP = 'r') then wait for 10 ns; -- wait for 10 ns to read WRITE(L,OP); -- write operation to output line WRITE(L,' '); -- write a space to output line WRITE(L,AD); -- write address to output line for i in 7 downto 0 loop if (DOUT(i) = '0') then DAT(i) := '0'; -- transfer DOUT to DAT else DAT(i) := '1'; end if; end loop; WRITE(L,' '); -- write a space to output line WRITE(L,DAT); -- write DAT to output line WRITELINE(RESULT,L); -- write output line to output file end if; else end if; STOP <= ‘1’; -- will stop read/write of files when ‘e’ encountered wait for 10 ns; -- wait for 10 ns to read end process; end architecture; Note that you must be careful about trying to open and read results or write vector files while ModelSim is open. The results file may not be closed until you exit ModelSim. Similarly, edits made to the input vector file may not be transferred to ModelSim without closing out the file and/or simulation, and restarting ModelSim. An alternative to the “STOP” approach used in the example above is the following construct used in the process: process -- main process for test bench to read/write files variable and file declarations begin while not (endfile(script)) loop do test bench stuff end loop; end process;
  • 5. Test Bench 5 3/11C. E. Stroud,ECE Dept.,Auburn Univ. assert statements check to see if a condition is true or not and displays an error message general format: assert BOOLEAN-EXPRESSION report “STRING” -- reports only if Boolean-expression is false severity SEVERITY-LEVEL ; -- severity is optional 3 severity-levels: note, warning, error, failure (lowest to highest) –action taken depends on simulator (typically “note” and “warning” keep running while “error” and “failure” halt simulation)