Thank you roboticus for reading the post and providing some valuable feedback. You have justified things rightly. I agree with your points. The fact is, I am not at all good at this language. For the purpose of automation I use perl and I seek help Monks from Perl Monks :). But I can assure you I noted all the valuable feedback and this will always be reflected for my next perl assignment.

Let me explain you what is the expectation from the code.

I need to compare the different bias voltages, one which we picked up from "mnk_alpha" and the other from the files, inside of lib_pg directory.For example "put cornerData(ffg0p82v100c) {VDD 0.825,VDDQN 1.17,VDDM 1.17 +,TEMP 100} " line bias voltages for the given PVT ffg0p82v100c of mnk_alpha file and the corresponding file (file name must be <cell_name>_PVT_pg.lib, here the cell name is "mnk_lib" and PVT is ff0p82v100c. We are omitting the word "g") inside mnk_lib/lib_pg/mnk_lib_ff0p82v100c_pg.lib, if it is wrong it will flag an ERROR message. Beside this if any bias voltages are missing from any of the file, it will also display the message. Please follow the desired output in the terminal or in a separate file after running the code.

DESIRED OUTPUT

PVT === ffg0p82v100c File mnk_alpha ==== VDD 0.825,VDDQN 1.17,VDDM 1.17 File mnk_lib_ff0p82v100c_pg.lib ===== VDDQN 1.1, VDDM 1.1,VSS 0 Bias voltage differences has been observed for VDDQN, VDDM. Missing Bias voltages VSS from mnk_alpha file. VDD from mnk_lib_ff0p82v100c_pg.lib file PVT === ssg0p905v100c File mnk_alpha === VDD 0.825,VDDQN 1.1,VDDM 0.17 File mnk_lib_ss0p905v100c_pg.lib ===== VDDQN 1.1, VDDM 1.1,VSS 0 Bias voltage differences has been observed for VDDQN, VDDM. Missing Bias voltages VSS from mnk_alpha file. VDD from mnk_lib_ss0p905v100c_pg.lib file PVT === tt0p40v100c File mnk_alpha === VDD 0.825,VDDQN 1.07,VDDM 2.15 File mnk_lib_tt0p40v100c_pg.lib ===== VDDQN 1.1, VDDM 1.1,VSS 0 Bias voltage differences has been observed for VDDQN, VDDM. Missing Bias voltages VSS from mnk_alpha file. VDD from mnk_lib_tt0p40v100c_pg.lib file

At time of posting I was not very clear what should be the desired output and please accept my sincere apologies for this.

Few things I want to explain more to avoid confusions :)

1. The file inside <Cell>/lib_pg/ directory could be mnk_lib_ss0p905v100c_pg.lib or mnk_lib_ssg0p905v100c_pg.lib. And that is why I did some operations in the first posted code.

2. The code which I posted at the beginning, actually just grepping the bias voltages but not comparing.

I hope this can give some light to understand the problem. I updated the code, and this look like this ::
use strict; use warnings; my $in_macro = $ARGV[0]; my $alpha_config = $ARGV[1]; if ($#ARGV!=1) { print "USAGE :: perl bias_mnk.pl <<CELL_NAME>> <<config_FILE>> \n +\n"; exit(1); } my $pvt_name; my $bias_voltage; my @bias_voltage; open my $ALPHAFILE, "<", $alpha_config or die "Can not open config_FIL +E"; while (my $line = <$ALPHAFILE>) { chomp $line; print "alpha[$.]: $line \n"; if ($line =~m/\s*cornerData\((.*)\)\s*\{(.*),TEMP\s*(.*)/g) { $pvt_name = $1; $bias_voltage = $2; print " PVT_NAME: $pvt_name\n"; print " BIAS_V: $bias_voltage\n"; @bias_voltage = split (',',$bias_voltage); if ($pvt_name =~m/^([a-z].*)([0-9]p.*)/) { my ($process, $vol_temp) = ($1, $2); my $process_two = substr($process, 0, 2); #got ff from ffg +p my @vol_temp = split ('v',$vol_temp); my $temp = $vol_temp[1]; my $volt_1 = $vol_temp[0]; $volt_1 =~ s/[0]$//; $vol_temp[0] =~ s/[0]$//; my $volt_2 = $vol_temp[0]; my @volt_2 = split('p',$volt_2); $volt_2 = join('.',@volt_2); #replacing p with . my $file_name1 = "$in_macro/lib_pg/$in_macro\_$pvt_name\_p +g.lib"; if (-e $file_name1) { print " FNAME 1: $file_name1\n"; my $data = handle_library_file($file_name1); # Do something with the $data } my $file_name2 = "$in_macro/lib_pg/$in_macro\_$process_two +$volt_1\v$temp\_pg.lib"; if (-e $file_name2) { print " FNAME 2: $file_name2\n"; my $data = handle_library_file($file_name2); # Do something with the $data } } } } sub handle_library_file { my $file_name = shift; open my $LIBFILE, "<", $file_name or die "Can not open INPUT liber +ty file $file_name: $!"; while (my $libline = <$LIBFILE>) { chomp $libline; if ($libline=~m/^\s*voltage_map\((.*)\)/g) { my @volt_array = ("$1"); my $lib_volt = $1; my @lib_volt = split (',',$lib_volt); print "FILE lib_volt: @lib_volt \n"; } } # After gathering and processing the data, return it! }

In reply to Re^2: Comparing values from two different files and flag error by anirbanphys
in thread Comparing values from two different files and flag error by anirbanphys

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.