Beruflich Dokumente
Kultur Dokumente
/usr/bin/perl
##############################################################################
## Description # This script generates a template vhdl file form a port list
##############################################################################
## Date # Who # Version # Details
##############################################################################
## 10/06/08 # Avi # 1 # Initial Revision
##############################################################################
#-$Author: amittal $
#-$Date: Thu Jun 26 15:57:29 2008 $
#-$Revision: 1.3 $
#-$Log: genEntity.pl.rca $
#-
#- Revision: 1.3 Thu Jun 26 15:57:29 2008 amittal
#- Removed comment bug
#-$Revision: 1.3 $
#-$KeysEnd$
use File::Find;
use Cwd;
$iter = 0;
if($#ARGV < 0) {
print "ERROR: insufficient fields\n";
print "Usage:\nlinux_prompt> genEntity.pl <port list file>\n";
print "\n";
print "Example Port list file is given below,# is a comment character\n";
pHelp();
exit;
}
if(!(-f @ARGV[0]))
{
print "ERROR! Input file @ARGV[0] does not exists. . . Exiting\n";
exit;
}
$cwd = getcwd();
@paths = split(/\//,$cwd);
$block_dir = pop(@paths);
$user_dir = pop(@paths);
$ff = "$ARGV[0]";
#t#@ffs = split(/\//, $ff);
#t#$out_file_name = pop(@ffs);
#f#print "file name minus path = $out_file_name,array = @ffs,orig argv0 = $ff\n";
#t#$line_number = 0;
open(infile0,"<$ff") || die "Couldnft open infile0. $ff\n ";
#system("awk f/module/,/endmodule/f @ARGV[0]>@ARGV[0].module")
$found_entity = 0;
$found_arch = 0;
while ($line0 = <infile0>)
{
chomp($line0);
$line_number ++;
$line0 =~ s/^/ /g; #add a space at start
$line0 =~ s/$/ /g; #add a space at end
$line0 =~ s/\-\-.*//g; #remove comments
$line0 =~ s/#.*//g; #remove comments
#print "line0 comment removed = $line0\n";
next if(!($line0 =~ /(\w+)/)); #Revmoved Empty lines
if($line0 =~ /( entity)(\s+)(\w+)(\s+)(\w+)/)
{
print "ERROR! T0: At $line_number:($line0): Expected Input is of the form
\n";
print "entity entity_name\n";
exit;
}
elsif($line0 =~ /(architecture)(\s+)(\w+)(\s+)(\w+)/)
{
print "ERROR! T1: At $line_number:($line0): Expected Input is of the form
\n";
print "architecture architecture_name\n";
exit;
}
elsif($line0 =~ /(port)(\s+)(\w+)(\s+)(\w+)(\s+)(\w+)(\s+)(\w+)/)
{
print "ERROR! T2: At $line_number:($line0): Expected Input is of the form
\n";
print "port port_name port_direction port_type_or_size\n";
exit;
}
elsif($line0 =~ /( entity)(\s+)(\w+)/)
{
#print "Found entity = $3\n";
$entity_name = $3;
$found_entity = $found_entity + 1;
}
elsif($line0 =~ /( architecture)(\s+)(\w+)/)
{
#print "Found architecture = $3\n";
$arch_name = $3;
$found_arch = $found_arch + 1;
}
elsif($line0 =~ /( port)(\s+)(\w+)(\s+)(\w+)(\s+)(\w+)/)
{
#print "Found port = $3\n";
push(@ports_dir,$5);
push(@ports_type,$7);
push(@ports,$3);
if($7 =~ /\D/)
{
push(@generics, $7); #Non Digits
}
}# elsif($line0 =~ /( port)(\s+)(\w+)(\s+)(\w+)(\s+)(\w+)/)
else
{
print "ERROR! T3: At $line_number:($line0): Expected Input is of the form
\n";
pHelp();
}
sub pHelp
{
print "------------------\n";
print "#port_name direction size_type\n";
print "entity state_machine \n";
print "port clk in 1\n";
print "port rstn in 1\n";
print "port datain IN width1\n";
print "port dataout OUT width2\n";
print "port ready out 1\n";
print "port sync_out out mydatatype\n";
print "port fft_out out 8\n";
print "architecture rtl\n";
print "-----------------------\n";
exit;
}