How to compare content of modules in text files

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

    How to compare content of modules in text files

    Hello,
    i was a beginner in perl .but my TL gave me critical work.
    my task looks simple!But not.i was trying for 4days.
    i have uploaded the files also.


    i have two text files each contain code in modules.

    my task i have to take module name from the user

    and search the module in file.whenever module is found

    i have to take the content in the module into on string

    or array ,ETc

    similarly i have to perform the search in 2nd file also and finally

    compare the content in the modules and print the code which is different.


    i can able to search upto module name.then after i can't

    module looks like

    (i have to search the module first upto i_MMCM_ADV then after take the contents after

    brackets into dummy variable upto ;)

    for anothe i have to do the same and compare the contents


    .CLKIN1_PERIOD ( 5.000000 ),
    .CLKIN2_PERIOD ( 5.000000 ),
    .LOC ( "MMCM_ADV_X 0Y5" ),
    .VCOCLK_FREQ_MA X ( 1200.000000 ),
    .VCOCLK_FREQ_MI N ( 600.000000 ),
    .CLKIN_FREQ_MAX ( 700.000000 ),
    .CLKIN_FREQ_MIN ( 10.000000 ),
    .CLKPFD_FREQ_MA X ( 450.000000 ),
    .CLKPFD_FREQ_MI N ( 10.000000 ))
    start i_MMCM_ADV (
    .CLKFBIN(CLKFBI N),
    .PSCLK(GND),
    .PWRDWN(\i_MMCM _ADV/PWRDWN_INT ),
    .DCLK(GND),
    .DEN(GND),
    .CLKINSEL(\i_MM CM_ADV/CLKINSEL_INT ),
    .CLKIN2(GND),
    .RST(\i_MMCM_AD V/RST_INT ),
    .PSINCDEC(\i_MM CM_ADV/PSINCDEC_INT ),
    .DWE(GND),
    .PSEN(\i_MMCM_A DV/PSEN_INT ),
    .CLKIN1(clk_IBU F_2571),
    .CLKOUT3(CLKOUT 3),
    .CLKOUT3B(\i_MM CM_ADV/CLKOUT3B ),
    .CLKFBOUT(CLKFB OUT),
    .CLKFBSTOPPED(\ i_MMCM_ADV/CLKFBSTOPPED ),
    .CLKFBOUTB(\i_M MCM_ADV/CLKFBOUTB ),
    .CLKOUT1(CLKOUT 1),
    .CLKOUT5(CLKOUT 5),
    .DRDY(\i_MMCM_A DV/DRDY ),
    .CLKOUT0(clk_ou t0_OBUF_2333),
    .CLKOUT4(CLKOUT 4),
    .CLKOUT1B(\i_MM CM_ADV/CLKOUT1B ),
    .CLKINSTOPPED(\ i_MMCM_ADV/CLKINSTOPPED ),
    .CLKOUT0B(\i_MM CM_ADV/CLKOUT0B ),
    .CLKOUT2(CLKOUT 2),
    .CLKOUT2B(\i_MM CM_ADV/CLKOUT2B ),
    .PSDONE(\i_MMCM _ADV/PSDONE ),
    .CLKOUT6(CLKOUT 6),
    .LOCKED(LOCKED_ OBUF_2386),
    .DI({GND, GND, GND, GND, GND, GND, GND, GND, GND, GND, GND, GND, GND, GND, GND, GND}),
    .DADDR({GND, GND, GND, GND, GND, GND, GND}),
    .DO({\i_MMCM_AD V/DO15 , \i_MMCM_ADV/DO14 , \i_MMCM_ADV/DO13 , \i_MMCM_ADV/DO12 , \i_MMCM_ADV/DO11 , \i_MMCM_ADV/DO10 , \i_MMCM_ADV/DO9 ,
    \i_MMCM_ADV/DO8 , \i_MMCM_ADV/DO7 , \i_MMCM_ADV/DO6 , \i_MMCM_ADV/DO5 , \i_MMCM_ADV/DO4 , \i_MMCM_ADV/DO3 , \i_MMCM_ADV/DO2 , \i_MMCM_ADV/DO1 ,
    \i_MMCM_ADV/DO0 })
    ); END
    X_SRLC16E #(
    .LOC ( "SLICE_X0Y1 02" ),
    .INIT ( 16'h0000 ))
    \dsync_r6/Mshreg_dout_0 (
    .A0(1'b0),
    .A1(1'b0),
    .A2(1'b0),
    .A3(1'b0),
    .CLK(\NlwBuffer Signal_dsync_r6/Mshreg_dout_0/CLK ),
    .D(r6[0]),
    .Q15(\NLW_dsync _r6/Mshreg_dout_0_Q 15_UNCONNECTED ),
    .Q(\dsync_r6/Mshreg_dout_0_3 03 ),
    .CE(1'b1)



    The code i have developed is:


    use Getopt::Long;
    my $file1;
    my $file2;
    my $modul;

    my %hash1;
    my %hash2;
    print "Getting the options";
    my $ok = &GetOptions("ar gs" => sub { &PrintArgs(\@ar gs) },
    "h|help|?" => sub { &Help },
    "file1=s" => \$file1,
    "file2=s" => \$file2,
    "modul=s" => \$modul,
    "server=s" => \$dbserver,
    "datasource =s" => \$datasource,
    "v+" => \$verbose,
    "version" => sub { &Version });
    #print " hi $file1";

    open file1, "$file1" or die "Could not open file \n";
    open file2, "$file2" or die "Could not open file \n";




    while (<file1>)
    {
    @san=split " ", $_;
    for $i(@san)
    {


    if ( $i eq "$modul")
    {
    while($i != ";")
    {
    @arra=$i;
    }
    print "@arra";
    print "out of array";
    #print "hi found";
    }
    else
    {
    #print "sorry";
    }
    }
    }

    so i was able to take files read file and go to that module.

    after that i want the way to take content of module upto semicolan.

    for one file if i get and i can do the for other file and comapare them
    Attached Files
    Last edited by koduruabhinav; Sep 4 '10, 07:59 AM. Reason: to give clear explanation
  • toolic
    Recognized Expert New Member
    • Sep 2009
    • 70

    #2
    What part of the task is giving you trouble?

    Do you know how to open a file?
    Do you know how to read through the file to find the strings of interest?

    Show the code you have been working on for 4 days.

    Since your input files look like Verilog code, a long-term solution might be to parse them using
    Verilog-Perl.

    However, since you are new to Perl, that might be a bit advanced. Let's start with perlintro.

    Comment

    • pradeepkr13
      New Member
      • Aug 2010
      • 43

      #3
      Get the whole file content into a string variable and then do a regular expression match.

      Try this,

      Code:
      #you have all the file into the variable $var
      $modul = 'i_MMCM_ADV';
      if ($var =~ m/start\s+$modul([^;]*);\s+END/si)
      {
       print "Module content ",$1;
      }else
      {
        print 'No luck';
      }

      Comment

      Working...