vhdl2html.pl

brought to you by:

All content, diagrams, equations, html and css by Benj Carson, Jeff Mrochuk, Imran Waheed & Eric Tan, unless otherwise noted. Please send any questions, suggestions or other feedback to Benj Carson

Description

Ever get tired of reading bland code in the student appnote section of the 552 website? Well, the solution has arrived. vhdl2html.pl is a Perl script that parses vhdl files and adds syntax highlighting to html output. It was originally written by Rex Hill (as seen here), but was modified by Benj Carson to add CSS support and greater syntactic accuracy. Now any style can be applied to keywords, types, standard packages, attributes and operators.

Example

Before vhdl2html.pl:After vhdl2html.pl:
-- adder_1.vhd

library ieee;
use ieee.std_logic_1164.all;

entity adder_1 is

  port (
    a, b, cin   : in  std_logic;
    sum, cout   : out std_logic);

end entity adder_1;

architecture demo of adder_1 is

begin  -- architecture demo

  sum <= (a xor b) xor cin;
  cout <= (a and b) or (cin and a) or (cin and b);
  
end architecture demo;

-- adder_1.vhd

library ieee;
use ieee.std_logic_1164.all;

entity adder_1 is

  port (
    a, b, cin   : in  std_logic;
    sum, cout   : out std_logic);

end entity adder_1;

architecture demo of adder_1 is

begin  -- architecture demo

  sum <= (a xor b) xor cin;
  cout <= (a and b) or (cin and a) or (cin and b);
  
end architecture demo;
 

Installation and Use

vhdl2html.pl is easy to install and use. Simply follow these steps:

  1. Make sure Perl is installed on the system you're using. In *NIX you can type "which perl" to see if it is in your path, or failing that "find / -name perl -ls".
  2. Download either vhdl2html.tar.gz or vhdl2html.zip.
  3. Extract the archive into a directory (tar xvzf vhdl2html.tar.gz or unzip vhdl2html.zip or use WinZip).
  4. You will need to make a few changes to the source to ensure paths are correct. Open vhdl2html.pl in your text editor of choice and ensure that the first line points to your Perl interpreter (found in step 1).
  5. Change $SYNTAXFILEPATH to the directory where the syntax lists will reside (i.e. vhdl.keywords, vhdl.attributes etc.). I used /usr/local/share/vhdl2html/ on my box at home, but if you're using nyquist, you might want to keep it under your home directory. Save your changes and close your editor.
  6. Ensure that vhdl2html.pl has execute permissions. Type "chmod 755 vhdl2html.pl".
  7. That's it!

To use vhdl2html.pl, simply type "/path/to/vhdl2html.pl foo.vhd". If the script can't find the syntax files, it will let you know, but if it works, it will output foo.html which is ready to go. Copy both the html file and style.css to their final destinations as required by your webserver.

If you want to make changes to the colors or styles applied, simply open style.css and edit away!

All content, diagrams, equations, html and css by Benj Carson, Jeff Mrochuk, Imran Waheed & Eric Tan, unless otherwise noted. Please send any questions, suggestions or other feedback to Benj Carson