Skip to content

Commit

Permalink
Elaborate block scopes burried in generate schemes.
Browse files Browse the repository at this point in the history
Named begin/end blocks burried within generate schemes need to be
elaborated. Handle this by remembering to elaborate_scope on the
statements within the generate scheme.

In the process, clean up/regularize some of the member names and
methods.
  • Loading branch information
steveicarus committed Jun 18, 2008
1 parent 05f1541 commit 15481a9
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

/* n is a permallocated string. */
Module::Module(perm_string n)
: PScope(n, 0)
: PScope(n)
{
library_flag = false;
default_nettype = NetNet::NONE;
Expand Down
5 changes: 0 additions & 5 deletions PGenerate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,3 @@ void PGenerate::add_gate(PGate*gate)
{
gates.push_back(gate);
}

void PGenerate::add_behavior(PProcess*proc)
{
behaviors.push_back(proc);
}
6 changes: 3 additions & 3 deletions PGenerate.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class PWire;
class PGenerate : public LineInfo {

public:
PGenerate(unsigned id_number);
explicit PGenerate(unsigned id_number);
~PGenerate();

// Generate schemes have an ID number, for when the scope is
Expand All @@ -78,9 +78,9 @@ class PGenerate : public LineInfo {
void add_gate(PGate*);

list<PProcess*> behaviors;
void add_behavior(PProcess*behave);

list<PGenerate*> generates;
// Generate schemes can contain further generate schemes.
list<PGenerate*> generate_schemes;
PGenerate*parent;

// This method is called by the elaboration of a module to
Expand Down
9 changes: 7 additions & 2 deletions PScope.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@

# include "PScope.h"

PScope::PScope(perm_string n, PScope*p)
: name_(n), parent_(p)
PScope::PScope(perm_string n, PScope*parent)
: name_(n), parent_(parent)
{
}

PScope::PScope(perm_string n)
: name_(n), parent_(0)
{
}

Expand Down
1 change: 1 addition & 0 deletions PScope.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class PScope {
// modules. Scopes for tasks and functions point to their
// containing module.
PScope(perm_string name, PScope*parent);
PScope(perm_string name);
virtual ~PScope();

perm_string pscope_name() const { return name_; }
Expand Down
2 changes: 1 addition & 1 deletion Statement.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ PBlock::PBlock(perm_string n, PScope*parent, BL_TYPE t)
}

PBlock::PBlock(BL_TYPE t)
: PScope(perm_string(),0), bl_type_(t)
: PScope(perm_string()), bl_type_(t)
{
}

Expand Down
16 changes: 11 additions & 5 deletions elab_scope.cc
Original file line number Diff line number Diff line change
Expand Up @@ -548,8 +548,8 @@ bool PGenerate::generate_scope_case_(Design*des, NetScope*container)
PGenerate*default_item = 0;

typedef list<PGenerate*>::const_iterator generator_it_t;
generator_it_t cur = generates.begin();
while (cur != generates.end()) {
generator_it_t cur = generate_schemes.begin();
while (cur != generate_schemes.end()) {
PGenerate*item = *cur;
assert( item->scheme_type == PGenerate::GS_CASE_ITEM );

Expand Down Expand Up @@ -578,7 +578,7 @@ bool PGenerate::generate_scope_case_(Design*des, NetScope*container)
delete case_value_co;
case_value_co = 0;

PGenerate*item = (cur == generates.end())? default_item : *cur;
PGenerate*item = (cur == generate_schemes.end())? default_item : *cur;
if (item == 0) {
cerr << get_fileline() << ": debug: "
<< "No generate items found" << endl;
Expand All @@ -605,8 +605,8 @@ void PGenerate::elaborate_subscope_(Design*des, NetScope*scope)
// from simple elaboration.

typedef list<PGenerate*>::const_iterator generate_it_t;
for (generate_it_t cur = generates.begin()
; cur != generates.end() ; cur ++ ) {
for (generate_it_t cur = generate_schemes.begin()
; cur != generate_schemes.end() ; cur ++ ) {
(*cur) -> generate_scope(des, scope);
}

Expand All @@ -618,6 +618,12 @@ void PGenerate::elaborate_subscope_(Design*des, NetScope*scope)
(*cur) ->elaborate_scope(des, scope);
}

typedef list<PProcess*>::const_iterator proc_it_t;
for (proc_it_t cur = behaviors.begin()
; cur != behaviors.end() ; cur ++ ) {
(*cur) -> statement() -> elaborate_scope(des, scope);
}

// Save the scope that we created, for future use.
scope_list_.push_back(scope);
}
Expand Down
8 changes: 4 additions & 4 deletions elab_sig.cc
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,8 @@ bool PGenerate::elaborate_sig(Design*des, NetScope*container) const
<< scope_path(container) << "." << endl;

typedef list<PGenerate*>::const_iterator generate_it_t;
for (generate_it_t cur = generates.begin()
; cur != generates.end() ; cur ++) {
for (generate_it_t cur = generate_schemes.begin()
; cur != generate_schemes.end() ; cur ++) {
PGenerate*item = *cur;
if (! item->scope_list_.empty()) {
flag &= item->elaborate_sig(des, container);
Expand Down Expand Up @@ -462,8 +462,8 @@ bool PGenerate::elaborate_sig_(Design*des, NetScope*scope) const
}

typedef list<PGenerate*>::const_iterator generate_it_t;
for (generate_it_t cur = generates.begin()
; cur != generates.end() ; cur ++ ) {
for (generate_it_t cur = generate_schemes.begin()
; cur != generate_schemes.end() ; cur ++ ) {
(*cur) -> elaborate_sig(des, scope);
}

Expand Down
10 changes: 5 additions & 5 deletions elaborate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1952,7 +1952,7 @@ NetProc* PBlock::elaborate(Design*des, NetScope*scope) const
if (nscope == 0) {
cerr << get_fileline() << ": internal error: "
"unable to find block scope " << scope_path(scope)
<< "<" << pscope_name() << ">" << endl;
<< "." << pscope_name() << endl;
des->errors += 1;
return 0;
}
Expand Down Expand Up @@ -3681,8 +3681,8 @@ bool PGenerate::elaborate(Design*des, NetScope*container) const
<< scope_path(container) << "." << endl;

typedef list<PGenerate*>::const_iterator generate_it_t;
for (generate_it_t cur = generates.begin()
; cur != generates.end() ; cur ++) {
for (generate_it_t cur = generate_schemes.begin()
; cur != generate_schemes.end() ; cur ++) {
PGenerate*item = *cur;
if (! item->scope_list_.empty()) {
flag &= item->elaborate(des, container);
Expand Down Expand Up @@ -3733,8 +3733,8 @@ bool PGenerate::elaborate_(Design*des, NetScope*scope) const
(*cur)->elaborate(des, scope);

typedef list<PGenerate*>::const_iterator generate_it_t;
for (generate_it_t cur = generates.begin()
; cur != generates.end() ; cur ++ ) {
for (generate_it_t cur = generate_schemes.begin()
; cur != generate_schemes.end() ; cur ++ ) {
(*cur)->elaborate(des, scope);
}

Expand Down
6 changes: 3 additions & 3 deletions pform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ void pform_endgenerate()
if (pform_cur_generate != 0) {
assert(cur->scheme_type == PGenerate::GS_CASE_ITEM
|| pform_cur_generate->scheme_type != PGenerate::GS_CASE);
pform_cur_generate->generates.push_back(cur);
pform_cur_generate->generate_schemes.push_back(cur);
} else {
assert(cur->scheme_type != PGenerate::GS_CASE_ITEM);
pform_cur_module->generate_schemes.push_back(cur);
Expand Down Expand Up @@ -1251,7 +1251,7 @@ void pform_make_reginit(const struct vlltype&li,
FILE_NAME(top, li);

if (pform_cur_generate)
pform_cur_generate->add_behavior(top);
pform_cur_generate->behaviors.push_back(top);
else
lexical_scope->behaviors.push_back(top);
}
Expand Down Expand Up @@ -1905,7 +1905,7 @@ PProcess* pform_make_behavior(PProcess::Type type, Statement*st,
}

if (pform_cur_generate)
pform_cur_generate->add_behavior(pp);
pform_cur_generate->behaviors.push_back(pp);
else
pform_cur_module->behaviors.push_back(pp);

Expand Down
4 changes: 2 additions & 2 deletions pform_dump.cc
Original file line number Diff line number Diff line change
Expand Up @@ -937,8 +937,8 @@ void PGenerate::dump(ostream&out, unsigned indent) const
(*idx)->dump(out, indent+2);
}

for (list<PGenerate*>::const_iterator idx = generates.begin()
; idx != generates.end() ; idx++) {
for (list<PGenerate*>::const_iterator idx = generate_schemes.begin()
; idx != generate_schemes.end() ; idx++) {
(*idx)->dump(out, indent+2);
}

Expand Down

0 comments on commit 15481a9

Please sign in to comment.