Get $root scope tasks/fuctions down to the ivl_target API.

This commit is contained in:
Stephen Williams
2014-10-02 14:09:27 -07:00
parent c5fee8bdb9
commit 338a0eb11a
7 changed files with 79 additions and 17 deletions
+49 -16
View File
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000-2013 Stephen Williams ([email protected])
* Copyright (c) 2000-2014 Stephen Williams ([email protected])
* Copyright CERN 2013 / Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
@@ -261,6 +261,12 @@ ivl_scope_t dll_target::find_scope(ivl_design_s &des, const NetScope*cur)
return tmp;
}
if (cur->type()==NetScope::TASK || cur->type()==NetScope::FUNC) {
map<const NetScope*,ivl_scope_t>::const_iterator idx = des.root_tasks.find(cur);
if (idx != des.root_tasks.end())
return idx->second;
}
for (unsigned idx = 0; idx < des.roots.size(); idx += 1) {
assert(des.roots[idx]);
ivl_scope_t scope = find_scope_from_root(des.roots[idx], cur);
@@ -605,6 +611,13 @@ void dll_target::add_root(const NetScope *s)
root_->lpm_ = 0;
root_->def = 0;
make_scope_parameters(root_, s);
root_->tname_ = root_->name_;
root_->time_precision = s->time_precision();
root_->time_units = s->time_unit();
root_->nattr = s->attr_cnt();
root_->attr = fill_in_attributes(s);
root_->is_auto = 0;
root_->is_cell = s->is_cell();
switch (s->type()) {
case NetScope::PACKAGE:
root_->type_ = IVL_SCT_PACKAGE;
@@ -615,16 +628,25 @@ void dll_target::add_root(const NetScope *s)
case NetScope::CLASS:
root_->type_ = IVL_SCT_CLASS;
break;
case NetScope::TASK: {
const NetTaskDef*def = s->task_def();
if (def == 0) {
cerr << "?:?" << ": internal error: "
<< "task " << root_->name_
<< " has no definition." << endl;
}
assert(def);
root_->type_ = IVL_SCT_TASK;
root_->tname_ = def->scope()->basename();
break;
}
break;
case NetScope::FUNC:
root_->type_ = IVL_SCT_FUNCTION;
break;
default:
assert(0);
}
root_->tname_ = root_->name_;
root_->time_precision = s->time_precision();
root_->time_units = s->time_unit();
root_->nattr = s->attr_cnt();
root_->attr = fill_in_attributes(s);
root_->is_auto = 0;
root_->is_cell = s->is_cell();
switch (s->type()) {
case NetScope::MODULE:
@@ -650,6 +672,11 @@ void dll_target::add_root(const NetScope *s)
des_.classes[s] = root_;
break;
case NetScope::TASK:
case NetScope::FUNC:
des_.root_tasks[s] = root_;
break;
default:
assert(0);
break;
@@ -691,16 +718,22 @@ bool dll_target::start_design(const Design*des)
}
assert(idx == des_.disciplines.size());
list<NetScope *> package_scopes = des->find_package_scopes();
for (list<NetScope*>::const_iterator scop = package_scopes.begin()
; scop != package_scopes.end(); ++ scop ) {
add_root(*scop);
list<NetScope *> scope_list = des->find_roottask_scopes();
for (list<NetScope*>::const_iterator cur = scope_list.begin()
; cur != scope_list.end() ; ++ cur) {
add_root(*cur);
}
list<NetScope *> root_scopes = des->find_root_scopes();
for (list<NetScope*>::const_iterator scop = root_scopes.begin()
; scop != root_scopes.end(); ++ scop ) {
add_root(*scop);
scope_list = des->find_package_scopes();
for (list<NetScope*>::const_iterator cur = scope_list.begin()
; cur != scope_list.end(); ++ cur ) {
add_root(*cur);
}
scope_list = des->find_root_scopes();
for (list<NetScope*>::const_iterator cur = scope_list.begin()
; cur != scope_list.end(); ++ cur ) {
add_root(*cur);
}
target_ = (target_design_f)ivl_dlsym(dll_, LU "target_design" TU);