#! /usr/local/bin/perl # @(#)vlog2html 1.2 12/23/97 ################################################################## # NAME : vlog2html # # AUTHOR : Venkat Talapaneni # # PURPOSE: To convert Verilog files into HTML format. Highlights # # Keywords, Declarations, Subroutine commands, Comments # # in different colors. # # VERSION: 1.0 December 22nd, 1997. # # COPYRIGHT (C) 1997 Venkat Talapaneni (neni@comit.com) # # Comit Systems, Inc. # ################################################################## $debug = 0; &Usage if (!$ARGV[0] || $ARGV[0] =~ /-[uUhH]/); $infile = $ARGV[0]; $outfile = $ARGV[1] if $ARGV[1]; $tabfile = $ARGV[2] ? $ARGV[2] : "table.key"; $key_b = ""; #keyword begins $key_e = ""; #keyword ends $com_b = ""; #comment begins $com_e = ""; #comment ends $comment = "//"; if (!$outfile) { $outfile = $infile; $outfile =~ s/\.v$/\.html/; $outfile .= ".html" if ($infile eq $outfile); } open(IN, "$infile") || &Err("Couldn't open $infile\n"); open(OUT, ">$outfile") || &Err("Couldn't open $outfile for writing.\n"); #&ReadTable($tabfile); &BuildKeyArray; &WriteOutHead; &Main; &WriteOutTail; sub Main { while(){ $_ =~ s/\t/ /; chop; @arr = split /\ /, $_; $comment_seen=0; foreach $word (@arr){ if ($comment_seen){ print OUT " $word"; next; } if ($word eq " "){ print OUT $word; } elsif ($word eq $comment){ $comment_seen = 1; print OUT $com_b, "$word "; } elsif (&IsKeyword($word, *key)){ print OUT $key_b, "$word ", $key_e; } else { print OUT "$word "; } } print OUT $com_e if $comment_seen; print OUT "\n"; } } sub ReadTable { local($tabfile) = $_[0]; local(@arr, $line); local($kcnt); open(TB, $tabfile) || &Err("Couldn't open table file $tab\n"); @tab = ; close(TB); undef $key; foreach $line (@tab){ chop $line; $line =~ s/^\s+//; # Eliminate comments, too! $line =~ s/##.*$//; @arr = split /\s+/, $line; if ($key){ foreach $ele (@arr){ $key[$kcnt++] = $ele; } } elsif ($arr[0] eq "KEYWORDS"){ $key =1; $kcnt =0; } } if ($debug){ print "\nTOTAL NO OF KEYWORDS: $kcnt"; foreach (@key){ print "$_ "; } print "\n"; } } sub IsKeyword { local($word) = $_[0]; local(*arr) = $_[1]; local($ele); foreach $ele (@arr){ return 1 if $word eq $ele; } return 0; } sub WriteOutHead { print OUT "\ $outfile
\n";
}

sub WriteOutTail {
    print OUT "
\n"; close(OUT); } sub Usage { print " vlog2html [] vlog_file Name of the Verilog file to be converted html_file Name of the output HTML file. Default is the name of the vlog_file, with .v substituted by .html Version: 1.0 Date: December 22nd, 1997. \n"; exit 1; } sub Err { print STDERR $_[0]; exit 1; } sub BuildKeyArray { @key = ( 'always', 'and', 'assign', 'attribute', 'begin', 'buf', 'bufif0', 'bufif1', 'case', 'casex', 'casez', 'cmos', 'deassign', 'default', 'defparam', 'disable', 'edge', 'else', 'end', 'endattribute', 'endcase', 'endfunction', 'endmodule', 'endprimitive', 'endspecify', 'endtable', 'endtask', 'event', 'for', 'force', 'forever', 'fork', 'function', 'highz0', 'highz1', 'if', 'initial', 'inout', 'input', 'integer', 'join', 'large', 'macromodule', 'medium', 'module', 'nand', 'negedge', 'nmos', 'nor', 'not', 'notif0', 'notif1', 'or', 'output', 'parameter', 'pmos', 'posedge', 'promitive', 'pull0', 'pull1', 'pulldown', 'pullup', 'rcmos', 'real', 'realtime', 'reg', 'release', 'repeat', 'rnmos', 'rpmos', 'rtran', 'rtranif0', 'rtranif1', 'scalared', 'signed', 'small', 'specify', 'specparam', 'strength', 'strong0', 'strong1', 'supply0', 'supply1', 'table', 'task', 'time', 'tran', 'tranif0', 'tranif1', 'tri', 'tri0', 'tri1', 'triand', 'trior', 'trireg', 'unsigned', 'vectored', 'wait', 'wand', 'wor', 'weak0', 'weak1', 'while', 'wire', 'xnor', 'xor', '$bitstoreal', '$countdrivers', '$display', '$fclose', '$fdisplay', '$fmonitor', '$fopen', '$fstrobe', '$fwrite', '$finish', '$getpattern', '$history', '$incsave', '$input', '$itor', '$key', '$list', '$log', '$monitor', '$monitoroff', '$monitoron', '$nokey', '`accelerate', '`autoexpand_vectornets', '`celldefine', '`default_nettype', '`define', '`else', '`endcelldefine', '`endif', '`endprotect', '`endprotected', '`expand_vectornets', '`ifdef', '`include', '`noaccelerate', '`noexpand_vectornets', '`noremove_gatenames', '`nounconnected_drive', '`protect', '`protected', '`remove_gatenames', '`remove_netnames', '`resetall', '`timescale', '`unconnected_drive' ); }