Add +1364-1995ext and similar language options, bug532.

This commit is contained in:
Wilson Snyder 2012-11-13 20:12:23 -05:00
parent 0e8ce59022
commit 7a8c425103
19 changed files with 531 additions and 64 deletions

View File

@ -5,6 +5,8 @@ indicates the contributor was also the author of the fix; Thanks!
* Verilator 3.84** devel
*** Add +1364-1995ext and similar language options, bug532. [Jeremy Bennett]
**** Fix svdpi compile issue on MSVCC, bug571. [Amir Gonnen]

View File

@ -241,6 +241,11 @@ descriptions in the next sections for more information.
{file.c/cc/cpp} Optional C++ files to compile in
{file.a/o/so} Optional C++ files to link in
+1364-1995ext+<ext> Use Verilog 1995 with file extension <ext>
+1364-2001ext+<ext> Use Verilog 2001 with file extension <ext>
+1364-2005ext+<ext> Use Verilog 2005 with file extension <ext>
+1800-2005ext+<ext> Use SystemVerilog 2005 with file extension <ext>
+1800-2009ext+<ext> Use SystemVerilog 2009 with file extension <ext>
--assert Enable all assertions
--autoflush Flush streams after all $displays
--bbox-sys Blackbox unknown $system calls
@ -261,6 +266,7 @@ descriptions in the next sections for more information.
--debug-check Enable debugging assertions
--debugi <level> Enable debugging at a specified level
--debugi-<srcfile> <level> Enable debugging a source file at a level
--default-language <lang> Default language to parse
+define+<var>+<value> Set preprocessor define
--dump-tree Enable dumping .tree files
--dump-treei <level> Enable dumping .tree files at a level
@ -279,7 +285,7 @@ descriptions in the next sections for more information.
--inline-mult <value> Tune module inlining
-LDFLAGS <flags> Linker pre-object flags for makefile
-LDLIBS <flags> Linker library flags for makefile
--language <lang> Language standard to parse
--language <lang> Default language standard to parse
+libext+<ext>+[ext]... Extensions for finding modules
--lint-only Lint, but do not make output
--MMD Create .d dependency files
@ -308,6 +314,7 @@ descriptions in the next sections for more information.
--sp Create SystemPerl output
--stats Create statistics file
-sv Enable SystemVerilog parsing
+systemverilogext+<ext> Synonym for +1800-2009ext+<ext>
--top-module <topname> Name of top level input module
--trace Enable waveform creation
--trace-depth <levels> Depth of tracing
@ -320,6 +327,8 @@ descriptions in the next sections for more information.
--unused-regexp <regexp> Tune UNUSED lint signals
-V Verbose version and config
-v <filename> Verilog library
+verilog1995ext+<ext> Synonym for +1364-1995ext+<ext>
+verilog2001ext+<ext> Synonym for +1364-2001ext+<ext>
-Werror-<message> Convert warning to error
-Wfuture-<message> Disable unknown message warnings
-Wno-<message> Disable warning
@ -355,6 +364,41 @@ this way, Verilator will include a make rule that uses these files when
linking the I<module> executable. This generally is only useful when used
with the --exe option.
=item +1364-1995ext+I<ext>
=item +1364-2001ext+I<ext>
=item +1364-2005ext+I<ext>
=item +1800-2005ext+I<ext>
=item +1800-2009ext+I<ext>
Specifies the language standard to be used with a specific filename
extension, I<ext>.
For compatibility with other simulators, see also the synonyms
C<+verilog1995ext+>I<ext>, C<+verilog2001ext+>I<ext>, and
C<+systemverilogext+>I<ext>.
For any source file, the language specified by these options takes
precedence over any language specified by the C<--default-language> or
C<--language> options.
These options take effect in the order they are encountered. Thus the
following would use Verilog 1995 for C<a.v> and Verilog 2001 for C<b.v>.
verilator ... +1364-1995ext+v a.v +1364-2001ext+v b.v
These flags are only recommended for legacy mixed language designs, as the
preferable option is to edit the code to repair new keywords, or add
appropriate C<`begin_keywords>.
B<Note> C<`begin_keywords> is a SystemVerilog construct, which specifies
I<only> which the set of keywords is to be recognized. Whatever set is
chosen, the semantics will be those of SystemVerilog. By contrast
C<+1364-1995ext+> etc. specify both the syntax I<and> semantics to be used.
=item --assert
Enable all assertions, includes enabling the --psl flag. (If psl is not
@ -536,6 +580,25 @@ to the specified debug level (1-10) or set the specified source file to the
specified level. Higher levels produce more detailed messages (plain
C<--debug> is equivalent to C<--debugi 4>).
=item --default-language I<value>
Select the language to be used by default when first processing each
Verilog file. The language value must be "1364-1995", "1364-2001",
"1364-2005", "1800-2005" or "1800-2009".
Any language associated with a particular file extension (see the various
+I<lang>ext+ options) will be used in preference to the language specified
by --default-language.
The --default-language flag is only recommended for legacy code using the
same language in all source files, as the preferable option is to edit the
code to repair new keywords, or add appropriate C<`begin_keywords>. For
legacy mixed language designs, the various +I<lang>ext+ options should be
used.
If no language is specified, either by this flag or +I<lang>ext+ options,
then the latest SystemVerilog language (IEEE 1800-2009) is used.
=item +define+I<var>+I<value>
Defines the given preprocessor symbol. Same as -D; +define is fairly
@ -645,15 +708,8 @@ in the Make variable LDLIBS, not LDFLAGS.)
=item --language I<value>
Select the language to be used when first processing each Verilog file.
The language value must be "1364-1995", "1364-2001", "1364-2001",
"1364-2005", "1800-2005", "VAMS-2.3". Verilator also allows the
non-standard "1800+VAMS" to allow both the full SystemVerilog and
Verilog-AMS keywords.
The --language flag is only recommended for legacy code, as the preferable
option is to edit the code to repair new keywords, or add appropriate
`begin_keywords.
A synonym for C<--default-langauge>, for compatibility with other tools and
earlier versions of Verilator.
=item +libext+I<ext>+I<ext>...
@ -860,6 +916,10 @@ Specifies SystemVerilog language features should be enabled; equivalent to
"--language 1800-2005". This option is selected by default, it exists for
compatibility with other simulators.
=item +systemverilogext+I<ext>
A synonym for C<+1800-2009ext+>I<ext>.
=item --top-module I<topname>
When the input Verilog contains more than one top level module, specifies
@ -935,6 +995,12 @@ Read the filename as a Verilog library. Any modules in the file may be
used to resolve cell instantiations in the top level module, else ignored.
Note -v is fairly standard across Verilog tools.
=item +verilog1995ext+I<ext>
=item +verilog2001ext+I<ext>
Synonyms for C<+1364-1995ext+>I<ext> and C<+1364-2001ext+>I<ext> respectively
=item -Wall
Enable all warnings, including code style warnings that are normally

View File

@ -80,22 +80,33 @@ const string FileLineSingleton::filenameLetters(int no) {
return op;
}
//! Convert filenames to a filenameno
//! This lets us assign a nice small identifier for debug messages, but more
//! importantly lets us use a 4 byte int instead of 8 byte pointer in every
//! FileLine.
//! We associate a language with each source file, so we also set the default
//! for this.
int FileLineSingleton::nameToNumber(const string& filename) {
// Convert filenames to a filenameno
// This lets us assign a nice small identifier for debug messages, but more
// importantly lets us use a 4 byte int instead of 8 byte pointer in every FileLine.
FileNameNumMap::const_iterator iter = m_namemap.find(filename);
if (VL_LIKELY(iter != m_namemap.end())) return iter->second;
int num = m_names.size();
m_names.push_back(filename);
m_languages.push_back(V3LangCode::mostRecent());
m_namemap.insert(make_pair(filename,num));
return num;
}
//! Support XML output
//! Experimental. Updated to also put out the language.
void FileLineSingleton::fileNameNumMapDumpXml(ostream& os) {
os<<"<files>\n";
for (FileNameNumMap::const_iterator it = m_namemap.begin(); it != m_namemap.end(); ++it) {
os<<"<file id=\""<<filenameLetters(it->second)<<"\" filename=\""<<it->first<<"\"/>\n";
os<<"<file id=\""<<filenameLetters(it->second)
<<"\" filename=\""<<it->first
<<"\" language=\""<<numberToLang(it->second).ascii()<<"\"/>\n";
}
os<<"</files>\n";
}
@ -170,6 +181,10 @@ FileLine* FileLine::copyOrSameFileLine() {
return newp;
}
void FileLine::updateLanguage () {
language(v3Global.opt.fileLanguage(filename()));
}
const string FileLine::filebasename() const {
string name = filename();
string::size_type pos;

View File

@ -30,6 +30,8 @@
#include <set>
#include <deque>
#include "V3LangCode.h"
//######################################################################
class V3ErrorCode {
@ -271,12 +273,18 @@ inline uint32_t cvtToHash(const void* vp) {
class FileLine;
//! Singleton class with tables of per-file data.
//! This singleton class contains tables of data that are unchanging in each
//! source file (each with its own unique filename number).
class FileLineSingleton {
// TYPES
typedef map<string,int> FileNameNumMap;
typedef map<string,V3LangCode> FileLangNumMap;
// MEMBERS
FileNameNumMap m_namemap; // filenameno for each filename
deque<string> m_names; // filename text for each filenameno
deque<V3LangCode> m_languages; // language for each filenameno
// COSNTRUCTORS
FileLineSingleton() { }
~FileLineSingleton() { }
@ -285,17 +293,22 @@ protected:
// METHODS
int nameToNumber(const string& filename);
const string numberToName(int filenameno) const { return m_names[filenameno]; }
void clear() { m_namemap.clear(); m_names.clear(); }
const V3LangCode numberToLang(int filenameno) const { return m_languages[filenameno]; }
void numberToLang(int filenameno, const V3LangCode l) { m_languages[filenameno] = l; }
void clear() { m_namemap.clear(); m_names.clear(); m_languages.clear(); }
void fileNameNumMapDumpXml(ostream& os);
static const string filenameLetters(int fileno);
};
//! File and line number of an object, mostly for error reporting
//! This class is instantiated for every source code line (potentially
//! millions). To save space, per-file information (e.g. filename, source
//! language is held in tables in the FileLineSingleton class.
class FileLine {
// File and line number of an object, mostly for error reporting
int m_lineno;
int m_filenameno;
bitset<V3ErrorCode::_ENUM_MAX> m_warnOn;
// Consider moving opt.language() into here, so can know language per-node
private:
struct EmptySecret {};
@ -315,6 +328,7 @@ protected:
friend class V3PreLex;
friend class V3PreProcImp;
void lineno(int num) { m_lineno = num; }
void language (V3LangCode lang) { singleton().numberToLang(m_filenameno, lang); }
void filename(const string& name) { m_filenameno = singleton().nameToNumber(name); }
void lineDirective(const char* textp, int& enterExitRef);
void linenoInc() { m_lineno++; }
@ -337,6 +351,8 @@ public:
#endif
int lineno () const { return m_lineno; }
V3LangCode language () const { return singleton().numberToLang(m_filenameno); }
void updateLanguage ();
string ascii() const;
const string filename () const { return singleton().numberToName(m_filenameno); }
const string filenameLetters() const { return singleton().filenameLetters(m_filenameno); }

72
src/V3LangCode.h Normal file
View File

@ -0,0 +1,72 @@
// -*- mode: C++; c-file-style: "cc-mode" -*-
//*************************************************************************
// DESCRIPTION: Verilator: Language code class
//
// Code available from: http://www.veripool.org/verilator
//
//*************************************************************************
//
// Copyright 2003-2012 by Wilson Snyder. This program is free software; you can
// redistribute it and/or modify it under the terms of either the GNU
// Lesser General Public License Version 3 or the Perl Artistic License
// Version 2.0.
//
// Verilator is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
//*************************************************************************
#ifndef _V3LANGCODE_H_
#define _V3LANGCODE_H_ 1
#include "config_build.h"
#include "verilatedos.h"
#include <string>
#include <vector>
#include <map>
#include <set>
//######################################################################
//! Class for the different languages supported.
//! A separate file, since used both in V3Options (globally) and FileLine 9per
//! file).
class V3LangCode {
public:
enum en {
L_ERROR, // Must be first.
L1364_1995,
L1364_2001,
L1364_2005,
L1800_2005,
L1800_2009,
// ***Add new elements below also***
_ENUM_END
};
const char* ascii() const {
const char* names[] = {
// These must match the `begin_keywords values.
" ERROR",
"1364-1995",
"1364-2001",
"1364-2005",
"1800-2005",
"1800-2009"
};
return names[m_e];
};
static V3LangCode mostRecent() { return V3LangCode(L1800_2009); }
bool legal() const { return m_e != L_ERROR; }
//
enum en m_e;
inline V3LangCode () : m_e(L_ERROR) {}
inline V3LangCode (en _e) : m_e(_e) {}
V3LangCode (const char* textp);
explicit inline V3LangCode (int _e) : m_e(static_cast<en>(_e)) {}
operator en () const { return m_e; }
};
//######################################################################
#endif // guard

View File

@ -55,6 +55,7 @@ struct V3OptionsImp {
set<string> m_incDirUserSet; // Include directories (for removing duplicates)
list<string> m_incDirFallbacks; // Include directories (ordered)
set<string> m_incDirFallbackSet; // Include directories (for removing duplicates)
map<string,V3LangCode> m_langExts; // Language extension map
list<string> m_libExtVs; // Library extensions (ordered)
set<string> m_libExtVSet; // Library extensions (for removing duplicates)
DirMap m_dirMap; // Directory listing
@ -76,6 +77,12 @@ struct V3OptionsImp {
}
}
}
void addLangExt(const string &langext, const V3LangCode lc) {
// New language extension replaces any pre-existing one.
(void)m_langExts.erase(langext);
m_langExts[langext] = lc;
}
void addLibExtV(const string& libext) {
if (m_libExtVSet.find(libext) == m_libExtVSet.end()) {
m_libExtVSet.insert(libext);
@ -91,6 +98,9 @@ void V3Options::addIncDirUser(const string& incdir) {
void V3Options::addIncDirFallback(const string& incdir) {
m_impp->addIncDirFallback(incdir);
}
void V3Options::addLangExt(const string &langext, const V3LangCode lc) {
m_impp->addLangExt(langext, lc);
}
void V3Options::addLibExtV(const string& libext) {
m_impp->addLibExtV(libext);
}
@ -158,7 +168,7 @@ string V3Options::allArgsString() {
}
//######################################################################
// Language class
// V3LangCode class functions
V3LangCode::V3LangCode (const char* textp) {
// Return code for given string, or ERROR, which is a bad code
@ -365,6 +375,24 @@ void V3Options::filePathLookedMsg(FileLine* fl, const string& modname) {
}
}
//! Determine what language is associated with a filename
//! If we recognize the extension, use its language, otherwise, use the
//! default language.
V3LangCode V3Options::fileLanguage(const string &filename) {
string ext = filenameNonDir(filename);
string::size_type pos;
if ((pos = ext.rfind(".")) != string::npos) {
ext.erase(0, pos + 1);
map<string,V3LangCode>::iterator it = m_impp->m_langExts.find(ext);
if (it != m_impp->m_langExts.end()) {
return it->second;
}
}
return m_defaultLanguage;
}
void V3Options::unlinkRegexp(const string& dir, const string& regexp) {
if (DIR* dirp = opendir(dir.c_str())) {
while (struct dirent* direntp = readdir(dirp)) {
@ -633,6 +661,17 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
else if ( !strncmp (sw, "+incdir+", 8)) {
addIncDirUser (parseFileArg(optdir, string (sw+strlen("+incdir+"))));
}
else if (parseLangExt(sw, "+systemverilogext+", V3LangCode::L1800_2009)
|| parseLangExt(sw, "+verilog1995ext+", V3LangCode::L1364_1995)
|| parseLangExt(sw, "+verilog2001ext+", V3LangCode::L1364_2001)
|| parseLangExt(sw, "+1364-1995ext+", V3LangCode::L1364_1995)
|| parseLangExt(sw, "+1364-2001ext+", V3LangCode::L1364_2001)
|| parseLangExt(sw, "+1364-2005ext+", V3LangCode::L1364_2005)
|| parseLangExt(sw, "+1800-2005ext+", V3LangCode::L1800_2005)
|| parseLangExt(sw, "+1800-2009ext+", V3LangCode::L1800_2009)) {
// Nothing to do here - all done in the test
}
else if ( !strncmp (sw, "+libext+", 8)) {
string exts = string(sw+strlen("+libext+"));
string::size_type pos;
@ -695,7 +734,7 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
else if ( onoff (sw, "-skip-identical", flag/*ref*/) ) { m_skipIdentical = flag; }
else if ( !strcmp (sw, "-sp") ) { m_outFormatOk = true; m_systemC = true; m_systemPerl = true; }
else if ( onoff (sw, "-stats", flag/*ref*/) ) { m_stats = flag; }
else if ( !strcmp (sw, "-sv") ) { m_language = V3LangCode::L1800_2005; }
else if ( !strcmp (sw, "-sv") ) { m_defaultLanguage = V3LangCode::L1800_2005; }
else if ( onoff (sw, "-trace", flag/*ref*/) ) { m_trace = flag; }
else if ( onoff (sw, "-trace-dups", flag/*ref*/) ) { m_traceDups = flag; }
else if ( onoff (sw, "-trace-underscore", flag/*ref*/) ) { m_traceUnderscore = flag; }
@ -779,11 +818,12 @@ void V3Options::parseOptsList(FileLine* fl, const string& optdir, int argc, char
shift;
addLdLibs(argv[i]);
}
else if ( !strcmp (sw, "-language") && (i+1)<argc ) {
else if ( (!strcmp (sw, "-language") && (i+1)<argc)
|| (!strcmp (sw, "-default-language") && (i+1)<argc)) {
shift;
V3LangCode optval = V3LangCode(argv[i]);
if (optval.legal()) {
m_language = optval;
m_defaultLanguage = optval;
} else {
fl->v3fatal("Unknown language specified: "<<argv[i]);
}
@ -1074,6 +1114,21 @@ string V3Options::parseFileArg(const string& optdir, const string& relfilename)
//======================================================================
//! Utility to see if we have a language extension argument and if so add it.
bool V3Options::parseLangExt (const char* swp, //!< argument text
const char* langswp, //!< option to match
const V3LangCode lc) { //!< language code
int len = strlen(langswp);
if (!strncmp(swp, langswp, len)) {
addLangExt(swp + len, lc);
return true;
} else {
return false;
}
}
//======================================================================
void V3Options::showVersion(bool verbose) {
cout <<version();
cout <<endl;
@ -1171,7 +1226,7 @@ V3Options::V3Options() {
m_unusedRegexp = "*unused*";
m_xAssign = "fast";
m_language = V3LangCode::mostRecent();
m_defaultLanguage = V3LangCode::mostRecent();
optimize(true);
// Default +libext+

View File

@ -29,43 +29,7 @@
#include <set>
#include "V3Global.h"
//######################################################################
class V3LangCode {
public:
enum en {
L_ERROR, // Must be first.
L1364_1995,
L1364_2001,
L1364_2005,
L1800_2005,
L1800_2009,
// ***Add new elements below also***
_ENUM_END
};
const char* ascii() const {
const char* names[] = {
// These must match the `begin_keywords values.
" ERROR",
"1364-1995",
"1364-2001",
"1364-2005",
"1800-2005",
"1800-2009"
};
return names[m_e];
};
static V3LangCode mostRecent() { return V3LangCode(L1800_2009); }
bool legal() const { return m_e != L_ERROR; }
//
enum en m_e;
inline V3LangCode () : m_e(L_ERROR) {}
inline V3LangCode (en _e) : m_e(_e) {}
V3LangCode (const char* textp); // Return matching code or ERROR
explicit inline V3LangCode (int _e) : m_e(static_cast<en>(_e)) {}
operator en () const { return m_e; }
};
#include "V3LangCode.h"
//######################################################################
// V3Options - Command line options
@ -156,8 +120,9 @@ class V3Options {
string m_unusedRegexp; // main switch: --unused-regexp
string m_xAssign; // main switch: --x-assign
// Consider moving m_language into FileLine, so can know language per-node
V3LangCode m_language; // main switch: --language
// Language is now held in FileLine, on a per-node basis. However we still
// have a concept of the default language at a global level.
V3LangCode m_defaultLanguage; // main switch: --language
// MEMBERS (optimizations)
// // main switch: -Op: --public
@ -185,6 +150,7 @@ class V3Options {
void addFuture(const string& flag);
void addIncDirUser(const string& incdir); // User requested
void addIncDirFallback(const string& incdir); // Low priority if not found otherwise
void addLangExt(const string &langext, const V3LangCode lc);
void addLibExtV(const string& libext);
void optimize(int level);
void showVersion(bool verbose);
@ -192,6 +158,7 @@ class V3Options {
bool onoff(const char* sw, const char* arg, bool& flag);
bool suffixed(const char* sw, const char* arg);
string parseFileArg(const string& optdir, const string& relfilename);
bool parseLangExt(const char* swp, const char* langswp, const V3LangCode lc);
string filePathCheckOneDir(const string& modname, const string& dirname);
static string getenvStr(const string& envvar, const string& defaultValue);
@ -288,7 +255,7 @@ class V3Options {
const V3StringSet& ldLibs() const { return m_ldLibs; }
const V3StringSet& libraryFiles() const { return m_libraryFiles; }
const V3StringList& vFiles() const { return m_vFiles; }
const V3LangCode& language() const { return m_language; }
const V3LangCode& defaultLanguage() const { return m_defaultLanguage; }
bool isFuture(const string& flag) const;
bool isLibraryFile(const string& filename) const;
@ -351,6 +318,7 @@ class V3Options {
string fileExists (const string& filename);
string filePath (FileLine* fl, const string& modname, const string& errmsg);
void filePathLookedMsg(FileLine* fl, const string& modname);
V3LangCode fileLanguage(const string &filename);
static bool fileStatDir (const string& filename);
static bool fileStatNormal (const string& filename);

View File

@ -100,8 +100,12 @@ void V3ParseImp::parseFile(FileLine* fileline, const string& modfilename, bool i
// Set language standard up front
if (!v3Global.opt.preprocOnly()) {
// Leting lex parse this saves us from having to specially en/decode
// from the V3LangCode to the various Lex BEGIN states.
ppPushText((string)"`begin_keywords \""+v3Global.opt.language().ascii()+"\"\n");
// from the V3LangCode to the various Lex BEGIN states. The language
// of this source file is updated here, in case there have been any
// intervening +<lang>ext+ options since it was first ecountered.
FileLine *modfileline = new FileLine (modfilename, 0);
modfileline->updateLanguage();
ppPushText((string)"`begin_keywords \""+modfileline->language().ascii()+"\"\n");
}
// Preprocess into m_ppBuffer

16
test_regress/t/t_langext_1.pl Executable file
View File

@ -0,0 +1,16 @@
#!/usr/bin/perl
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2003 by Wilson Snyder. This program is free software; you can
# redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
# This is a compile only test.
compile (
v_flags2 => ["+verilog2001ext+v"],
);
ok(1);
1;

View File

@ -0,0 +1,51 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// A test of the +verilog1995ext+ and +verilog2001ext+ flags.
//
// This source code contains constructs that are valid in Verilog 2001 and
// SystemVerilog 2005/2009, but not in Verilog 1995. So it should fail if we
// set the language to be 1995, but not 2001.
//
// Compile only test, so no need for "All Finished" output.
//
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2012 by Jeremy Bennett.
module t (/*AUTOARG*/
// Inputs
clk
);
input clk;
reg [1:0] res;
// Instantiate the test
test test_i (/*AUTOINST*/
// Outputs
.res (res),
// Inputs
.clk (clk),
.in (1'b1));
endmodule
module test (// Outputs
res,
// Inputs
clk,
in
);
output [1:0] res;
input clk;
input in;
// This is a Verilog 2001 test
generate
genvar i;
for (i=0; i<2; i=i+1) begin
always @(posedge clk) begin
res[i:i] <= in;
end
end
endgenerate
endmodule

View File

@ -0,0 +1,19 @@
#!/usr/bin/perl
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2003 by Wilson Snyder. This program is free software; you can
# redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
top_filename("t/t_langext_1.v");
# This is a compile only test.
compile (
v_flags2 => ["+verilog1995ext+v"],
fails => 1
);
ok(1);
1;

16
test_regress/t/t_langext_2.pl Executable file
View File

@ -0,0 +1,16 @@
#!/usr/bin/perl
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2003 by Wilson Snyder. This program is free software; you can
# redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
# This is a compile only test.
compile (
v_flags2 => ["+systemverilogext+v"],
);
ok(1);
1;

View File

@ -0,0 +1,55 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// A test of the +1364-1995ext+ and +systemverilogext+ flags.
//
// This source code contains constructs that are valid in SystemVerilog 2009
// but not in Verilog 1995. So it should fail if we set the language to be
// Verilog 1995, but not SystemVerilog 2009.
//
// Compile only test, so no need for "All Finished" output.
//
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2012 by Jeremy Bennett.
module t (/*AUTOARG*/
// Inputs
clk
);
input clk;
reg [1:0] res;
// Instantiate the test
test test_i (/*AUTOINST*/
// Outputs
.res (res),
// Inputs
.clk (clk),
.in (1'b1));
endmodule
module test (// Outputs
res,
// Inputs
clk,
in
);
output [1:0] res;
input clk;
input in;
// This is a SystemVerilog 2009 only test
generate
genvar i;
for (i=0; i<2; i=i+1) begin
always @(posedge clk) begin
unique0 case (i)
0: res[0:0] <= in;
1: res[1:1] <= in;
endcase
end
end
endgenerate
endmodule

View File

@ -0,0 +1,19 @@
#!/usr/bin/perl
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2003 by Wilson Snyder. This program is free software; you can
# redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
top_filename("t/t_langext_2.v");
# This is a compile only test.
compile (
v_flags2 => ["+1364-1995ext+v"],
fails => 1
);
ok(1);
1;

16
test_regress/t/t_langext_3.pl Executable file
View File

@ -0,0 +1,16 @@
#!/usr/bin/perl
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2003 by Wilson Snyder. This program is free software; you can
# redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
# This is a compile only test.
compile (
v_flags2 => ["+1364-2005ext+v"],
);
ok(1);
1;

View File

@ -0,0 +1,21 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// A test of the +verilog2001ext+ and +verilog2005ext+ flags.
//
// This source code uses the uwire declaration, which is only valid in Verilog
// 2005.
//
// Compile only test, so no need for "All Finished" output.
//
// This file ONLY is placed into the Public Domain, for any use,
// without warranty, 2012 by Jeremy Bennett.
module t (/*AUTOARG*/
// Inputs
clk
);
input clk;
uwire w; // Only in Verilog 2005
endmodule

View File

@ -0,0 +1,19 @@
#!/usr/bin/perl
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2003 by Wilson Snyder. This program is free software; you can
# redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
top_filename("t/t_langext_3.v");
# This is a compile only test.
compile (
v_flags2 => ["+1364-2001ext+v"],
fails => 1
);
ok(1);
1;

18
test_regress/t/t_langext_4.pl Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/perl
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2003 by Wilson Snyder. This program is free software; you can
# redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
top_filename("t/t_langext_2.v");
# This is a compile only test.
compile (
v_flags2 => ["+1800-2009ext+v"],
);
ok(1);
1;

View File

@ -0,0 +1,19 @@
#!/usr/bin/perl
if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; }
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2003 by Wilson Snyder. This program is free software; you can
# redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
top_filename("t/t_langext_2.v");
# This is a compile only test.
compile (
v_flags2 => ["+1800-2005ext+v"],
fails => 1
);
ok(1);
1;