VHDL to HTML ¹ôȯ ½ºÅ©¸³Æ®...

 

# VHDL TO HTML Script Go To Script Pool
#
#

# This script converts a VHDL file to HTML with all VHDL keywords
# in bold face type.
#
# Rex Hill
# Applied Research Laboratory
# Washington University in St. Louis
# rex@arl.wustl.edu
#

# Die if the program doesn't receive a filename of the form
# foo.vhd

if($ARGV[0] =~ /\.vhd$/) {
}
else {
printf("Usage: perl vhdltohtml.pl <file>.vhd\n");
exit(-1);
}

# If we have a filename of the form foo.vhd, open that file
$vhdlname = $ARGV[
0];
$success =
open(VHDLFILE,$vhdlname);
if(!$success) {
printf("Couldn't open VHDL file %s. Exiting.\n",$vhdlname);
exit(-1);
}

# Copy the vhdl filename over and change the suffix to .html
# Open that file for writing.

$htmlname = $vhdlname;
$htmlname =~
s/\.vhd$/.html/;
$success =
open(HTMLFILE,">".$htmlname);
if(!$success) {
printf("Couldn't open HTML file %s for writing. Exiting.\n",$htmlname);
exit(-1);
}

# Open the keyword file
$success =
open(KEYWORDFILE,"vhdl.keywords");
if(!$success) {
printf("Couldn't open keyword file vhdl.keywords for reading.\n");
printf("If you are missing the vhdl.keywords file, you can\n");
printf("create your own by putting your favorite VHDL keywords\n");
printf("into a new vhdl.keywords file, one to a line\n");
printf("Exiting.\n");
exit(-1);
}

# Read the keywords into an array
@keywords = <KEYWORDFILE>;
for($i=0; $i<=$#keywords; $i=$i+1) {
chop($keywords[$i]);
}

printf("Converting %s to %s\n",$vhdlname,$htmlname);

# Print out the HTML header information
printf(HTMLFILE "<html>\n");
printf(HTMLFILE " <head>\n");
printf(HTMLFILE " <title>%s</title>\n",$vhdlname);
printf(HTMLFILE " </head>\n");
printf(HTMLFILE " <body>\n");
printf(HTMLFILE " <H1 align=center font=+2>\n");
printf(HTMLFILE " %s\n",$vhdlname);
printf(HTMLFILE " </H1>\n");
printf(HTMLFILE " <pre>\n");

# For each line in the VHDL file, split it into a line of text
# and a comment (the comment may be empty). In the line of
# text, look for each keyword in the @keywords array and
# surround each found keyword by <b></b> tags to make it bold.
# For each comment, surround it by <i></i> and <font color></font>
# tags to make the comment italicized and dark red.

while($theline = <VHDLFILE>) {
$theline =~
s/\n//;
($theline,$thecomment) = split(/--/,$theline);
if($thecomment ne "") {
$thecomment =~
s/^/--/;
}
for($i=0; $i<=$#keywords; $i=$i+1) {
if($keywords[$i] ne "") {
$theline =~
s/\b($keywords[$i])\b/<b>\1<\/b>/g;
}
}
$thecomment =~
s/(--.*)/<i><font color=#a00000>\1<\/font><\/i>/g;
printf(HTMLFILE "%s%s\n",$theline,$thecomment);
}

# Put the ending tags in the HTML file.
printf(HTMLFILE " </pre>\n");
printf(HTMLFILE " </body>\n");
printf(HTMLFILE "</html>\n");

#
#
# END...

 

 



Copyleft Chang-woo,YANG