Get $root scope tasks/fuctions down to the ivl_target API.
This commit is contained in:
parent
c5fee8bdb9
commit
338a0eb11a
6
emit.cc
6
emit.cc
|
|
@ -504,6 +504,12 @@ int Design::emit(struct target_t*tgt) const
|
|||
if (tgt->start_design(this) == false)
|
||||
return -2;
|
||||
|
||||
for (map<NetScope*,PTaskFunc*>::const_iterator scope = root_tasks_.begin()
|
||||
; scope != root_tasks_.end() ; ++ scope) {
|
||||
scope->first->emit_scope(tgt);
|
||||
scope->first->emit_defs(tgt);
|
||||
}
|
||||
|
||||
// enumerate package scopes
|
||||
for (map<perm_string,NetScope*>::const_iterator scope = packages_.begin()
|
||||
; scope != packages_.end() ; ++ scope) {
|
||||
|
|
|
|||
|
|
@ -52,6 +52,7 @@ struct ivl_design_s {
|
|||
|
||||
// Keep arrays of root scopes.
|
||||
std::map<const NetScope*,ivl_scope_t> classes;
|
||||
std::map<const NetScope*,ivl_scope_t> root_tasks;
|
||||
std::vector<ivl_scope_t> packages;
|
||||
std::vector<ivl_scope_t> roots;
|
||||
|
||||
|
|
|
|||
|
|
@ -169,6 +169,17 @@ list<NetScope*> Design::find_package_scopes() const
|
|||
return res;
|
||||
}
|
||||
|
||||
list<NetScope*> Design::find_roottask_scopes() const
|
||||
{
|
||||
list<NetScope*>res;
|
||||
for (map<NetScope*,PTaskFunc*>::const_iterator cur = root_tasks_.begin()
|
||||
; cur != root_tasks_.end() ; ++ cur) {
|
||||
res.push_back (cur->first);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
/*
|
||||
* This method locates a scope in the design, given its rooted
|
||||
* hierarchical name. Each component of the key is used to scan one
|
||||
|
|
|
|||
|
|
@ -4815,6 +4815,7 @@ class Design : public Definitions {
|
|||
// Tasks
|
||||
NetScope* find_task(NetScope*scope, const pform_name_t&name);
|
||||
void add_root_task(NetScope*tscope, PTaskFunc*tf);
|
||||
std::list<NetScope*> find_roottask_scopes(void) const;
|
||||
|
||||
// Find a class in the $root scope.
|
||||
void add_class(netclass_t*cl, PClass*pclass);
|
||||
|
|
|
|||
|
|
@ -84,7 +84,11 @@ extern "C" void ivl_design_roots(ivl_design_t des, ivl_scope_t **scopes,
|
|||
assert (nscopes && scopes);
|
||||
if (des->root_scope_list.size() == 0) {
|
||||
size_t fill = 0;
|
||||
des->root_scope_list.resize(des->packages.size() + des->roots.size() + des->classes.size());
|
||||
des->root_scope_list.resize(des->root_tasks.size() + des->packages.size() + des->roots.size() + des->classes.size());
|
||||
for (map<const NetScope*,ivl_scope_t>::iterator idx = des->root_tasks.begin()
|
||||
; idx != des->root_tasks.end() ; ++ idx)
|
||||
des->root_scope_list[fill++] = idx->second;
|
||||
|
||||
for (map<const NetScope*,ivl_scope_t>::iterator idx = des->classes.begin()
|
||||
; idx != des->classes.end() ; ++ idx)
|
||||
des->root_scope_list[fill++] = idx->second;
|
||||
|
|
|
|||
65
t-dll.cc
65
t-dll.cc
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2000-2013 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 2000-2014 Stephen Williams (steve@icarus.com)
|
||||
* Copyright CERN 2013 / Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
* 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);
|
||||
|
|
|
|||
|
|
@ -1797,6 +1797,12 @@ int target_design(ivl_design_t des)
|
|||
|
||||
ivl_scope_t cur = root_scopes[idx];
|
||||
switch (ivl_scope_type(cur)) {
|
||||
case IVL_SCT_TASK:
|
||||
fprintf(out, "task = %s\n", ivl_scope_name(cur));
|
||||
break;
|
||||
case IVL_SCT_FUNCTION:
|
||||
fprintf(out, "function = %s\n", ivl_scope_name(cur));
|
||||
break;
|
||||
case IVL_SCT_CLASS:
|
||||
fprintf(out, "class = %s\n", ivl_scope_name(cur));
|
||||
break;
|
||||
|
|
|
|||
Loading…
Reference in New Issue