Enable variable declarations/initialisations in the compilation unit scope.
This commit is contained in:
parent
0f95770418
commit
caf83b02c1
|
|
@ -5684,6 +5684,10 @@ bool PPackage::elaborate(Design*des, NetScope*scope) const
|
|||
// Elaborate class definitions.
|
||||
elaborate_classes(des, scope, classes);
|
||||
|
||||
// Elaborate the variable initialization statements, making a
|
||||
// single initial process out of them.
|
||||
result_flag &= elaborate_var_inits_(des, scope);
|
||||
|
||||
return result_flag;
|
||||
}
|
||||
|
||||
|
|
|
|||
21
pform.cc
21
pform.cc
|
|
@ -2682,7 +2682,8 @@ void pform_makewire(const vlltype&li,
|
|||
* net_decl_assign_t argument.
|
||||
*/
|
||||
void pform_makewire(const struct vlltype&li,
|
||||
std::list<PExpr*>*, str_pair_t ,
|
||||
std::list<PExpr*>*delay,
|
||||
str_pair_t str,
|
||||
std::list<decl_assignment_t*>*assign_list,
|
||||
NetNet::Type type,
|
||||
data_type_t*data_type)
|
||||
|
|
@ -2691,10 +2692,6 @@ void pform_makewire(const struct vlltype&li,
|
|||
VLerror(li, "error: variable declarations must be contained within a module.");
|
||||
return;
|
||||
}
|
||||
if (is_compilation_unit(lexical_scope)) {
|
||||
VLerror(li, "sorry: variable declarations in the $root scope are not yet supported.");
|
||||
return;
|
||||
}
|
||||
|
||||
list<perm_string>*names = new list<perm_string>;
|
||||
|
||||
|
|
@ -2709,8 +2706,18 @@ void pform_makewire(const struct vlltype&li,
|
|||
while (! assign_list->empty()) {
|
||||
decl_assignment_t*first = assign_list->front();
|
||||
assign_list->pop_front();
|
||||
// For now, do not handle assignment expressions.
|
||||
assert(! first->expr.get());
|
||||
if (PExpr*expr = first->expr.release()) {
|
||||
if (type == NetNet::REG || type == NetNet::IMPLICIT_REG) {
|
||||
pform_make_var_init(li, first->name, expr);
|
||||
} else {
|
||||
PWire*cur = pform_get_wire_in_scope(first->name);
|
||||
assert(cur);
|
||||
PEIdent*lval = new PEIdent(first->name);
|
||||
FILE_NAME(lval, li.text, li.first_line);
|
||||
PGAssign*ass = pform_make_pgassign(lval, expr, delay, str);
|
||||
FILE_NAME(ass, li.text, li.first_line);
|
||||
}
|
||||
}
|
||||
delete first;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1720,8 +1720,10 @@ void PPackage::pform_dump(std::ostream&out) const
|
|||
dump_localparams_(out, 4);
|
||||
dump_parameters_(out, 4);
|
||||
dump_enumerations_(out, 4);
|
||||
dump_wires_(out, 4);
|
||||
dump_tasks_(out, 4);
|
||||
dump_funcs_(out, 4);
|
||||
dump_var_inits_(out, 4);
|
||||
out << "endpackage" << endl;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue