Hi,
I have two files and each consists of modules and in turn modules consists of some verilog
data and instances.i have to search for module name in the two files and comapare the
contents of the modules in the two files.
i have code it does module search,extract the contents of modules and compare
them and print the differnces.
BUT THE PROBLEM IS
I have same module 10 to 15 times in each file.
so what i have to do is take the the module name and for all occurrances
of module i have to take content in itand compare with other file
same module contents.but both the files have equal modules.
i was sending the files as attchements
use warnings;
#use Getopt::Long;
#$filename1;
#$filename2;
#$modul;
#@args = @ARGV;
#print "Getting the options";
#$ok = &GetOptions("args" => sub { &PrintArgs(\@args) },
# "h|help|?" => sub { &Help },
# "filename1=s" => \$filename1,
# "filename2=s" => \$filename2,
# "modul=s" => \$modul);
print "\n\n";
$filename1='isemapped.ncd.v';
$filename2='rodinmapped.ncd.v';
print " --------------------------------File1: $filename1 File2:$filename2 -------------------------------------\n\n\n\n";
$modul='X_RAMB18E1';
$string1 = readfile( $filename1);
$string2 = readfile( $filename2);
if($modul eq 'X_MMCM_ADV' or $modul eq 'X_RAMB18E1' or $modul eq 'X_RAMB36E1' or $modul eq 'X_FIFO36E1')
{
&mod1;
}
elsif($modul eq 'i_MMCM_ADV')
{
&mod2;
}
else
{
print "module not found";
}
sub readfile {
$file = shift;
local $/;
open $fh,'<',"$file" or die "open of $file failed: $!\n";
<$fh>;
};
sub Help {
$tmp = '\$';
print <<EOF
Usage\:perl pr2.pl -filename1 ise_routed.v -filename2 rodin_routed.v -modul X_MMCM_ADV
This script is used to generate a report of differences between modules of
file1 and file2taking module as another input parameter.
so according to the module name module based comparision will be done
EOF
;
exit 0;
}
sub mod1(){
$string1 =~ /$modul #\(([^;]*)\);/s;
$modcode_from_1 = $1;
open (MYFILE, '>module1.txt');
print MYFILE "$modcode_from_1\n";
close (MYFILE);
undef $string1;
$modcode_from_1 =~ s/[[:cntrl:]]//gm;
$string2 =~ /$modul #\(([^;]*)\);/s;
$modcode_from_2 = $1;
open (MYFILE1, '>module2.txt');
print MYFILE1 "$modcode_from_2\n";
close (MYFILE1);
undef $string2;
$modcode_from_2 =~ s/[[:cntrl:]]//gm;
@codes1 = split /\,/, $modcode_from_1;
@codes2 = split /\,/, $modcode_from_2;
print "\t\t****************THE DIFFERENCES IN THE FILES ARE AS FOLLOWS****************\n\n\n";
printf "\t\t\t%-45s %s\n\n\n", $filename1, $filename2;
$i = 0;
foreach ( @codes1) {
unless ( $codes1[$i] eq $codes2[$i]) {
printf "\t%-45s is not the same as %s\n\n", $codes1[$i], $codes2[$i];
}
$i++;
}
}
sub mod2(){
$string1 =~ /$modul \(([^;]*)\);/s;
$modcode_from_1 = $1;
open (MYFILE, '>module1.txt');
print MYFILE "$modcode_from_1\n";
close (MYFILE);
undef $string1;
$modcode_from_1 =~ s/[[:cntrl:]]//gm;
$string2 =~ /$modul \(([^;]*)\);/s;
$modcode_from_2 = $1;
open (MYFILE1, '>module2.txt');
print MYFILE1 "$modcode_from_2\n";
close (MYFILE1);
undef $string2;
$modcode_from_2 =~ s/[[:cntrl:]]//gm;
@codes1 = split /\,/, $modcode_from_1;
@codes2 = split /\,/, $modcode_from_2;
print "\t\t****************THE DIFFERENCES IN THE FILES ARE AS FOLLOWS****************\n\n\n";
printf "\t\t\t%-45s %s\n\n\n", $filename1, $filename2;
$i = 0;
foreach ( @codes1) {
unless ( $codes1[$i] eq $codes2[$i]) {
printf "\t%-45s is not the same as %s\n\n", $codes1[$i], $codes2[$i];
}
$i++;
}
suppose if we take X_RAMB18E1 module it is present 15 times in each file.
but different is instances.so i have to take module in on file and compare it with other and print the diff.again upto the last occurance of module i have to do that.
so if select the X_RAMB18E1 comparision should be done in all 15 and print the differences
file1 file2 instance name
X_RAMB18E1 is occured 15 times each occurance has an instance different.
it below lock parameter in code.
i have uploaded the instances also.
'PLEASE TRY TO HELP ME"
YOU HELP ME FOR ONE ONE MODULE I WILL WORK FOR OTHER BY REFERENCE