Email: bknpk@hotmail.com Phone: +972-54-7649119
V

 

ASIC/FPGA Design and Verification Out Source Services

Filter your print output with command line PERL

  1. The need for very short, code of PERL, help arises often.

  2. In some cases only a very few lines will do. So writing a script is an overkill.

  3. I will describe such a case.
    I have a huge file, which is an output of simulation.
    The activity of many TDM ports are listed in the log. Well if I did not say, it is a SONET project, but it does not do matter for us now.
    Many ports are listed there and which are the ones that do not have active data on them
    An active port has this data written in the simulation log file:
    ...
                                bla bla id=0334 bla bla
    bla bla id=0334 bla bla
    bla bla id=0334 bla bla
    bla bla id=0334 bla bla
    bla bla id=0334 bla bla
    bla bla id=0335 bla bla
    bla bla id=0335 bla bla
    bla bla id=0335 bla bla
    bla bla id=0335 bla bla
    ...
    So the examples shows ports 334 and 335 are active, but are there more.

  4. I simply use a single command to find out:
    grep "dbg pini mon vc11_12 EXP id=" TSF_and_VC11_LOP.pinik.09_06_18_14_21_14/chain_0/run_1/specman.elog | sort -n --key=5 | perl -e 'while() { if($_ =~ /(id=[0-9]*)/) {print("$1\n");}}' | uniq

  5. Looks complex. Well first extract the interesting lines using the grep command.

  6. Next we sort the output using sort command on the fifth field.
    Note sort is required for later unique entry filtering.

  7. For unique entry filtering, we must have only the TDM port in the output. Here comes PERL command line very handy. All the standard is read and processed so only the interesting field is printed out.

  8. All we got to do now is pipe the output to the uniq command.

  9. This site contains pages describing design and verification using HDL languages such VHDL, and system C. Best way to look out your way in this site is using the search my site option at the end of the page. You may select from some predefined words or you can use your own ones.


  10. To run an IP scan on a loop of addresses using perl:
    perl -e 'for (1..254) {$ip="192.168.0.$_"; system("ping -c 1 $ip")} '

  ...


Home

Download Area






Search This Site


Feedback This Site




new pages on this site