1 |
2 |
dragos_don |
#! /usr/bin/perl -w
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
#/////////////////////////////////////////////////////////////////////
|
5 |
|
|
#//// ////
|
6 |
|
|
#//// This project has been provided to you on behalf of: ////
|
7 |
|
|
#//// ////
|
8 |
|
|
#//// S.C. ASICArt S.R.L. ////
|
9 |
|
|
#//// www.asicart.com ////
|
10 |
|
|
#//// eli_f@asicart.com ////
|
11 |
|
|
#//// ////
|
12 |
|
|
#//// Author: Dragos Constantin Doncean ////
|
13 |
|
|
#//// Email: doncean@asicart.com ////
|
14 |
|
|
#//// Mobile: +40-740-936997 ////
|
15 |
|
|
#//// ////
|
16 |
|
|
#//// Downloaded from: http://www.opencores.org/ ////
|
17 |
|
|
#//// ////
|
18 |
|
|
#/////////////////////////////////////////////////////////////////////
|
19 |
|
|
#//// ////
|
20 |
|
|
#//// Copyright (C) 2007 Dragos Constantin Doncean ////
|
21 |
|
|
#//// www.asicart.com ////
|
22 |
|
|
#//// doncean@asicart.com ////
|
23 |
|
|
#//// ////
|
24 |
|
|
#//// This source file may be used and distributed without ////
|
25 |
|
|
#//// restriction provided that this copyright statement is not ////
|
26 |
|
|
#//// removed from the file and that any derivative work contains ////
|
27 |
|
|
#//// the original copyright notice and the associated disclaimer.////
|
28 |
|
|
#//// ////
|
29 |
|
|
#//// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY ////
|
30 |
|
|
#//// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED ////
|
31 |
|
|
#//// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS ////
|
32 |
|
|
#//// FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL THE AUTHOR ////
|
33 |
|
|
#//// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, ////
|
34 |
|
|
#//// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ////
|
35 |
|
|
#//// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE ////
|
36 |
|
|
#//// GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR ////
|
37 |
|
|
#//// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF ////
|
38 |
|
|
#//// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ////
|
39 |
|
|
#//// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT ////
|
40 |
|
|
#//// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE ////
|
41 |
|
|
#//// POSSIBILITY OF SUCH DAMAGE. ////
|
42 |
|
|
#//// ////
|
43 |
|
|
#/////////////////////////////////////////////////////////////////////
|
44 |
|
|
|
45 |
|
|
|
46 |
|
|
use Getopt::Long;
|
47 |
|
|
use IO::Handle;
|
48 |
|
|
|
49 |
|
|
######################################################################
|
50 |
|
|
# the help print
|
51 |
|
|
######################################################################
|
52 |
|
|
my $help = <<EndHelp;
|
53 |
|
|
Usage:
|
54 |
|
|
RunTest.pl <test_name> [-help|-h]
|
55 |
|
|
[-log|-l <log filename>]
|
56 |
|
|
|
57 |
|
|
The arguments meaning:
|
58 |
|
|
----------------------
|
59 |
|
|
|
60 |
|
|
<test_name> - the test name (can be with or without the extention .vr)
|
61 |
|
|
[-help|-h] - print this help screen
|
62 |
|
|
[-log|-l <log filename>] - the test name
|
63 |
|
|
|
64 |
|
|
EndHelp
|
65 |
|
|
|
66 |
|
|
######################################################################
|
67 |
|
|
# check the arguments
|
68 |
|
|
######################################################################
|
69 |
|
|
$result = &GetOptions(\%optctl, "help|h", "log|l=s");
|
70 |
|
|
|
71 |
|
|
if($result == 0 || $#ARGV == -1 || defined($optctl{help})){
|
72 |
|
|
print $help;
|
73 |
|
|
exit 0;
|
74 |
|
|
}
|
75 |
|
|
|
76 |
|
|
$test_name = $ARGV[0];
|
77 |
|
|
$test_name =~ s/\.v$//;
|
78 |
|
|
$test_file = "$test_name" . ".v";
|
79 |
|
|
|
80 |
|
|
unless (-e $test_file) {
|
81 |
|
|
die "\n Test file $test_file does not exist!!!\n" .
|
82 |
|
|
" exiting ...\n";
|
83 |
|
|
}
|
84 |
|
|
|
85 |
|
|
if(defined($optctl{"log"})){
|
86 |
|
|
$log_file = $optctl{"log"};
|
87 |
|
|
}
|
88 |
|
|
else{
|
89 |
|
|
$log_file = $test_name . ".log";
|
90 |
|
|
}
|
91 |
|
|
|
92 |
|
|
######################################################################
|
93 |
|
|
# open the log file, create cds.lib and hdl.var
|
94 |
|
|
######################################################################
|
95 |
|
|
open (LOG_FILE, "> $log_file") or die " Can not open file $log_file\n\n";
|
96 |
|
|
autoflush LOG_FILE;
|
97 |
|
|
SystemCmd("date");
|
98 |
|
|
close (LOG_FILE);
|
99 |
|
|
|
100 |
|
|
######################################################################
|
101 |
|
|
# compile the test
|
102 |
|
|
######################################################################
|
103 |
|
|
my $test_compile_cmd = "verilog -c $test_file";
|
104 |
|
|
SystemCmd("$test_compile_cmd");
|
105 |
|
|
|
106 |
|
|
######################################################################
|
107 |
|
|
# clean the test directory
|
108 |
|
|
######################################################################
|
109 |
|
|
SystemCmd("make clean");
|
110 |
|
|
|
111 |
|
|
######################################################################
|
112 |
|
|
# run the simulation
|
113 |
|
|
######################################################################
|
114 |
|
|
my $sim_cmd = "make TEST_TYPE=$test_file";
|
115 |
|
|
SystemCmd("$sim_cmd");
|
116 |
|
|
|
117 |
|
|
######################################################################
|
118 |
|
|
# Execute system command
|
119 |
|
|
######################################################################
|
120 |
|
|
sub SystemCmd # Arg: Command string
|
121 |
|
|
{
|
122 |
|
|
my($command_line) = @_;
|
123 |
|
|
open (LOG_FILE, ">> $log_file") or die "Can not create $log_file file\n";
|
124 |
|
|
autoflush LOG_FILE;
|
125 |
|
|
print LOG_FILE "\nExecuting '$command_line >> $log_file 2>&1'\n";
|
126 |
|
|
close(LOG_FILE);
|
127 |
|
|
sleep 1;
|
128 |
|
|
system "$command_line >> $log_file 2>&1";
|
129 |
|
|
my $rc = $?/256;
|
130 |
|
|
sleep 1;
|
131 |
|
|
open (LOG_FILE, ">> $log_file") or die "Can not create $log_file file\n";
|
132 |
|
|
autoflush LOG_FILE;
|
133 |
|
|
if ($rc != 0) {
|
134 |
|
|
print LOG_FILE "\nWARNING: Return code of system command $command_line >> $log_file > 2>&1 = $rc != 0\n";
|
135 |
|
|
}
|
136 |
|
|
close (LOG_FILE);
|
137 |
|
|
$rc;
|
138 |
|
|
}
|