Handle tasks in packages.
This commit is contained in:
parent
b1d853bf9b
commit
4dffd97d28
15
Statement.cc
15
Statement.cc
|
|
@ -127,7 +127,18 @@ void PBlock::set_statement(const vector<Statement*>&st)
|
|||
}
|
||||
|
||||
PCallTask::PCallTask(const pform_name_t&n, const list<PExpr*>&p)
|
||||
: path_(n), parms_(p.size())
|
||||
: package_(0), path_(n), parms_(p.size())
|
||||
{
|
||||
list<PExpr*>::const_iterator cur = p.begin();
|
||||
for (size_t idx = 0 ; idx < parms_.size() ; idx += 1) {
|
||||
parms_[idx] = *cur;
|
||||
++cur;
|
||||
}
|
||||
assert(cur == p.end());
|
||||
}
|
||||
|
||||
PCallTask::PCallTask(PPackage*pkg, const pform_name_t&n, const list<PExpr*>&p)
|
||||
: package_(pkg), path_(n), parms_(p.size())
|
||||
{
|
||||
list<PExpr*>::const_iterator cur = p.begin();
|
||||
for (size_t idx = 0 ; idx < parms_.size() ; idx += 1) {
|
||||
|
|
@ -138,7 +149,7 @@ PCallTask::PCallTask(const pform_name_t&n, const list<PExpr*>&p)
|
|||
}
|
||||
|
||||
PCallTask::PCallTask(perm_string n, const list<PExpr*>&p)
|
||||
: parms_(p.size())
|
||||
: package_(0), parms_(p.size())
|
||||
{
|
||||
list<PExpr*>::const_iterator cur = p.begin();
|
||||
for (size_t idx = 0 ; idx < parms_.size() ; idx += 1) {
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
# include "HName.h"
|
||||
# include "LineInfo.h"
|
||||
class PExpr;
|
||||
class PPackage;
|
||||
class Statement;
|
||||
class PEventStatement;
|
||||
class Design;
|
||||
|
|
@ -198,6 +199,7 @@ class PBlock : public PScope, public Statement {
|
|||
class PCallTask : public Statement {
|
||||
|
||||
public:
|
||||
explicit PCallTask(PPackage*pkg, const pform_name_t&n, const list<PExpr*>&parms);
|
||||
explicit PCallTask(const pform_name_t&n, const list<PExpr*>&parms);
|
||||
explicit PCallTask(perm_string n, const list<PExpr*>&parms);
|
||||
~PCallTask();
|
||||
|
|
@ -217,6 +219,7 @@ class PCallTask : public Statement {
|
|||
NetProc*elaborate_build_call_(Design*des, NetScope*scope,
|
||||
NetScope*task, NetExpr*use_this) const;
|
||||
|
||||
PPackage*package_;
|
||||
pform_name_t path_;
|
||||
vector<PExpr*> parms_;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3206,7 +3206,13 @@ NetProc* PCallTask::elaborate_usr(Design*des, NetScope*scope) const
|
|||
return 0;
|
||||
}
|
||||
|
||||
NetScope*task = des->find_task(scope, path_);
|
||||
NetScope*pscope = scope;
|
||||
if (package_) {
|
||||
pscope = des->find_package(package_->pscope_name());
|
||||
ivl_assert(*this, pscope);
|
||||
}
|
||||
|
||||
NetScope*task = des->find_task(pscope, path_);
|
||||
if (task == 0) {
|
||||
// For SystemVerilog this may be a few other things.
|
||||
if (gn_system_verilog()) {
|
||||
|
|
|
|||
10
parse.y
10
parse.y
|
|
@ -1412,6 +1412,7 @@ package_item /* IEEE1800-2005 A.1.10 */
|
|||
| K_localparam param_type localparam_assign_list ';'
|
||||
| type_declaration
|
||||
| function_declaration
|
||||
| task_declaration
|
||||
| data_declaration
|
||||
;
|
||||
|
||||
|
|
@ -5725,8 +5726,7 @@ statement_item /* This is roughly statement_item in the LRM */
|
|||
}
|
||||
|
||||
| hierarchy_identifier '(' expression_list_with_nuls ')' ';'
|
||||
{ PCallTask*tmp = new PCallTask(*$1, *$3);
|
||||
FILE_NAME(tmp, @1);
|
||||
{ PCallTask*tmp = pform_make_call_task(@1, *$1, *$3);
|
||||
delete $1;
|
||||
delete $3;
|
||||
$$ = tmp;
|
||||
|
|
@ -5760,8 +5760,7 @@ statement_item /* This is roughly statement_item in the LRM */
|
|||
|
||||
| hierarchy_identifier ';'
|
||||
{ list<PExpr*>pt;
|
||||
PCallTask*tmp = new PCallTask(*$1, pt);
|
||||
FILE_NAME(tmp, @1);
|
||||
PCallTask*tmp = pform_make_call_task(@1, *$1, pt);
|
||||
delete $1;
|
||||
$$ = tmp;
|
||||
}
|
||||
|
|
@ -5769,8 +5768,7 @@ statement_item /* This is roughly statement_item in the LRM */
|
|||
| hierarchy_identifier '(' error ')' ';'
|
||||
{ yyerror(@3, "error: Syntax error in task arguments.");
|
||||
list<PExpr*>pt;
|
||||
PCallTask*tmp = new PCallTask(*$1, pt);
|
||||
FILE_NAME(tmp, @1);
|
||||
PCallTask*tmp = pform_make_call_task(@1, *$1, pt);
|
||||
delete $1;
|
||||
$$ = tmp;
|
||||
}
|
||||
|
|
|
|||
28
pform.cc
28
pform.cc
|
|
@ -580,6 +580,34 @@ PECallFunction* pform_make_call_function(const struct vlltype&loc,
|
|||
return tmp;
|
||||
}
|
||||
|
||||
PCallTask* pform_make_call_task(const struct vlltype&loc,
|
||||
const pform_name_t&name,
|
||||
const list<PExpr*>&parms)
|
||||
{
|
||||
PCallTask*tmp = 0;
|
||||
|
||||
do {
|
||||
if (name.size() != 1)
|
||||
break;
|
||||
|
||||
perm_string use_name = peek_tail_name(name);
|
||||
|
||||
map<perm_string,PPackage*>::iterator cur_pkg;
|
||||
cur_pkg = lexical_scope->imports.find(use_name);
|
||||
if (cur_pkg == lexical_scope->imports.end())
|
||||
break;
|
||||
|
||||
tmp = new PCallTask(cur_pkg->second, name, parms);
|
||||
} while (0);
|
||||
|
||||
if (tmp == 0) {
|
||||
tmp = new PCallTask(name, parms);
|
||||
}
|
||||
|
||||
FILE_NAME(tmp, loc);
|
||||
return tmp;
|
||||
}
|
||||
|
||||
static void pform_put_behavior_in_scope(PProcess*pp)
|
||||
{
|
||||
lexical_scope->behaviors.push_back(pp);
|
||||
|
|
|
|||
6
pform.h
6
pform.h
|
|
@ -279,7 +279,11 @@ extern void pform_set_typedef(perm_string name, data_type_t*data_type);
|
|||
*/
|
||||
extern PECallFunction* pform_make_call_function(const struct vlltype&loc,
|
||||
const pform_name_t&name,
|
||||
const list<PExpr*>&parms);
|
||||
const std::list<PExpr*>&parms);
|
||||
extern PCallTask* pform_make_call_task(const struct vlltype&loc,
|
||||
const pform_name_t&name,
|
||||
const std::list<PExpr*>&parms);
|
||||
|
||||
|
||||
/*
|
||||
* The makewire functions announce to the pform code new wires. These
|
||||
|
|
|
|||
|
|
@ -105,6 +105,13 @@ void pform_package_import(const struct vlltype&, PPackage*pkg, const char*ident)
|
|||
return;
|
||||
}
|
||||
|
||||
map<perm_string,PTask*>::const_iterator ttcur;
|
||||
ttcur = pkg->tasks.find(use_ident);
|
||||
if (ttcur != pkg->tasks.end()) {
|
||||
scope->imports[ttcur->first] = pkg;
|
||||
return;
|
||||
}
|
||||
|
||||
map<perm_string,PWire*>::const_iterator wcur;
|
||||
wcur = pkg->wires.find(use_ident);
|
||||
if (wcur != pkg->wires.end()) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue