Friday, 30 January 2015

Using Perl in your VHDL Design By Elecdude


/************************************************************************************/
 Author: ElecDude
         admin@elecdude.com        

 Please report bugs, errors, modifications, etc. Thank you

 Copyright - 2015 - ElecDude

 USAGE AND REDISTRIBUTION OF THIS SOURCE CODE IS PERMITTED PROVIDED THAT
 THE FOLLOWING CONDITIONS ARE MET:

    1. REDISTRIBUTIONS OF SOURCE CODE MUST RETAIN THE ABOVE ORIGINAL COPYRIGHT
  NOTICE AND THE ASSOCIATED DISCLAIMER, THIS LIST OF CONDITIONS AND
  THE FOLLOWING DISCLAIMER.
    2. REDISTRIBUTIONS IN BINARY FORM MUST REPRODUCE THE ABOVE COPYRIGHT
  NOTICE, THIS LIST OF CONDITIONS AND THE FOLLOWING DISCLAIMER IN
  THE DOCUMENTATION AND/OR OTHER MATERIALS PROVIDED WITH THE
  DISTRIBUTION.

 THIS IS PROVIDED WITHOUT ANY  EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
 BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 A PARTICULAR PURPOSE ARE DISCLAIMED. TO BE USED FOR LEARNING PURPOSE ONLY.  
 IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT OWNER, BE LIABLE FOR ANY DIRECT,
 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ARISING IN ANY WAY OUT OF THE
 USE OF THIS SOURCE CODE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
/************************************************************************************/

print "\nWelcome to ElecDude...";
print "\n Enter file name in FULL (header1.h, file1.c,  module1.v, entity1.vhd,...) :";
$finp = <STDIN>;
chomp $finp;
print "\n ";

$char="";
$char1="";

if ($finp =~ m/.[chv]$/i) { #// //
    $char1="// // // // // // // // // // // // // // // // // // // // // // // // // // // // //  // ";
$char="//";
print "\n Adding copyright for C/Verilog..";
} elsif($finp =~ m/.pl$/i) {# # #
$char1="#   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #   #  # ";
$char="#";
print "\n Adding copyright for PERL..";
} elsif($finp =~ m/.vhd$/i) {# -- --
$char1="--  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  --  -- ";
$char="--";
print "\n Adding copyright for VHDL..";
} else {
print "Couldn't identify input file type...\n";
exit;
}
# exit;
open($DCR, "<ED_Copyright.txt") or die "Couldn't open file ED_Copyright.txt";
open(DATA_O, ">new_$finp") or die "Couldn't open file new_$finp";

print DATA_O ("$char1\n");
while (!eof($DCR)) 
{
  my $line1 = <$DCR>;
  chomp $line1;
  print DATA_O ("$char $line1\t$char \n");
}
close($DCR);
print DATA_O ("$char1\n");

open($DIN, "<$finp") or die "Couldn't open file $finp.";
print "\n Adding the Source File contents...";
while (!eof($DIN)) 
{
  my $line1 = <$DIN>;
  chomp $line1;
  print DATA_O ($line1, "\n");
}
close($DIN);
close(DATA_O);

print "\n File (new_$finp) with Copyright contents created succesfully";
system "start new_$finp";

print "\n Press ENTER key to end..."; $key = getc(STDIN);


If you enjoyed this post plz let us know your views via comments.
This helps us to do much more better.
Thankyou.


Reactions:

0 comments:

Post a Comment

Search Here...