Determination of fileType (verilog, VHDL or System Verilog)

V

very_log

Guest
I have a list of HDL files.
How do I find out the type of each file (Verilog, System Verilog or
VHDL) ?
Would be great if some simple utility in C/C++ is already there.
I dont need to know the flavours of verilog like 95, 2000 etc but
wouldn't mind the extra info if there.
 
On 2007-12-11, very_log <sachin.goyal.new@gmail.com> wrote:
I have a list of HDL files.
How do I find out the type of each file (Verilog, System Verilog or
VHDL) ?
Would be great if some simple utility in C/C++ is already there.
I dont need to know the flavours of verilog like 95, 2000 etc but
wouldn't mind the extra info if there.
Personally, I would just look at the file extension, if someone
doesn't name files properly he or she should expect problems :)

Another possibility: Just try to compile it with your current
RTL simulator and see if it compiles cleanly using either
Verilog, SystemVerilog or VHDL mode.

But if for some reason this is impractical it will be quite
hard to distinguish between SystemVerilog and Verilog files
since a file can be both legal Verilog and SystemVerilog at
the same time. In fact, an empty file is both a legal Verilog
and SystemVerilog file if I read the BNF correctly.

Distuingishing between a VHDL file and a non VHDL file is probably
easier if that is enough for you. I haven't looked into it too much,
but I believe it is just a matter of stripping all VHDL type comments
and look for the first keyword. If the first keyword isn't one of the
following keywords I don't think it can be a legal VHDL file:
architecture configuration entity library package use

Warning: It seems like the keyword "library" can be used to begin
a Verilog library source text as well. So if you are worried about
this the following script cannot be used without further
modifications. Also, the keyword "package" can appear in
SystemVerilog files, but in that case you will find the keyword
endpackage later on. (Checking for that will require some more
advanced parsing of the source files however since it wouldn't
be enough to just search for the string "endpackage" in the text.
(Due to comments, etc.) And there is probably something else I have
forgotten as well.


Here is the beginning of a bash script implemented along
the lines described above. Perhaps it can be of some use to you.

#!/bin/bash
# Tests if a file could be a VHDL file. (Or at least tries
# to do so, it hasn't been very well tested...)

function firstvhdlkeyword {
sed 's/^ *--.*$//' < $1 | egrep -v '^$' | head -1|\
egrep -i '^(architecture|configuration|entity|library|package|use)'
}

if firstvhdlkeyword $1 > /dev/null
then
echo Most probably VHDL
else
echo 'Probably not VHDL, perhaps Verilog?'
fi




/Andreas
 
On 11 Dec, 08:19, very_log <sachin.goyal....@gmail.com> wrote:
I have a list of HDL files.
How do I find out the type of each file (Verilog, System Verilog or
VHDL) ?
Would be great if some simple utility in C/C++ is already there.
I dont need to know the flavours of verilog like 95, 2000 etc but
wouldn't mind the extra info if there.
Hi,

Just to state the obvious, and sorry if this sounds a little
patronizing, but you would usually identify file types via the
extension.

e.g.
filename.vhd
filename.v (Verilog)
filename.vg (Verilog Netlist)
filename.sv (System Verilog? I am not sure whether there is a
'standard extension' in wide use).

Steven
 

Welcome to EDABoard.com

Sponsor

Back
Top