diff --git a/vhdlpp/subprogram.h b/vhdlpp/subprogram.h index 82ba804d1..7b4bcceee 100644 --- a/vhdlpp/subprogram.h +++ b/vhdlpp/subprogram.h @@ -49,7 +49,7 @@ class SubprogramBody : public LineInfo, public ScopeBase { int emit(ostream&out, Entity*ent, ScopeBase*scope); // Emit body as it would show up in a package. - int emit_package(std::ostream&fd) const; + int emit_package(std::ostream&fd); void write_to_stream(std::ostream&fd) const; void dump(std::ostream&fd) const; diff --git a/vhdlpp/subprogram_emit.cc b/vhdlpp/subprogram_emit.cc index 0a38c58f2..2d9e4e533 100644 --- a/vhdlpp/subprogram_emit.cc +++ b/vhdlpp/subprogram_emit.cc @@ -26,7 +26,7 @@ using namespace std; -int SubprogramBody::emit_package(ostream&fd) const +int SubprogramBody::emit_package(ostream&fd) { int errors = 0; @@ -34,7 +34,7 @@ int SubprogramBody::emit_package(ostream&fd) const ; cur != new_variables_.end() ; ++cur) { // Enable reg_flag for variables cur->second->count_ref_sequ(); - errors += cur->second->emit(fd, NULL, NULL); + errors += cur->second->emit(fd, NULL, this, false); } // Emulate automatic functions (add explicit initial value assignments) @@ -44,7 +44,7 @@ int SubprogramBody::emit_package(ostream&fd) const if(const Expression*init = var->peek_init_expr()) { fd << cur->first << " = "; - init->emit(fd, NULL, NULL); + init->emit(fd, NULL, this); fd << "; // automatic function emulation" << endl; } } diff --git a/vhdlpp/vsignal.cc b/vhdlpp/vsignal.cc index 8576c212e..5065356e0 100644 --- a/vhdlpp/vsignal.cc +++ b/vhdlpp/vsignal.cc @@ -49,7 +49,7 @@ void SigVarBase::type_elaborate_(VType::decl_t&decl) decl.type = type_; } -int Signal::emit(ostream&out, Entity*ent, ScopeBase*scope) +int Signal::emit(ostream&out, Entity*ent, ScopeBase*scope, bool initialize) { int errors = 0; @@ -63,7 +63,7 @@ int Signal::emit(ostream&out, Entity*ent, ScopeBase*scope) errors += decl.emit(out, peek_name()); const Expression*init_expr = peek_init_expr(); - if (init_expr) { + if (initialize && init_expr) { /* Emit initialization value for wires as a weak assignment */ if(!decl.reg_flag && !type->type_match(&primitive_REAL)) out << ";" << endl << "/*init*/ assign (weak1, weak0) " << peek_name(); @@ -75,7 +75,7 @@ int Signal::emit(ostream&out, Entity*ent, ScopeBase*scope) return errors; } -int Variable::emit(ostream&out, Entity*ent, ScopeBase*scope) +int Variable::emit(ostream&out, Entity*ent, ScopeBase*scope, bool initialize) { int errors = 0; @@ -85,7 +85,7 @@ int Variable::emit(ostream&out, Entity*ent, ScopeBase*scope) errors += decl.emit(out, peek_name()); const Expression*init_expr = peek_init_expr(); - if (init_expr) { + if (initialize && init_expr) { out << " = "; init_expr->emit(out, ent, scope); } diff --git a/vhdlpp/vsignal.h b/vhdlpp/vsignal.h index e387d8954..27de1d778 100644 --- a/vhdlpp/vsignal.h +++ b/vhdlpp/vsignal.h @@ -70,7 +70,7 @@ class Signal : public SigVarBase { public: Signal(perm_string name, const VType*type, Expression*init_expr); - int emit(ostream&out, Entity*ent, ScopeBase*scope); + int emit(ostream&out, Entity*ent, ScopeBase*scope, bool initalize = true); }; class Variable : public SigVarBase { @@ -78,7 +78,7 @@ class Variable : public SigVarBase { public: Variable(perm_string name, const VType*type, Expression*init_expr = NULL); - int emit(ostream&out, Entity*ent, ScopeBase*scope); + int emit(ostream&out, Entity*ent, ScopeBase*scope, bool initialize = true); void write_to_stream(std::ostream&fd); };