modules and instances comparision IN FILES

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • koduruabhinav
    New Member
    • Sep 2010
    • 8

    #1

    modules and instances comparision IN FILES

    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


    Code:
    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
    Attached Files
  • koduruabhinav
    New Member
    • Sep 2010
    • 8

    #2
    hi please anyone can help me faster

    Hi,
    the example was very useful for this basic programmer and working for 0ne instance.


    in short my problem is

    1. read the files
    2.find the module

    3.compare the file1 X_RAMB18E1 and file 2 X_RAMB18E1

    4.for each and every time and print the differences


    so for example if X_RAMB18E1 occurs "n" times in file1

    and X_RAMB18E1 occurs "n" time in file 2.N is not known

    if n =15



    i have to print differences for 15 times occuranceBut actually what i want is to print the differences

    between number of modules of same name in two files.
    instance is some what like

    1.) \U_eth_aggregat or_tb/eth_aggregator/core_0/client_side_FIF O1/rx_fifo_i/ramgen_u

    instance in X_RAMB18E1 for the first time

    2.) \U_eth_aggregat or_tb/eth_aggregator/core_0/central_memory/Mram_txmemory8

    instance in X_RAMB18E1 for module occurance for the second time


    like wise X_RAMB18E1 occurs 18 times each with different instance.

    in the example file1 i have send only two modules of X_RAMB18E1


    SO WHAT i want is if i give any module name the code should check occurance of module

    if occurs then it should take the content of module from #( to semicolan

    so upto now i can do this only for one module at a time.

    i was trying to excute with while loop the code but i was unable....

    Comment

    Working...