Add -g option to only enable supported assertion statements.

This commit is contained in:
Martin Whitaker 2019-10-05 13:37:03 +01:00
parent 455702810e
commit 05641f386f
5 changed files with 58 additions and 34 deletions

View File

@ -1,7 +1,7 @@
#ifndef IVL_compiler_H
#define IVL_compiler_H
/*
* Copyright (c) 1999-2017 Stephen Williams (steve@icarus.com)
* Copyright (c) 1999-2019 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -177,9 +177,12 @@ extern bool gn_icarus_misc_flag;
is false, then skip elaboration of specify behavior. */
extern bool gn_specify_blocks_flag;
/* If this flag is true, then elaborate assertions. If this flag is
false, then stub out assertion statements. */
extern bool gn_assertions_flag;
/* If this flag is true, then elaborate supported assertion statements. If
this flag is false, then stub out supported assertion statements. */
extern bool gn_supported_assertions_flag;
/* If this flag is true, then error on unsupported assertion statements. If
this flag is false, then stub out unsupported assertion statements. */
extern bool gn_unsupported_assertions_flag;
/* If this flag is true, then support/elaborate Verilog-AMS. */
extern bool gn_verilog_ams_flag;

View File

@ -1,4 +1,4 @@
.TH iverilog 1 "Sep 20th, 2019" "" "Version %M.%n%E"
.TH iverilog 1 "Oct 5th, 2019" "" "Version %M.%n%E"
.SH NAME
iverilog - Icarus Verilog compiler
@ -80,10 +80,11 @@ use any of the new \fIIEEE1800\fP keywords.
Enable or disable (default) support for Verilog\-AMS.
Very little Verilog\-AMS specific functionality is currently supported.
.TP 8
.B -gassertions\fI|\fP-gno-assertions
.B -gassertions\fI|\fP-gsupported-assertions\fI|\fP-gno-assertions
Enable (default) or disable SystemVerilog assertions. When enabled,
assertion statements are elaborated. When disabled, assertion statements
are parsed but ignored.
are parsed but ignored. The \fB\-gsupported-assertions\fP option only
enables assertions that are currently supported by the compiler.
.TP 8
.B -gspecify\fI|\fP-gno-specify
Enable or disable (default) specify block support. When enabled,

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000-2017 Stephen Williams (steve@icarus.com)
* Copyright (c) 2000-2019 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@ -748,6 +748,9 @@ static int process_generation(const char*name)
else if (strcmp(name,"assertions") == 0)
gen_assertions = "assertions";
else if (strcmp(name,"supported-assertions") == 0)
gen_assertions = "supported-assertions";
else if (strcmp(name,"no-assertions") == 0)
gen_assertions = "no-assertions";
@ -804,6 +807,7 @@ static int process_generation(const char*name)
" 2009 -- IEEE1800-2009\n"
" 2012 -- IEEE1800-2012\n"
"Other generation flags:\n"
" assertions | supported-assertions | no-assertions\n"
" specify | no-specify\n"
" verilog-ams | no-verilog-ams\n"
" std-include | no-std-include\n"
@ -1176,7 +1180,7 @@ int main(int argc, char **argv)
if (version_flag || verbose_flag) {
printf("Icarus Verilog version " VERSION " (" VERSION_TAG ")\n\n");
printf("Copyright 1998-2017 Stephen Williams\n\n");
printf("Copyright 1998-2019 Stephen Williams\n\n");
puts(NOTICE);
}

15
main.cc
View File

@ -1,5 +1,5 @@
const char COPYRIGHT[] =
"Copyright (c) 1998-2017 Stephen Williams (steve@icarus.com)";
"Copyright (c) 1998-2019 Stephen Williams (steve@icarus.com)";
/*
* This source code is free software; you can redistribute it
@ -104,7 +104,8 @@ generation_t generation_flag = GN_DEFAULT;
bool gn_icarus_misc_flag = true;
bool gn_cadence_types_flag = true;
bool gn_specify_blocks_flag = true;
bool gn_assertions_flag = true;
bool gn_supported_assertions_flag = true;
bool gn_unsupported_assertions_flag = true;
bool gn_io_range_error_flag = true;
bool gn_strict_ca_eval_flag = false;
bool gn_strict_expr_width_flag = false;
@ -331,10 +332,16 @@ static void process_generation_flag(const char*gen)
gn_specify_blocks_flag = false;
} else if (strcmp(gen,"assertions") == 0) {
gn_assertions_flag = true;
gn_supported_assertions_flag = true;
gn_unsupported_assertions_flag = true;
} else if (strcmp(gen,"supported-assertions") == 0) {
gn_supported_assertions_flag = true;
gn_unsupported_assertions_flag = false;
} else if (strcmp(gen,"no-assertions") == 0) {
gn_assertions_flag = false;
gn_supported_assertions_flag = false;
gn_unsupported_assertions_flag = false;
} else if (strcmp(gen,"verilog-ams") == 0) {
gn_verilog_ams_flag = true;

51
parse.y
View File

@ -1005,33 +1005,37 @@ concurrent_assertion_item /* IEEE1800-2012 A.2.10 */
concurrent_assertion_statement /* IEEE1800-2012 A.2.10 */
: assert_or_assume K_property '(' property_spec ')' statement_or_null %prec less_than_K_else
{ /* */
if (gn_assertions_flag) {
if (gn_unsupported_assertions_flag) {
yyerror(@1, "sorry: concurrent_assertion_item not supported."
" Try -gno-assertion to turn this message off.");
" Try -gno-assertions or -gsupported-assertions"
" to turn this message off.");
}
$$ = 0;
}
| assert_or_assume K_property '(' property_spec ')' K_else statement_or_null
{ /* */
if (gn_assertions_flag) {
if (gn_unsupported_assertions_flag) {
yyerror(@1, "sorry: concurrent_assertion_item not supported."
" Try -gno-assertion to turn this message off.");
" Try -gno-assertions or -gsupported-assertions"
" to turn this message off.");
}
$$ = 0;
}
| assert_or_assume K_property '(' property_spec ')' statement_or_null K_else statement_or_null
{ /* */
if (gn_assertions_flag) {
if (gn_unsupported_assertions_flag) {
yyerror(@1, "sorry: concurrent_assertion_item not supported."
" Try -gno-assertion to turn this message off.");
" Try -gno-assertions or -gsupported-assertions"
" to turn this message off.");
}
$$ = 0;
}
| K_cover K_property '(' property_spec ')' statement_or_null
{ /* */
if (gn_assertions_flag) {
if (gn_unsupported_assertions_flag) {
yyerror(@1, "sorry: concurrent_assertion_item not supported."
" Try -gno-assertion to turn this message off.");
" Try -gno-assertions or -gsupported-assertions"
" to turn this message off.");
}
$$ = 0;
}
@ -1039,17 +1043,19 @@ concurrent_assertion_statement /* IEEE1800-2012 A.2.10 */
They are syntactically identical. */
| K_cover K_sequence '(' property_spec ')' statement_or_null
{ /* */
if (gn_assertions_flag) {
if (gn_unsupported_assertions_flag) {
yyerror(@1, "sorry: concurrent_assertion_item not supported."
" Try -gno-assertion to turn this message off.");
" Try -gno-assertions or -gsupported-assertions"
" to turn this message off.");
}
$$ = 0;
}
| K_restrict K_property '(' property_spec ')' ';'
{ /* */
if (gn_assertions_flag) {
if (gn_unsupported_assertions_flag) {
yyerror(@2, "sorry: concurrent_assertion_item not supported."
" Try -gno-assertion to turn this message off.");
" Try -gno-assertions or -gsupported-assertions"
" to turn this message off.");
}
$$ = 0;
}
@ -1261,9 +1267,10 @@ deferred_immediate_assertion_item /* IEEE1800-2012: A.6.10 */
deferred_immediate_assertion_statement /* IEEE1800-2012 A.6.10 */
: assert_or_assume deferred_mode '(' expression ')' statement_or_null %prec less_than_K_else
{
if (gn_assertions_flag) {
if (gn_unsupported_assertions_flag) {
yyerror(@1, "sorry: Deferred assertions are not supported."
" Try -gno-assertion to turn this message off.");
" Try -gno-assertions or -gsupported-assertions"
" to turn this message off.");
}
delete $4;
delete $6;
@ -1271,9 +1278,10 @@ deferred_immediate_assertion_statement /* IEEE1800-2012 A.6.10 */
}
| assert_or_assume deferred_mode '(' expression ')' K_else statement_or_null
{
if (gn_assertions_flag) {
if (gn_unsupported_assertions_flag) {
yyerror(@1, "sorry: Deferred assertions are not supported."
" Try -gno-assertion to turn this message off.");
" Try -gno-assertions or -gsupported-assertions"
" to turn this message off.");
}
delete $4;
delete $7;
@ -1281,9 +1289,10 @@ deferred_immediate_assertion_statement /* IEEE1800-2012 A.6.10 */
}
| assert_or_assume deferred_mode '(' expression ')' statement_or_null K_else statement_or_null
{
if (gn_assertions_flag) {
if (gn_unsupported_assertions_flag) {
yyerror(@1, "sorry: Deferred assertions are not supported."
" Try -gno-assertion to turn this message off.");
" Try -gno-assertions or -gsupported-assertions"
" to turn this message off.");
}
delete $4;
delete $6;
@ -2071,7 +2080,7 @@ signing /* IEEE1800-2005: A.2.2.1 */
simple_immediate_assertion_statement /* IEEE1800-2012 A.6.10 */
: assert_or_assume '(' expression ')' statement_or_null %prec less_than_K_else
{
if (gn_assertions_flag) {
if (gn_supported_assertions_flag) {
list<PExpr*>arg_list;
PCallTask*tmp1 = new PCallTask(lex_strings.make("$error"), arg_list);
FILE_NAME(tmp1, @1);
@ -2086,7 +2095,7 @@ simple_immediate_assertion_statement /* IEEE1800-2012 A.6.10 */
}
| assert_or_assume '(' expression ')' K_else statement_or_null
{
if (gn_assertions_flag) {
if (gn_supported_assertions_flag) {
PCondit*tmp = new PCondit($3, 0, $6);
FILE_NAME(tmp, @1);
$$ = tmp;
@ -2098,7 +2107,7 @@ simple_immediate_assertion_statement /* IEEE1800-2012 A.6.10 */
}
| assert_or_assume '(' expression ')' statement_or_null K_else statement_or_null
{
if (gn_assertions_flag) {
if (gn_supported_assertions_flag) {
PCondit*tmp = new PCondit($3, $5, $7);
FILE_NAME(tmp, @1);
$$ = tmp;