Add option -gno-strict-parameter-declaration
The standards requires that parameters must be declared before they are used. Using -gno-strict-parameter-declaration will allow using a parameter before declaration, e.g., in a port declaration, with the parameter declared in the body of the module. Prior to version 13 this was allowed, so there is a large body of existing code depending on the pre version 13 behaviour.
This commit is contained in:
parent
ff2f4c6864
commit
ab74cafa20
|
|
@ -131,6 +131,14 @@ These flags affect the general behavior of the compiler.
|
|||
containing an unsized constant number, and unsized constant numbers are
|
||||
not truncated to integer width.
|
||||
|
||||
* strict-parameter-declaration/no-strict-parameter-declaration
|
||||
|
||||
The standards requires that parameters must be declared lexically
|
||||
before they are used. Using -gno-strict-parameter-declaration
|
||||
will allow using a parameter before declaration, e.g., in a port
|
||||
declaration, with the parameter declared in the body of the
|
||||
module.
|
||||
|
||||
* shared-loop-index/no-shared-loop-index
|
||||
|
||||
Enable or disable the exclusion of for-loop control variables from
|
||||
|
|
|
|||
|
|
@ -210,6 +210,12 @@ extern bool gn_strict_expr_width_flag;
|
|||
loop. */
|
||||
extern bool gn_shared_loop_index_flag;
|
||||
|
||||
/* If this flag is true (default), then parameters must be declared before
|
||||
use.
|
||||
use `-gno-strict-parameter-declaration` for pre version 13 behaviour.
|
||||
*/
|
||||
extern bool gn_strict_parameter_declaration;
|
||||
|
||||
static inline bool gn_system_verilog(void)
|
||||
{
|
||||
if (generation_flag >= GN_VER2005_SV)
|
||||
|
|
|
|||
|
|
@ -150,6 +150,12 @@ parameter assignment is evaluated as a lossless expression, as is any
|
|||
expression containing an unsized constant number, and unsized constant
|
||||
numbers are not truncated to integer width.
|
||||
.TP 8
|
||||
.B -gstrict-parameter-declaration\fI|\fP-gno-strict-parameter-declaration
|
||||
The standards requires that parameters must be declared lexically
|
||||
before they are used. Using \fB\-gno\-strict\-parameter\-declaration\fP
|
||||
will allow using a parameter before declaration, e.g., in a port
|
||||
declaration, with the parameter declared in the body of the module.
|
||||
.TP 8
|
||||
.B -gshared-loop-index\fI|\fP-gno-shared-loop-index
|
||||
Enable (default) or disable the exclusion of for-loop control variables
|
||||
from implicit event_expression lists. When enabled, if a for-loop control
|
||||
|
|
|
|||
|
|
@ -134,6 +134,7 @@ const char*gen_strict_ca_eval = "no-strict-ca-eval";
|
|||
const char*gen_strict_expr_width = "no-strict-expr-width";
|
||||
const char*gen_shared_loop_index = "shared-loop-index";
|
||||
const char*gen_verilog_ams = "no-verilog-ams";
|
||||
const char*gen_strict_parameter_declaration = "strict-parameter-declaration";
|
||||
|
||||
/* Boolean: true means use a default include dir, false means don't */
|
||||
int gen_std_include = 1;
|
||||
|
|
@ -815,6 +816,12 @@ static int process_generation(const char*name)
|
|||
else if (strcmp(name,"no-verilog-ams") == 0)
|
||||
gen_verilog_ams = "no-verilog-ams";
|
||||
|
||||
else if (strcmp(name,"strict-parameter-declaration") == 0)
|
||||
gen_strict_parameter_declaration = "strict-parameter-declaration";
|
||||
|
||||
else if (strcmp(name,"no-strict-parameter-declaration") == 0)
|
||||
gen_strict_parameter_declaration = "no-strict-parameter-declaration";
|
||||
|
||||
else {
|
||||
fprintf(stderr, "Unknown/Unsupported Language generation "
|
||||
"%s\n\n", name);
|
||||
|
|
@ -837,7 +844,8 @@ static int process_generation(const char*name)
|
|||
" io-range-error | no-io-range-error\n"
|
||||
" strict-ca-eval | no-strict-ca-eval\n"
|
||||
" strict-expr-width | no-strict-expr-width\n"
|
||||
" shared-loop-index | no-shared-loop-index\n");
|
||||
" shared-loop-index | no-shared-loop-index\n"
|
||||
" strict-parameter-declaration | no-strict-parameter-declaration\n");
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
|
@ -1385,6 +1393,7 @@ int main(int argc, char **argv)
|
|||
fprintf(iconfig_file, "generation:%s\n", gen_strict_expr_width);
|
||||
fprintf(iconfig_file, "generation:%s\n", gen_shared_loop_index);
|
||||
fprintf(iconfig_file, "generation:%s\n", gen_verilog_ams);
|
||||
fprintf(iconfig_file, "generation:%s\n", gen_strict_parameter_declaration);
|
||||
fprintf(iconfig_file, "generation:%s\n", gen_icarus);
|
||||
fprintf(iconfig_file, "warnings:%s\n", warning_flags);
|
||||
fprintf(iconfig_file, "ignore_missing_modules:%s\n", ignore_missing_modules ? "true" : "false");
|
||||
|
|
|
|||
7
main.cc
7
main.cc
|
|
@ -117,6 +117,7 @@ bool gn_strict_ca_eval_flag = false;
|
|||
bool gn_strict_expr_width_flag = false;
|
||||
bool gn_shared_loop_index_flag = true;
|
||||
bool gn_verilog_ams_flag = false;
|
||||
bool gn_strict_parameter_declaration = true;
|
||||
|
||||
/*
|
||||
* For some generations we allow a system function to be called
|
||||
|
|
@ -386,6 +387,12 @@ static void process_generation_flag(const char*gen)
|
|||
} else if (strcmp(gen,"no-shared-loop-index") == 0) {
|
||||
gn_shared_loop_index_flag = false;
|
||||
|
||||
} else if (strcmp(gen,"strict-parameter-declaration") == 0) {
|
||||
gn_strict_parameter_declaration = true;
|
||||
|
||||
} else if (strcmp(gen,"no-strict-parameter-declaration") == 0) {
|
||||
gn_strict_parameter_declaration = false;
|
||||
|
||||
} else {
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -189,7 +189,8 @@ bool symbol_search(const LineInfo*li, Design*des, NetScope*scope,
|
|||
}
|
||||
|
||||
if (const NetExpr*par = scope->get_parameter(des, path_tail.name, res->type)) {
|
||||
if (prefix_scope || (scope->get_parameter_lexical_pos(path_tail.name) <= lexical_pos)) {
|
||||
if (!gn_strict_parameter_declaration || prefix_scope
|
||||
|| (scope->get_parameter_lexical_pos(path_tail.name) <= lexical_pos)) {
|
||||
path.push_back(path_tail);
|
||||
res->scope = scope;
|
||||
res->par_val = par;
|
||||
|
|
|
|||
Loading…
Reference in New Issue