Test Bench Generation using Perl script

December 27, 2017 | Author: Aditya | Category: Control Flow, Perl, String (Computer Science), Programming Paradigms, Computer Engineering
Share Embed Donate


Short Description

Perl code for Test bench generation...

Description

Scripting Languages and Verification Lab (Winter Sem 2014-15) 14MVD0123 14MVD0106

SCRIPTING LANGUAGES AND VERIFICATION LAB LAB REPORT

EXPT 2: WRITE A PERL PROGRAM TO GENERATE A TEST BENCH FOR A GIVEN VERILOG CODE

Aditya Vibhute 14MVD0123

1

Scripting Languages and Verification Lab (Winter Sem 2014-15) 14MVD0123 14MVD0106

EXP 2: WRITE A PERL PROGRAM TO GENERATE A TEST BENCH FOR A GIVEN VERILOG CODE

OBJECTIVE: Write a PERL Program to Generate a Test bench for a given Verilog Code.

DESCRIPTION: Keywords and Functions: 1. 2. 3. 4.

print: To print the required data. for: for loop; used for terminating running of the program after a specified limit rand: this function returns random values between user defined range. while: while loop is used to run a piece of code until the condition remains true, as soon as the condition becomes false, program terminates/comes out of the loop. 5. if: program will be executed if the specified condition is true. 6. split: this function is used to split the string of characters. Sometimes a specified delimiter is used to make divisions in between the string. 7. foreach: it is similar to for loop. Foreach helps us to check whether element of the list stored in an array variable is given word.

CODE (Combinational Circuit):

#!usr\bin\perl open OUT,">fulladd_tb.v"; open IN,"fulladd.v"; $test_vector=9; while($a=) { if($a=~/module\s(\w+)\((.*)\)\;/) { $name=$1; $portlist=$2; } if ($a=~/input\s+(.*)\;/) { $input=$1; @b=split/,/,$input; $k=@b; }

2

Scripting Languages and Verification Lab (Winter Sem 2014-15) 14MVD0123 14MVD0106

if($a=~/output\s+(.*)\;/) { $output=$1; } } print OUT"module $name\_test()\;\n\n"; print OUT"reg $input\;\n\n"; print OUT"wire $output\;\n\n"; print OUT"$name\ f1($portlist)\;\n\n"; print OUT"initial\n"; print OUT"begin\n"; print"$k\n@b\n"; for($i=0;$i
View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF