2000-09-18 03:24:32 +02:00
|
|
|
/*
|
2013-09-17 05:01:06 +02:00
|
|
|
* Copyright (c) 2000-2013 Stephen Williams (steve@icarus.com)
|
2000-09-18 03:24:32 +02:00
|
|
|
*
|
|
|
|
|
* This source code is free software; you can redistribute it
|
|
|
|
|
* and/or modify it in source code form under the terms of the GNU
|
|
|
|
|
* General Public License as published by the Free Software
|
|
|
|
|
* Foundation; either version 2 of the License, or (at your option)
|
|
|
|
|
* any later version.will need a Picture Elements Binary Software
|
|
|
|
|
* License.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
2012-08-29 03:41:23 +02:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2000-09-18 03:24:32 +02:00
|
|
|
*/
|
|
|
|
|
|
2001-07-25 05:10:48 +02:00
|
|
|
# include "config.h"
|
|
|
|
|
|
|
|
|
|
# include <iostream>
|
|
|
|
|
|
2008-01-05 00:23:47 +01:00
|
|
|
# include <cstring>
|
2000-09-18 03:24:32 +02:00
|
|
|
# include "target.h"
|
|
|
|
|
# include "ivl_target.h"
|
|
|
|
|
# include "compiler.h"
|
|
|
|
|
# include "t-dll.h"
|
2012-12-10 02:59:16 +01:00
|
|
|
# include "netclass.h"
|
2010-05-31 22:12:06 +02:00
|
|
|
# include <cstdlib>
|
2010-10-24 00:52:56 +02:00
|
|
|
# include "ivl_alloc.h"
|
2000-09-18 03:24:32 +02:00
|
|
|
|
|
|
|
|
bool dll_target::process(const NetProcTop*net)
|
|
|
|
|
{
|
2008-07-31 03:01:41 +02:00
|
|
|
bool rc_flag = true;
|
|
|
|
|
|
2000-09-18 03:24:32 +02:00
|
|
|
ivl_process_t obj = (struct ivl_process_s*)
|
|
|
|
|
calloc(1, sizeof(struct ivl_process_s));
|
|
|
|
|
|
2008-10-22 07:15:49 +02:00
|
|
|
obj->type_ = net->type();
|
2008-11-07 06:31:34 +01:00
|
|
|
obj->analog_flag = 0;
|
2008-10-22 07:15:49 +02:00
|
|
|
|
2008-08-01 23:59:53 +02:00
|
|
|
FILE_NAME(obj, net);
|
2000-09-18 03:24:32 +02:00
|
|
|
|
2001-03-20 02:44:13 +01:00
|
|
|
/* Save the scope of the process. */
|
|
|
|
|
obj->scope_ = lookup_scope_(net->scope());
|
|
|
|
|
|
2002-05-26 03:39:02 +02:00
|
|
|
obj->nattr = net->attr_cnt();
|
|
|
|
|
obj->attr = fill_in_attributes(net);
|
2001-03-20 02:44:13 +01:00
|
|
|
|
2000-09-18 03:24:32 +02:00
|
|
|
/* This little bit causes the process to be completely
|
|
|
|
|
generated so that it can be passed to the DLL. The
|
2008-09-11 04:37:11 +02:00
|
|
|
stmt_cur_ member is used to hold a pointer to the current
|
2000-09-18 03:24:32 +02:00
|
|
|
statement in progress, and the emit_proc() method fills in
|
|
|
|
|
that object.
|
|
|
|
|
|
|
|
|
|
We know a few things about the current statement: we are
|
|
|
|
|
not in the middle of one, and when we are done, we have our
|
|
|
|
|
statement back. The asserts check these conditions. */
|
|
|
|
|
|
|
|
|
|
assert(stmt_cur_ == 0);
|
|
|
|
|
stmt_cur_ = (struct ivl_statement_s*)calloc(1, sizeof*stmt_cur_);
|
2008-07-31 03:01:41 +02:00
|
|
|
rc_flag = net->statement()->emit_proc(this) && rc_flag;
|
2000-09-18 03:24:32 +02:00
|
|
|
|
|
|
|
|
assert(stmt_cur_);
|
|
|
|
|
obj->stmt_ = stmt_cur_;
|
|
|
|
|
stmt_cur_ = 0;
|
|
|
|
|
|
2000-10-08 06:01:54 +02:00
|
|
|
/* Save the process in the design. */
|
|
|
|
|
obj->next_ = des_.threads_;
|
|
|
|
|
des_.threads_ = obj;
|
2000-09-18 03:24:32 +02:00
|
|
|
|
2008-07-31 03:01:41 +02:00
|
|
|
return rc_flag;
|
2000-09-18 03:24:32 +02:00
|
|
|
}
|
|
|
|
|
|
2001-04-02 04:28:12 +02:00
|
|
|
void dll_target::task_def(const NetScope*net)
|
|
|
|
|
{
|
2008-10-20 19:06:04 +02:00
|
|
|
ivl_scope_t scop = lookup_scope_(net);
|
2001-04-02 04:28:12 +02:00
|
|
|
const NetTaskDef*def = net->task_def();
|
|
|
|
|
|
|
|
|
|
assert(stmt_cur_ == 0);
|
|
|
|
|
stmt_cur_ = (struct ivl_statement_s*)calloc(1, sizeof*stmt_cur_);
|
|
|
|
|
def->proc()->emit_proc(this);
|
|
|
|
|
|
|
|
|
|
assert(stmt_cur_);
|
2008-10-20 19:06:04 +02:00
|
|
|
scop->def = stmt_cur_;
|
2001-04-02 04:28:12 +02:00
|
|
|
stmt_cur_ = 0;
|
|
|
|
|
|
2011-01-10 18:23:36 +01:00
|
|
|
scop->ports = def->port_count();
|
|
|
|
|
if (scop->ports > 0) {
|
2011-03-07 20:18:23 +01:00
|
|
|
scop->u_.port = new ivl_signal_t[scop->ports];
|
2011-01-10 18:23:36 +01:00
|
|
|
for (unsigned idx = 0 ; idx < scop->ports ; idx += 1)
|
2011-03-07 20:18:23 +01:00
|
|
|
scop->u_.port[idx] = find_signal(des_, def->port(idx));
|
2011-01-10 18:23:36 +01:00
|
|
|
}
|
|
|
|
|
|
2001-04-02 04:28:12 +02:00
|
|
|
}
|
|
|
|
|
|
2004-06-01 01:34:36 +02:00
|
|
|
bool dll_target::func_def(const NetScope*net)
|
2001-04-06 04:28:02 +02:00
|
|
|
{
|
2008-10-20 19:06:04 +02:00
|
|
|
ivl_scope_t scop = lookup_scope_(net);
|
2001-04-06 04:28:02 +02:00
|
|
|
const NetFuncDef*def = net->func_def();
|
|
|
|
|
|
|
|
|
|
assert(stmt_cur_ == 0);
|
|
|
|
|
stmt_cur_ = (struct ivl_statement_s*)calloc(1, sizeof*stmt_cur_);
|
|
|
|
|
def->proc()->emit_proc(this);
|
|
|
|
|
|
|
|
|
|
assert(stmt_cur_);
|
2008-10-20 19:06:04 +02:00
|
|
|
scop->def = stmt_cur_;
|
2001-04-06 04:28:02 +02:00
|
|
|
stmt_cur_ = 0;
|
|
|
|
|
|
2008-10-20 19:06:04 +02:00
|
|
|
scop->ports = def->port_count() + 1;
|
|
|
|
|
if (scop->ports > 0) {
|
2011-03-07 20:18:23 +01:00
|
|
|
scop->u_.port = new ivl_signal_t[scop->ports];
|
2008-10-20 19:06:04 +02:00
|
|
|
for (unsigned idx = 1 ; idx < scop->ports ; idx += 1)
|
2011-03-07 20:18:23 +01:00
|
|
|
scop->u_.port[idx] = find_signal(des_, def->port(idx-1));
|
2001-04-06 04:28:02 +02:00
|
|
|
}
|
2004-06-01 01:34:36 +02:00
|
|
|
|
|
|
|
|
/* FIXME: the ivl_target API expects port-0 to be the output
|
|
|
|
|
port. This assumes that the return value is a signal, which
|
|
|
|
|
is *not* correct. Someday, I'm going to have to change
|
|
|
|
|
this, but that will break code generators that use this
|
|
|
|
|
result. */
|
2013-09-19 03:48:16 +02:00
|
|
|
if (const NetNet*ret_sig = def->return_sig())
|
2011-03-07 20:18:23 +01:00
|
|
|
scop->u_.port[0] = find_signal(des_, ret_sig);
|
2013-09-19 03:48:16 +02:00
|
|
|
else
|
|
|
|
|
scop->u_.port[0] = 0;
|
|
|
|
|
|
|
|
|
|
/* If there is no return value, then this is a void function. */
|
2004-06-01 01:34:36 +02:00
|
|
|
|
2013-09-19 03:48:16 +02:00
|
|
|
return true;
|
2004-06-01 01:34:36 +02:00
|
|
|
|
2001-04-06 04:28:02 +02:00
|
|
|
}
|
|
|
|
|
|
2000-10-07 01:46:50 +02:00
|
|
|
/*
|
2004-12-11 03:31:25 +01:00
|
|
|
* This private function makes the assignment lvals for the various
|
|
|
|
|
* kinds of assignment statements.
|
2000-09-18 03:24:32 +02:00
|
|
|
*/
|
2013-11-17 01:27:05 +01:00
|
|
|
bool dll_target::make_assign_lvals_(const NetAssignBase*net)
|
2000-09-18 03:24:32 +02:00
|
|
|
{
|
2013-11-17 01:27:05 +01:00
|
|
|
bool flag = true;
|
2000-09-18 03:24:32 +02:00
|
|
|
assert(stmt_cur_);
|
|
|
|
|
|
2004-12-11 03:31:25 +01:00
|
|
|
unsigned cnt = net->l_val_count();
|
2000-10-07 01:46:50 +02:00
|
|
|
|
2004-12-11 03:31:25 +01:00
|
|
|
stmt_cur_->u_.assign_.lvals_ = cnt;
|
|
|
|
|
stmt_cur_->u_.assign_.lval_ = new struct ivl_lval_s[cnt];
|
|
|
|
|
stmt_cur_->u_.assign_.delay = 0;
|
2000-10-18 22:04:39 +02:00
|
|
|
|
|
|
|
|
for (unsigned idx = 0 ; idx < cnt ; idx += 1) {
|
|
|
|
|
struct ivl_lval_s*cur = stmt_cur_->u_.assign_.lval_ + idx;
|
|
|
|
|
const NetAssign_*asn = net->l_val(idx);
|
2006-02-02 03:43:57 +01:00
|
|
|
const NetExpr*loff = asn->get_base();
|
|
|
|
|
|
|
|
|
|
if (loff == 0) {
|
|
|
|
|
cur->loff = 0;
|
2011-02-23 18:15:36 +01:00
|
|
|
cur->sel_type = IVL_SEL_OTHER;
|
2006-02-02 03:43:57 +01:00
|
|
|
} else {
|
|
|
|
|
loff->expr_scan(this);
|
|
|
|
|
cur->loff = expr_;
|
2011-02-23 18:15:36 +01:00
|
|
|
cur->sel_type = asn->select_type();
|
2006-02-02 03:43:57 +01:00
|
|
|
expr_ = 0;
|
|
|
|
|
}
|
2000-10-18 22:04:39 +02:00
|
|
|
|
2001-08-26 01:50:02 +02:00
|
|
|
cur->width_ = asn->lwidth();
|
2006-02-02 03:43:57 +01:00
|
|
|
|
2002-06-04 07:38:43 +02:00
|
|
|
if (asn->sig()) {
|
2004-12-11 03:31:25 +01:00
|
|
|
cur->type_ = IVL_LVAL_REG;
|
|
|
|
|
cur->n.sig = find_signal(des_, asn->sig());
|
2002-06-04 07:38:43 +02:00
|
|
|
|
|
|
|
|
cur->idx = 0;
|
2007-01-16 06:44:14 +01:00
|
|
|
// If there is a word select expression, it is
|
2007-04-04 03:50:38 +02:00
|
|
|
// really an array index. Note that the word index
|
|
|
|
|
// expression is already converted to canonical
|
|
|
|
|
// form by elaboration.
|
2007-01-16 06:44:14 +01:00
|
|
|
if (asn->word()) {
|
2002-06-04 07:38:43 +02:00
|
|
|
assert(expr_ == 0);
|
2007-01-16 06:44:14 +01:00
|
|
|
asn->word()->expr_scan(this);
|
|
|
|
|
cur->type_ = IVL_LVAL_ARR;
|
2002-06-04 07:38:43 +02:00
|
|
|
cur->idx = expr_;
|
|
|
|
|
expr_ = 0;
|
|
|
|
|
}
|
2012-12-10 02:59:16 +01:00
|
|
|
|
|
|
|
|
cur->property_idx = -1;
|
|
|
|
|
perm_string pname = asn->get_property();
|
|
|
|
|
if (!pname.nil()) {
|
|
|
|
|
const netclass_t*use_type = dynamic_cast<const netclass_t*> (cur->n.sig->net_type);
|
|
|
|
|
cur->property_idx = use_type->property_idx_from_name(pname);
|
|
|
|
|
}
|
|
|
|
|
|
2004-12-11 03:31:25 +01:00
|
|
|
} else {
|
2013-11-17 01:27:05 +01:00
|
|
|
cerr << net->get_fileline() << ": internal error: "
|
|
|
|
|
<< "I don't know how to handle nested l-values "
|
|
|
|
|
<< "in ivl_target.h API." << endl;
|
|
|
|
|
flag = false;
|
2000-10-18 22:04:39 +02:00
|
|
|
}
|
|
|
|
|
}
|
2013-11-17 01:27:05 +01:00
|
|
|
|
|
|
|
|
return flag;
|
2004-12-11 03:31:25 +01:00
|
|
|
}
|
|
|
|
|
|
2008-09-27 01:54:13 +02:00
|
|
|
void dll_target::proc_alloc(const NetAlloc*net)
|
|
|
|
|
{
|
|
|
|
|
assert(stmt_cur_);
|
|
|
|
|
assert(stmt_cur_->type_ == IVL_ST_NONE);
|
|
|
|
|
FILE_NAME(stmt_cur_, net);
|
|
|
|
|
|
|
|
|
|
stmt_cur_->type_ = IVL_ST_ALLOC;
|
|
|
|
|
stmt_cur_->u_.alloc_.scope = lookup_scope_(net->scope());
|
|
|
|
|
}
|
|
|
|
|
|
2004-12-11 03:31:25 +01:00
|
|
|
/*
|
|
|
|
|
*/
|
2008-07-31 03:01:41 +02:00
|
|
|
bool dll_target::proc_assign(const NetAssign*net)
|
2004-12-11 03:31:25 +01:00
|
|
|
{
|
2013-11-17 01:27:05 +01:00
|
|
|
bool flag = true;
|
|
|
|
|
|
2004-12-11 03:31:25 +01:00
|
|
|
assert(stmt_cur_);
|
|
|
|
|
assert(stmt_cur_->type_ == IVL_ST_NONE);
|
|
|
|
|
|
|
|
|
|
stmt_cur_->type_ = IVL_ST_ASSIGN;
|
2007-12-22 15:31:24 +01:00
|
|
|
FILE_NAME(stmt_cur_, net);
|
2004-12-11 03:31:25 +01:00
|
|
|
|
|
|
|
|
stmt_cur_->u_.assign_.delay = 0;
|
|
|
|
|
|
|
|
|
|
/* Make the lval fields. */
|
2013-11-17 01:27:05 +01:00
|
|
|
flag &= make_assign_lvals_(net);
|
2000-10-07 01:46:50 +02:00
|
|
|
|
2011-11-28 01:46:02 +01:00
|
|
|
stmt_cur_->u_.assign_.oper = net->assign_operator();
|
2000-10-07 01:46:50 +02:00
|
|
|
assert(expr_ == 0);
|
|
|
|
|
net->rval()->expr_scan(this);
|
|
|
|
|
stmt_cur_->u_.assign_.rval_ = expr_;
|
|
|
|
|
expr_ = 0;
|
2002-04-22 00:31:02 +02:00
|
|
|
|
|
|
|
|
const NetExpr*del = net->get_delay();
|
|
|
|
|
if (del) {
|
|
|
|
|
del->expr_scan(this);
|
|
|
|
|
stmt_cur_->u_.assign_.delay = expr_;
|
|
|
|
|
expr_ = 0;
|
|
|
|
|
}
|
2008-07-31 03:01:41 +02:00
|
|
|
|
2013-11-17 01:27:05 +01:00
|
|
|
return flag;
|
2000-09-18 03:24:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2001-04-03 06:50:37 +02:00
|
|
|
void dll_target::proc_assign_nb(const NetAssignNB*net)
|
|
|
|
|
{
|
2002-04-22 00:31:02 +02:00
|
|
|
const NetExpr* delay_exp = net->get_delay();
|
2008-09-11 04:37:11 +02:00
|
|
|
const NetExpr* cnt_exp = net->get_count();
|
2001-04-03 06:50:37 +02:00
|
|
|
assert(stmt_cur_);
|
|
|
|
|
assert(stmt_cur_->type_ == IVL_ST_NONE);
|
|
|
|
|
|
|
|
|
|
stmt_cur_->type_ = IVL_ST_ASSIGN_NB;
|
2007-12-22 15:31:24 +01:00
|
|
|
FILE_NAME(stmt_cur_, net);
|
|
|
|
|
|
2001-04-15 04:58:11 +02:00
|
|
|
stmt_cur_->u_.assign_.delay = 0;
|
2008-09-11 04:37:11 +02:00
|
|
|
stmt_cur_->u_.assign_.count = 0;
|
|
|
|
|
stmt_cur_->u_.assign_.nevent = 0;
|
2001-04-03 06:50:37 +02:00
|
|
|
|
2004-12-11 03:31:25 +01:00
|
|
|
/* Make the lval fields. */
|
|
|
|
|
make_assign_lvals_(net);
|
2001-04-03 06:50:37 +02:00
|
|
|
|
2004-12-11 03:31:25 +01:00
|
|
|
/* Make the rval field. */
|
2001-04-03 06:50:37 +02:00
|
|
|
assert(expr_ == 0);
|
|
|
|
|
net->rval()->expr_scan(this);
|
|
|
|
|
stmt_cur_->u_.assign_.rval_ = expr_;
|
|
|
|
|
expr_ = 0;
|
2001-04-15 04:58:11 +02:00
|
|
|
|
2008-09-11 04:37:11 +02:00
|
|
|
/* Process a delay if it exists. */
|
2002-04-22 00:31:02 +02:00
|
|
|
if (const NetEConst*delay_num = dynamic_cast<const NetEConst*>(delay_exp)) {
|
|
|
|
|
verinum val = delay_num->value();
|
2001-04-15 04:58:11 +02:00
|
|
|
ivl_expr_t de = new struct ivl_expr_s;
|
2009-02-17 01:44:52 +01:00
|
|
|
de->type_ = IVL_EX_DELAY;
|
|
|
|
|
de->width_ = 8 * sizeof(uint64_t);
|
2001-04-15 04:58:11 +02:00
|
|
|
de->signed_ = 0;
|
2009-02-17 01:44:52 +01:00
|
|
|
de->u_.delay_.value = val.as_ulong64();
|
2001-04-15 04:58:11 +02:00
|
|
|
stmt_cur_->u_.assign_.delay = de;
|
2002-04-22 00:31:02 +02:00
|
|
|
|
|
|
|
|
} else if (delay_exp != 0) {
|
|
|
|
|
delay_exp->expr_scan(this);
|
|
|
|
|
stmt_cur_->u_.assign_.delay = expr_;
|
|
|
|
|
expr_ = 0;
|
2001-04-15 04:58:11 +02:00
|
|
|
}
|
2008-09-11 04:37:11 +02:00
|
|
|
|
|
|
|
|
/* Process a count if it exists. */
|
|
|
|
|
if (const NetEConst*cnt_num = dynamic_cast<const NetEConst*>(cnt_exp)) {
|
|
|
|
|
verinum val = cnt_num->value();
|
|
|
|
|
ivl_expr_t cnt = new struct ivl_expr_s;
|
|
|
|
|
cnt->type_ = IVL_EX_ULONG;
|
|
|
|
|
cnt->width_ = 8 * sizeof(unsigned long);
|
|
|
|
|
cnt->signed_ = 0;
|
|
|
|
|
cnt->u_.ulong_.value = val.as_ulong();
|
|
|
|
|
stmt_cur_->u_.assign_.count = cnt;
|
|
|
|
|
|
|
|
|
|
} else if (cnt_exp != 0) {
|
|
|
|
|
cnt_exp->expr_scan(this);
|
|
|
|
|
stmt_cur_->u_.assign_.count = expr_;
|
|
|
|
|
expr_ = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Process the events if they exist. This is a copy of code
|
|
|
|
|
* from NetEvWait below. */
|
|
|
|
|
if (net->nevents() > 0) {
|
|
|
|
|
stmt_cur_->u_.assign_.nevent = net->nevents();
|
|
|
|
|
if (net->nevents() > 1) {
|
|
|
|
|
stmt_cur_->u_.assign_.events = (ivl_event_t*)
|
|
|
|
|
calloc(net->nevents(), sizeof(ivl_event_t*));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (unsigned edx = 0 ; edx < net->nevents() ; edx += 1) {
|
|
|
|
|
|
|
|
|
|
/* Locate the event by name. Save the ivl_event_t in the
|
|
|
|
|
statement so that the generator can find it easily. */
|
|
|
|
|
const NetEvent*ev = net->event(edx);
|
|
|
|
|
ivl_scope_t ev_scope = lookup_scope_(ev->scope());
|
|
|
|
|
ivl_event_t ev_tmp=0;
|
|
|
|
|
|
|
|
|
|
assert(ev_scope);
|
|
|
|
|
assert(ev_scope->nevent_ > 0);
|
|
|
|
|
for (unsigned idx = 0; idx < ev_scope->nevent_; idx += 1) {
|
|
|
|
|
const char*ename =
|
|
|
|
|
ivl_event_basename(ev_scope->event_[idx]);
|
|
|
|
|
if (strcmp(ev->name(), ename) == 0) {
|
|
|
|
|
ev_tmp = ev_scope->event_[idx];
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// XXX should we assert(ev_tmp)?
|
|
|
|
|
|
|
|
|
|
if (net->nevents() == 1)
|
|
|
|
|
stmt_cur_->u_.assign_.event = ev_tmp;
|
|
|
|
|
else
|
|
|
|
|
stmt_cur_->u_.assign_.events[edx] = ev_tmp;
|
|
|
|
|
|
|
|
|
|
/* If this is an event with a probe, then connect up the
|
|
|
|
|
pins. This wasn't done during the ::event method because
|
|
|
|
|
the signals weren't scanned yet. */
|
|
|
|
|
|
|
|
|
|
if (ev->nprobe() >= 1) {
|
|
|
|
|
unsigned iany = 0;
|
|
|
|
|
unsigned ineg = ev_tmp->nany;
|
|
|
|
|
unsigned ipos = ineg + ev_tmp->nneg;
|
|
|
|
|
|
|
|
|
|
for (unsigned idx = 0; idx < ev->nprobe(); idx += 1) {
|
|
|
|
|
const NetEvProbe*pr = ev->probe(idx);
|
|
|
|
|
unsigned base = 0;
|
|
|
|
|
|
|
|
|
|
switch (pr->edge()) {
|
|
|
|
|
case NetEvProbe::ANYEDGE:
|
|
|
|
|
base = iany;
|
|
|
|
|
iany += pr->pin_count();
|
|
|
|
|
break;
|
|
|
|
|
case NetEvProbe::NEGEDGE:
|
|
|
|
|
base = ineg;
|
|
|
|
|
ineg += pr->pin_count();
|
|
|
|
|
break;
|
|
|
|
|
case NetEvProbe::POSEDGE:
|
|
|
|
|
base = ipos;
|
|
|
|
|
ipos += pr->pin_count();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (unsigned bit = 0; bit < pr->pin_count();
|
|
|
|
|
bit += 1) {
|
|
|
|
|
ivl_nexus_t nex = (ivl_nexus_t)
|
|
|
|
|
pr->pin(bit).nexus()->t_cookie();
|
|
|
|
|
assert(nex);
|
|
|
|
|
ev_tmp->pins[base+bit] = nex;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2001-04-03 06:50:37 +02:00
|
|
|
}
|
|
|
|
|
|
2000-09-18 03:24:32 +02:00
|
|
|
bool dll_target::proc_block(const NetBlock*net)
|
|
|
|
|
{
|
|
|
|
|
assert(stmt_cur_);
|
|
|
|
|
assert(stmt_cur_->type_ == IVL_ST_NONE);
|
2007-12-22 15:31:24 +01:00
|
|
|
FILE_NAME(stmt_cur_, net);
|
2000-09-18 03:24:32 +02:00
|
|
|
|
|
|
|
|
/* First, count the statements in the block. */
|
|
|
|
|
unsigned count = 0;
|
|
|
|
|
for (const NetProc*cur = net->proc_first()
|
|
|
|
|
; cur ; cur = net->proc_next(cur))
|
|
|
|
|
count += 1;
|
|
|
|
|
|
|
|
|
|
/* If the block has no statements, then turn it into a no-op */
|
|
|
|
|
if (count == 0) {
|
|
|
|
|
stmt_cur_->type_ = IVL_ST_NOOP;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If there is exactly one statement, there is no need for the
|
|
|
|
|
block wrapper, generate the contained statement instead. */
|
2002-08-13 07:35:00 +02:00
|
|
|
if ((count == 1) && (net->subscope() == 0)) {
|
2000-09-18 03:24:32 +02:00
|
|
|
return net->proc_first()->emit_proc(this);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Handle the general case. The block has some statements in
|
|
|
|
|
it, so fill in the block fields of the existing statement,
|
|
|
|
|
and generate the contents for the statement array. */
|
|
|
|
|
|
2012-05-20 02:34:13 +02:00
|
|
|
switch (net->type()) {
|
|
|
|
|
case NetBlock::SEQU:
|
|
|
|
|
stmt_cur_->type_ = IVL_ST_BLOCK;
|
|
|
|
|
break;
|
|
|
|
|
case NetBlock::PARA:
|
|
|
|
|
stmt_cur_->type_ = IVL_ST_FORK;
|
|
|
|
|
break;
|
|
|
|
|
case NetBlock::PARA_JOIN_ANY:
|
|
|
|
|
stmt_cur_->type_ = IVL_ST_FORK_JOIN_ANY;
|
|
|
|
|
break;
|
|
|
|
|
case NetBlock::PARA_JOIN_NONE:
|
|
|
|
|
stmt_cur_->type_ = IVL_ST_FORK_JOIN_NONE;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2000-09-18 03:24:32 +02:00
|
|
|
stmt_cur_->u_.block_.nstmt_ = count;
|
|
|
|
|
stmt_cur_->u_.block_.stmt_ = (struct ivl_statement_s*)
|
|
|
|
|
calloc(count, sizeof(struct ivl_statement_s));
|
|
|
|
|
|
2002-05-27 02:08:45 +02:00
|
|
|
if (net->subscope())
|
|
|
|
|
stmt_cur_->u_.block_.scope = lookup_scope_(net->subscope());
|
|
|
|
|
else
|
|
|
|
|
stmt_cur_->u_.block_.scope = 0;
|
|
|
|
|
|
2000-09-18 03:24:32 +02:00
|
|
|
struct ivl_statement_s*save_cur_ = stmt_cur_;
|
|
|
|
|
unsigned idx = 0;
|
|
|
|
|
bool flag = true;
|
|
|
|
|
|
|
|
|
|
for (const NetProc*cur = net->proc_first()
|
|
|
|
|
; cur ; cur = net->proc_next(cur), idx += 1) {
|
|
|
|
|
assert(idx < count);
|
|
|
|
|
stmt_cur_ = save_cur_->u_.block_.stmt_ + idx;
|
|
|
|
|
bool rc = cur->emit_proc(this);
|
|
|
|
|
flag = flag && rc;
|
|
|
|
|
}
|
|
|
|
|
assert(idx == count);
|
|
|
|
|
|
|
|
|
|
stmt_cur_ = save_cur_;
|
|
|
|
|
|
|
|
|
|
return flag;
|
|
|
|
|
}
|
|
|
|
|
|
2001-06-22 01:23:14 +02:00
|
|
|
/*
|
|
|
|
|
* A case statement is in turn an array of statements with gate
|
|
|
|
|
* expressions. This builds arrays of the right size and builds the
|
|
|
|
|
* ivl_expr_t and ivl_statement_s arrays for the substatements.
|
|
|
|
|
*/
|
2001-03-31 19:36:38 +02:00
|
|
|
void dll_target::proc_case(const NetCase*net)
|
|
|
|
|
{
|
|
|
|
|
assert(stmt_cur_);
|
|
|
|
|
assert(stmt_cur_->type_ == IVL_ST_NONE);
|
2007-12-22 15:31:24 +01:00
|
|
|
FILE_NAME(stmt_cur_, net);
|
2001-03-31 19:36:38 +02:00
|
|
|
|
|
|
|
|
switch (net->type()) {
|
|
|
|
|
case NetCase::EQ:
|
|
|
|
|
stmt_cur_->type_ = IVL_ST_CASE;
|
|
|
|
|
break;
|
|
|
|
|
case NetCase::EQX:
|
|
|
|
|
stmt_cur_->type_ = IVL_ST_CASEX;
|
|
|
|
|
break;
|
|
|
|
|
case NetCase::EQZ:
|
|
|
|
|
stmt_cur_->type_ = IVL_ST_CASEZ;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
assert(stmt_cur_->type_ != IVL_ST_NONE);
|
|
|
|
|
|
|
|
|
|
assert(expr_ == 0);
|
2001-04-15 05:14:31 +02:00
|
|
|
assert(net->expr());
|
2001-03-31 19:36:38 +02:00
|
|
|
net->expr()->expr_scan(this);
|
|
|
|
|
stmt_cur_->u_.case_.cond = expr_;
|
|
|
|
|
expr_ = 0;
|
|
|
|
|
|
2003-05-14 07:26:41 +02:00
|
|
|
/* If the condition expression is a real valued expression,
|
|
|
|
|
then change the case statement to a CASER statement. */
|
|
|
|
|
if (stmt_cur_->u_.case_.cond->value_ == IVL_VT_REAL)
|
|
|
|
|
stmt_cur_->type_ = IVL_ST_CASER;
|
|
|
|
|
|
2001-03-31 19:36:38 +02:00
|
|
|
unsigned ncase = net->nitems();
|
|
|
|
|
stmt_cur_->u_.case_.ncase = ncase;
|
|
|
|
|
|
|
|
|
|
stmt_cur_->u_.case_.case_ex = new ivl_expr_t[ncase];
|
|
|
|
|
stmt_cur_->u_.case_.case_st = new struct ivl_statement_s[ncase];
|
|
|
|
|
|
|
|
|
|
ivl_statement_t save_cur = stmt_cur_;
|
|
|
|
|
|
|
|
|
|
for (unsigned idx = 0 ; idx < ncase ; idx += 1) {
|
|
|
|
|
const NetExpr*ex = net->expr(idx);
|
|
|
|
|
if (ex) {
|
2001-04-15 05:14:31 +02:00
|
|
|
ex->expr_scan(this);
|
2001-03-31 19:36:38 +02:00
|
|
|
save_cur->u_.case_.case_ex[idx] = expr_;
|
|
|
|
|
expr_ = 0;
|
|
|
|
|
} else {
|
|
|
|
|
save_cur->u_.case_.case_ex[idx] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stmt_cur_ = save_cur->u_.case_.case_st + idx;
|
2001-06-22 01:23:14 +02:00
|
|
|
stmt_cur_->type_ = IVL_ST_NONE;
|
2001-04-15 05:14:31 +02:00
|
|
|
if (net->stat(idx) == 0) {
|
|
|
|
|
stmt_cur_->type_ = IVL_ST_NOOP;
|
|
|
|
|
} else {
|
|
|
|
|
net->stat(idx)->emit_proc(this);
|
|
|
|
|
}
|
2001-03-31 19:36:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stmt_cur_ = save_cur;
|
|
|
|
|
}
|
|
|
|
|
|
2001-10-30 03:52:07 +01:00
|
|
|
bool dll_target::proc_cassign(const NetCAssign*net)
|
|
|
|
|
{
|
2001-10-31 06:24:52 +01:00
|
|
|
|
|
|
|
|
assert(stmt_cur_);
|
|
|
|
|
assert(stmt_cur_->type_ == IVL_ST_NONE);
|
2007-12-22 15:31:24 +01:00
|
|
|
FILE_NAME(stmt_cur_, net);
|
2001-10-31 06:24:52 +01:00
|
|
|
|
|
|
|
|
stmt_cur_->type_ = IVL_ST_CASSIGN;
|
|
|
|
|
|
2004-12-11 03:31:25 +01:00
|
|
|
/* Make the l-value fields. */
|
|
|
|
|
make_assign_lvals_(net);
|
2001-10-31 06:24:52 +01:00
|
|
|
|
2004-12-11 03:31:25 +01:00
|
|
|
assert(expr_ == 0);
|
|
|
|
|
net->rval()->expr_scan(this);
|
|
|
|
|
stmt_cur_->u_.assign_.rval_ = expr_;
|
|
|
|
|
expr_ = 0;
|
2001-11-01 05:25:31 +01:00
|
|
|
|
2001-10-31 06:24:52 +01:00
|
|
|
return true;
|
2001-10-30 03:52:07 +01:00
|
|
|
}
|
|
|
|
|
|
2002-01-19 20:02:08 +01:00
|
|
|
bool dll_target::proc_condit(const NetCondit*net)
|
2000-09-18 03:24:32 +02:00
|
|
|
{
|
2008-07-31 03:01:41 +02:00
|
|
|
bool rc_flag = true;
|
|
|
|
|
|
2000-09-18 03:24:32 +02:00
|
|
|
assert(stmt_cur_);
|
|
|
|
|
assert(stmt_cur_->type_ == IVL_ST_NONE);
|
2007-12-22 15:31:24 +01:00
|
|
|
FILE_NAME(stmt_cur_, net);
|
2000-09-18 03:24:32 +02:00
|
|
|
|
|
|
|
|
stmt_cur_->type_ = IVL_ST_CONDIT;
|
|
|
|
|
stmt_cur_->u_.condit_.stmt_ = (struct ivl_statement_s*)
|
|
|
|
|
calloc(2, sizeof(struct ivl_statement_s));
|
|
|
|
|
|
2000-09-30 04:18:15 +02:00
|
|
|
assert(expr_ == 0);
|
|
|
|
|
net->expr()->expr_scan(this);
|
|
|
|
|
stmt_cur_->u_.condit_.cond_ = expr_;
|
2008-07-31 03:01:41 +02:00
|
|
|
if (expr_ == 0)
|
|
|
|
|
rc_flag = false;
|
2000-09-30 04:18:15 +02:00
|
|
|
expr_ = 0;
|
|
|
|
|
|
2000-09-18 03:24:32 +02:00
|
|
|
ivl_statement_t save_cur_ = stmt_cur_;
|
|
|
|
|
|
|
|
|
|
stmt_cur_ = save_cur_->u_.condit_.stmt_+0;
|
2008-07-31 03:01:41 +02:00
|
|
|
rc_flag = net->emit_recurse_if(this) && rc_flag;
|
2000-09-18 03:24:32 +02:00
|
|
|
|
|
|
|
|
stmt_cur_ = save_cur_->u_.condit_.stmt_+1;
|
2008-07-31 03:01:41 +02:00
|
|
|
rc_flag = net->emit_recurse_else(this) && rc_flag;
|
2000-09-18 03:24:32 +02:00
|
|
|
|
|
|
|
|
stmt_cur_ = save_cur_;
|
2008-07-31 03:01:41 +02:00
|
|
|
return rc_flag;
|
2000-09-18 03:24:32 +02:00
|
|
|
}
|
|
|
|
|
|
2001-10-30 03:52:07 +01:00
|
|
|
bool dll_target::proc_deassign(const NetDeassign*net)
|
|
|
|
|
{
|
2001-10-31 06:24:52 +01:00
|
|
|
assert(stmt_cur_);
|
|
|
|
|
assert(stmt_cur_->type_ == IVL_ST_NONE);
|
2007-12-22 15:31:24 +01:00
|
|
|
FILE_NAME(stmt_cur_, net);
|
2001-10-31 06:24:52 +01:00
|
|
|
|
|
|
|
|
stmt_cur_->type_ = IVL_ST_DEASSIGN;
|
|
|
|
|
|
2004-12-11 03:31:25 +01:00
|
|
|
/* Make the l-value fields. */
|
|
|
|
|
make_assign_lvals_(net);
|
2001-10-31 06:24:52 +01:00
|
|
|
|
|
|
|
|
return true;
|
2001-10-30 03:52:07 +01:00
|
|
|
}
|
|
|
|
|
|
2000-09-18 03:24:32 +02:00
|
|
|
bool dll_target::proc_delay(const NetPDelay*net)
|
|
|
|
|
{
|
|
|
|
|
assert(stmt_cur_);
|
|
|
|
|
assert(stmt_cur_->type_ == IVL_ST_NONE);
|
2007-12-22 15:31:24 +01:00
|
|
|
FILE_NAME(stmt_cur_, net);
|
2000-09-18 03:24:32 +02:00
|
|
|
|
|
|
|
|
ivl_statement_t tmp = (struct ivl_statement_s*)
|
|
|
|
|
calloc(1, sizeof(struct ivl_statement_s));
|
|
|
|
|
|
|
|
|
|
if (const NetExpr*expr = net->expr()) {
|
|
|
|
|
|
|
|
|
|
stmt_cur_->type_ = IVL_ST_DELAYX;
|
2001-07-19 06:55:06 +02:00
|
|
|
assert(expr_ == 0);
|
|
|
|
|
expr->expr_scan(this);
|
|
|
|
|
stmt_cur_->u_.delayx_.expr = expr_;
|
|
|
|
|
expr_ = 0;
|
|
|
|
|
|
2000-09-18 03:24:32 +02:00
|
|
|
stmt_cur_->u_.delayx_.stmt_ = tmp;
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
stmt_cur_->type_ = IVL_ST_DELAY;
|
|
|
|
|
stmt_cur_->u_.delay_.stmt_ = tmp;
|
2009-02-17 01:44:52 +01:00
|
|
|
stmt_cur_->u_.delay_.value = net->delay();
|
2000-09-18 03:24:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ivl_statement_t save_cur_ = stmt_cur_;
|
|
|
|
|
stmt_cur_ = tmp;
|
|
|
|
|
bool flag = net->emit_proc_recurse(this);
|
2000-09-19 06:15:27 +02:00
|
|
|
|
|
|
|
|
/* If the recurse doesn't turn this new item into something,
|
|
|
|
|
then either it failed or there is no statement
|
|
|
|
|
there. Either way, draw a no-op into the statement. */
|
|
|
|
|
if (stmt_cur_->type_ == IVL_ST_NONE) {
|
|
|
|
|
stmt_cur_->type_ = IVL_ST_NOOP;
|
|
|
|
|
}
|
|
|
|
|
|
2000-09-18 03:24:32 +02:00
|
|
|
stmt_cur_ = save_cur_;
|
|
|
|
|
|
|
|
|
|
return flag;
|
|
|
|
|
}
|
|
|
|
|
|
2001-04-07 21:24:36 +02:00
|
|
|
bool dll_target::proc_disable(const NetDisable*net)
|
|
|
|
|
{
|
|
|
|
|
assert(stmt_cur_);
|
|
|
|
|
assert(stmt_cur_->type_ == IVL_ST_NONE);
|
2007-12-22 15:31:24 +01:00
|
|
|
FILE_NAME(stmt_cur_, net);
|
2001-04-07 21:24:36 +02:00
|
|
|
|
|
|
|
|
stmt_cur_->type_ = IVL_ST_DISABLE;
|
2013-10-18 04:33:57 +02:00
|
|
|
const NetScope* dis_scope = net->target();
|
|
|
|
|
/* A normal disable. */
|
|
|
|
|
if (dis_scope) stmt_cur_->u_.disable_.scope = lookup_scope_(dis_scope);
|
|
|
|
|
/* A SystemVerilog disable fork. */
|
|
|
|
|
else stmt_cur_->u_.disable_.scope = 0;
|
2001-04-07 21:24:36 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-17 05:01:06 +02:00
|
|
|
void dll_target::proc_do_while(const NetDoWhile*net)
|
|
|
|
|
{
|
|
|
|
|
assert(stmt_cur_);
|
|
|
|
|
assert(stmt_cur_->type_ == IVL_ST_NONE);
|
|
|
|
|
FILE_NAME(stmt_cur_, net);
|
|
|
|
|
|
|
|
|
|
stmt_cur_->type_ = IVL_ST_DO_WHILE;
|
|
|
|
|
stmt_cur_->u_.while_.stmt_ = (struct ivl_statement_s*)
|
|
|
|
|
calloc(1, sizeof(struct ivl_statement_s));
|
|
|
|
|
|
|
|
|
|
assert(expr_ == 0);
|
|
|
|
|
net->expr()->expr_scan(this);
|
|
|
|
|
stmt_cur_->u_.while_.cond_ = expr_;
|
|
|
|
|
expr_ = 0;
|
|
|
|
|
|
|
|
|
|
/* Now generate the statement of the do/while loop. We know it is
|
|
|
|
|
a single statement, and we know that the
|
|
|
|
|
emit_proc_recurse() will call emit_proc() for it. */
|
|
|
|
|
|
|
|
|
|
ivl_statement_t save_cur_ = stmt_cur_;
|
|
|
|
|
stmt_cur_ = save_cur_->u_.while_.stmt_;
|
|
|
|
|
net->emit_proc_recurse(this);
|
|
|
|
|
stmt_cur_ = save_cur_;
|
|
|
|
|
}
|
|
|
|
|
|
2001-11-14 04:28:49 +01:00
|
|
|
bool dll_target::proc_force(const NetForce*net)
|
|
|
|
|
{
|
2004-12-11 03:31:25 +01:00
|
|
|
|
2001-11-14 04:28:49 +01:00
|
|
|
assert(stmt_cur_);
|
|
|
|
|
assert(stmt_cur_->type_ == IVL_ST_NONE);
|
2011-02-07 04:47:11 +01:00
|
|
|
FILE_NAME(stmt_cur_, net);
|
2001-11-14 04:28:49 +01:00
|
|
|
|
|
|
|
|
stmt_cur_->type_ = IVL_ST_FORCE;
|
|
|
|
|
|
2004-12-11 03:31:25 +01:00
|
|
|
/* Make the l-value fields. */
|
|
|
|
|
make_assign_lvals_(net);
|
2001-11-14 04:28:49 +01:00
|
|
|
|
2004-12-11 03:31:25 +01:00
|
|
|
assert(expr_ == 0);
|
|
|
|
|
net->rval()->expr_scan(this);
|
|
|
|
|
stmt_cur_->u_.assign_.rval_ = expr_;
|
|
|
|
|
expr_ = 0;
|
2001-11-14 04:28:49 +01:00
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2001-04-07 21:24:36 +02:00
|
|
|
|
2001-04-04 06:50:35 +02:00
|
|
|
void dll_target::proc_forever(const NetForever*net)
|
|
|
|
|
{
|
|
|
|
|
assert(stmt_cur_);
|
|
|
|
|
assert(stmt_cur_->type_ == IVL_ST_NONE);
|
2007-12-22 15:31:24 +01:00
|
|
|
FILE_NAME(stmt_cur_, net);
|
2001-04-04 06:50:35 +02:00
|
|
|
|
|
|
|
|
stmt_cur_->type_ = IVL_ST_FOREVER;
|
|
|
|
|
|
|
|
|
|
ivl_statement_t tmp = (struct ivl_statement_s*)
|
|
|
|
|
calloc(1, sizeof(struct ivl_statement_s));
|
|
|
|
|
|
|
|
|
|
ivl_statement_t save_cur_ = stmt_cur_;
|
|
|
|
|
stmt_cur_ = tmp;
|
|
|
|
|
|
|
|
|
|
net->emit_recurse(this);
|
|
|
|
|
|
|
|
|
|
save_cur_->u_.forever_.stmt_ = stmt_cur_;
|
|
|
|
|
stmt_cur_ = save_cur_;
|
|
|
|
|
}
|
|
|
|
|
|
2008-09-27 01:54:13 +02:00
|
|
|
void dll_target::proc_free(const NetFree*net)
|
|
|
|
|
{
|
|
|
|
|
assert(stmt_cur_);
|
|
|
|
|
assert(stmt_cur_->type_ == IVL_ST_NONE);
|
|
|
|
|
FILE_NAME(stmt_cur_, net);
|
|
|
|
|
|
|
|
|
|
stmt_cur_->type_ = IVL_ST_FREE;
|
|
|
|
|
stmt_cur_->u_.free_.scope = lookup_scope_(net->scope());
|
|
|
|
|
}
|
|
|
|
|
|
2001-11-14 04:28:49 +01:00
|
|
|
bool dll_target::proc_release(const NetRelease*net)
|
|
|
|
|
{
|
|
|
|
|
assert(stmt_cur_);
|
|
|
|
|
assert(stmt_cur_->type_ == IVL_ST_NONE);
|
2007-12-22 15:31:24 +01:00
|
|
|
FILE_NAME(stmt_cur_, net);
|
2001-11-14 04:28:49 +01:00
|
|
|
|
|
|
|
|
stmt_cur_->type_ = IVL_ST_RELEASE;
|
|
|
|
|
|
2004-12-11 03:31:25 +01:00
|
|
|
/* Make the l-value fields. */
|
|
|
|
|
make_assign_lvals_(net);
|
2001-11-14 04:28:49 +01:00
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2001-04-05 05:20:57 +02:00
|
|
|
void dll_target::proc_repeat(const NetRepeat*net)
|
|
|
|
|
{
|
|
|
|
|
assert(stmt_cur_);
|
|
|
|
|
assert(stmt_cur_->type_ == IVL_ST_NONE);
|
2007-12-22 15:31:24 +01:00
|
|
|
FILE_NAME(stmt_cur_, net);
|
2001-04-05 05:20:57 +02:00
|
|
|
|
|
|
|
|
stmt_cur_->type_ = IVL_ST_REPEAT;
|
|
|
|
|
|
|
|
|
|
assert(expr_ == 0);
|
|
|
|
|
net->expr()->expr_scan(this);
|
|
|
|
|
stmt_cur_->u_.while_.cond_ = expr_;
|
|
|
|
|
expr_ = 0;
|
|
|
|
|
|
|
|
|
|
ivl_statement_t tmp = (struct ivl_statement_s*)
|
|
|
|
|
calloc(1, sizeof(struct ivl_statement_s));
|
|
|
|
|
|
|
|
|
|
ivl_statement_t save_cur_ = stmt_cur_;
|
|
|
|
|
stmt_cur_ = tmp;
|
|
|
|
|
|
|
|
|
|
net->emit_recurse(this);
|
|
|
|
|
|
|
|
|
|
save_cur_->u_.while_.stmt_ = stmt_cur_;
|
|
|
|
|
stmt_cur_ = save_cur_;
|
|
|
|
|
}
|
|
|
|
|
|
2000-09-19 06:15:27 +02:00
|
|
|
void dll_target::proc_stask(const NetSTask*net)
|
|
|
|
|
{
|
2000-09-23 07:15:07 +02:00
|
|
|
unsigned nparms = net->nparms();
|
2000-09-19 06:15:27 +02:00
|
|
|
assert(stmt_cur_);
|
|
|
|
|
assert(stmt_cur_->type_ == IVL_ST_NONE);
|
2007-12-22 15:31:24 +01:00
|
|
|
FILE_NAME(stmt_cur_, net);
|
2000-09-19 06:15:27 +02:00
|
|
|
|
|
|
|
|
stmt_cur_->type_ = IVL_ST_STASK;
|
2003-03-01 07:25:30 +01:00
|
|
|
/* System task names are lex_strings strings. */
|
|
|
|
|
stmt_cur_->u_.stask_.name_ = net->name();
|
2010-08-12 04:01:58 +02:00
|
|
|
stmt_cur_->u_.stask_.sfunc_as_task_ = net->sfunc_as_task();
|
2000-09-23 07:15:07 +02:00
|
|
|
stmt_cur_->u_.stask_.nparm_= nparms;
|
|
|
|
|
stmt_cur_->u_.stask_.parms_= (ivl_expr_t*)
|
|
|
|
|
calloc(nparms, sizeof(ivl_expr_t));
|
|
|
|
|
|
|
|
|
|
for (unsigned idx = 0 ; idx < nparms ; idx += 1) {
|
2000-10-05 07:03:01 +02:00
|
|
|
if (net->parm(idx))
|
|
|
|
|
net->parm(idx)->expr_scan(this);
|
2000-09-23 07:15:07 +02:00
|
|
|
stmt_cur_->u_.stask_.parms_[idx] = expr_;
|
2000-10-07 01:46:50 +02:00
|
|
|
expr_ = 0;
|
2000-09-23 07:15:07 +02:00
|
|
|
}
|
|
|
|
|
|
2000-09-19 06:15:27 +02:00
|
|
|
}
|
|
|
|
|
|
2000-09-26 02:30:07 +02:00
|
|
|
bool dll_target::proc_trigger(const NetEvTrig*net)
|
|
|
|
|
{
|
|
|
|
|
assert(stmt_cur_);
|
|
|
|
|
assert(stmt_cur_->type_ == IVL_ST_NONE);
|
2007-12-22 15:31:24 +01:00
|
|
|
FILE_NAME(stmt_cur_, net);
|
2000-09-26 02:30:07 +02:00
|
|
|
|
|
|
|
|
stmt_cur_->type_ = IVL_ST_TRIGGER;
|
2003-12-03 03:46:23 +01:00
|
|
|
stmt_cur_->u_.wait_.nevent = 1;
|
2001-03-29 05:47:38 +02:00
|
|
|
|
|
|
|
|
/* Locate the event by name. Save the ivl_event_t in the
|
|
|
|
|
statement so that the generator can find it easily. */
|
|
|
|
|
const NetEvent*ev = net->event();
|
|
|
|
|
ivl_scope_t ev_scope = lookup_scope_(ev->scope());
|
|
|
|
|
|
|
|
|
|
for (unsigned idx = 0 ; idx < ev_scope->nevent_ ; idx += 1) {
|
|
|
|
|
const char*ename = ivl_event_basename(ev_scope->event_[idx]);
|
|
|
|
|
if (strcmp(ev->name(), ename) == 0) {
|
2003-12-03 03:46:23 +01:00
|
|
|
stmt_cur_->u_.wait_.event = ev_scope->event_[idx];
|
2001-03-29 05:47:38 +02:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2000-09-26 02:30:07 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2001-04-02 04:28:12 +02:00
|
|
|
void dll_target::proc_utask(const NetUTask*net)
|
|
|
|
|
{
|
|
|
|
|
assert(stmt_cur_);
|
|
|
|
|
assert(stmt_cur_->type_ == IVL_ST_NONE);
|
2007-12-22 15:31:24 +01:00
|
|
|
FILE_NAME(stmt_cur_, net);
|
2001-04-02 04:28:12 +02:00
|
|
|
|
|
|
|
|
stmt_cur_->type_ = IVL_ST_UTASK;
|
|
|
|
|
stmt_cur_->u_.utask_.def = lookup_scope_(net->task());
|
|
|
|
|
}
|
|
|
|
|
|
2000-09-18 03:24:32 +02:00
|
|
|
bool dll_target::proc_wait(const NetEvWait*net)
|
|
|
|
|
{
|
|
|
|
|
assert(stmt_cur_);
|
|
|
|
|
assert(stmt_cur_->type_ == IVL_ST_NONE);
|
2007-12-22 15:31:24 +01:00
|
|
|
FILE_NAME(stmt_cur_, net);
|
2000-09-18 03:24:32 +02:00
|
|
|
|
|
|
|
|
stmt_cur_->type_ = IVL_ST_WAIT;
|
|
|
|
|
stmt_cur_->u_.wait_.stmt_ = (struct ivl_statement_s*)
|
|
|
|
|
calloc(1, sizeof(struct ivl_statement_s));
|
|
|
|
|
|
2003-12-03 03:46:23 +01:00
|
|
|
stmt_cur_->u_.wait_.nevent = net->nevents();
|
2013-10-22 18:39:25 +02:00
|
|
|
|
|
|
|
|
/* This is a wait fork statement. */
|
|
|
|
|
if ((net->nevents() == 1) && (net->event(0) == 0)) {
|
|
|
|
|
stmt_cur_->u_.wait_.event = 0;
|
|
|
|
|
stmt_cur_->type_ = IVL_ST_WAIT;
|
|
|
|
|
stmt_cur_->u_.wait_.stmt_->type_ = IVL_ST_NOOP;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// This event processing code is also in the NB assign above.
|
2003-12-03 03:46:23 +01:00
|
|
|
if (net->nevents() > 1) {
|
|
|
|
|
stmt_cur_->u_.wait_.events = (ivl_event_t*)
|
|
|
|
|
calloc(net->nevents(), sizeof(ivl_event_t*));
|
2001-03-27 08:27:40 +02:00
|
|
|
}
|
|
|
|
|
|
2003-12-03 03:46:23 +01:00
|
|
|
for (unsigned edx = 0 ; edx < net->nevents() ; edx += 1) {
|
2001-03-27 08:27:40 +02:00
|
|
|
|
2003-12-03 03:46:23 +01:00
|
|
|
/* Locate the event by name. Save the ivl_event_t in the
|
|
|
|
|
statement so that the generator can find it easily. */
|
|
|
|
|
const NetEvent*ev = net->event(edx);
|
|
|
|
|
ivl_scope_t ev_scope = lookup_scope_(ev->scope());
|
2003-12-19 02:27:10 +01:00
|
|
|
ivl_event_t ev_tmp=0;
|
2001-03-27 08:27:40 +02:00
|
|
|
|
2007-06-02 05:42:12 +02:00
|
|
|
assert(ev_scope);
|
|
|
|
|
assert(ev_scope->nevent_ > 0);
|
2003-12-03 03:46:23 +01:00
|
|
|
for (unsigned idx = 0 ; idx < ev_scope->nevent_ ; idx += 1) {
|
|
|
|
|
const char*ename = ivl_event_basename(ev_scope->event_[idx]);
|
|
|
|
|
if (strcmp(ev->name(), ename) == 0) {
|
|
|
|
|
ev_tmp = ev_scope->event_[idx];
|
2001-04-01 03:48:21 +02:00
|
|
|
break;
|
|
|
|
|
}
|
2003-12-03 03:46:23 +01:00
|
|
|
}
|
2003-12-19 02:27:10 +01:00
|
|
|
// XXX should we assert(ev_tmp)?
|
2001-03-28 08:07:39 +02:00
|
|
|
|
2003-12-03 03:46:23 +01:00
|
|
|
if (net->nevents() == 1)
|
|
|
|
|
stmt_cur_->u_.wait_.event = ev_tmp;
|
|
|
|
|
else
|
|
|
|
|
stmt_cur_->u_.wait_.events[edx] = ev_tmp;
|
|
|
|
|
|
|
|
|
|
/* If this is an event with a probe, then connect up the
|
|
|
|
|
pins. This wasn't done during the ::event method because
|
|
|
|
|
the signals weren't scanned yet. */
|
|
|
|
|
|
|
|
|
|
if (ev->nprobe() >= 1) {
|
|
|
|
|
unsigned iany = 0;
|
|
|
|
|
unsigned ineg = ev_tmp->nany;
|
|
|
|
|
unsigned ipos = ineg + ev_tmp->nneg;
|
|
|
|
|
|
|
|
|
|
for (unsigned idx = 0 ; idx < ev->nprobe() ; idx += 1) {
|
|
|
|
|
const NetEvProbe*pr = ev->probe(idx);
|
|
|
|
|
unsigned base = 0;
|
|
|
|
|
|
|
|
|
|
switch (pr->edge()) {
|
|
|
|
|
case NetEvProbe::ANYEDGE:
|
|
|
|
|
base = iany;
|
|
|
|
|
iany += pr->pin_count();
|
|
|
|
|
break;
|
|
|
|
|
case NetEvProbe::NEGEDGE:
|
|
|
|
|
base = ineg;
|
|
|
|
|
ineg += pr->pin_count();
|
|
|
|
|
break;
|
|
|
|
|
case NetEvProbe::POSEDGE:
|
|
|
|
|
base = ipos;
|
|
|
|
|
ipos += pr->pin_count();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (unsigned bit = 0
|
|
|
|
|
; bit < pr->pin_count()
|
|
|
|
|
; bit += 1) {
|
|
|
|
|
ivl_nexus_t nex = (ivl_nexus_t)
|
|
|
|
|
pr->pin(bit).nexus()->t_cookie();
|
|
|
|
|
assert(nex);
|
|
|
|
|
ev_tmp->pins[base+bit] = nex;
|
|
|
|
|
}
|
2001-04-01 03:48:21 +02:00
|
|
|
}
|
2001-03-28 08:07:39 +02:00
|
|
|
}
|
2004-10-04 03:10:51 +02:00
|
|
|
}
|
2001-03-27 08:27:40 +02:00
|
|
|
|
2001-03-31 01:24:02 +02:00
|
|
|
/* The ivl_statement_t for the wait statement is not complete
|
|
|
|
|
until we calculate the sub-statement. */
|
|
|
|
|
|
2000-09-18 03:24:32 +02:00
|
|
|
ivl_statement_t save_cur_ = stmt_cur_;
|
|
|
|
|
stmt_cur_ = stmt_cur_->u_.wait_.stmt_;
|
|
|
|
|
bool flag = net->emit_recurse(this);
|
2001-03-31 01:24:02 +02:00
|
|
|
if (flag && (stmt_cur_->type_ == IVL_ST_NONE))
|
|
|
|
|
stmt_cur_->type_ = IVL_ST_NOOP;
|
|
|
|
|
|
2000-09-19 06:15:27 +02:00
|
|
|
stmt_cur_ = save_cur_;
|
2000-09-18 03:24:32 +02:00
|
|
|
|
|
|
|
|
return flag;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void dll_target::proc_while(const NetWhile*net)
|
|
|
|
|
{
|
|
|
|
|
assert(stmt_cur_);
|
|
|
|
|
assert(stmt_cur_->type_ == IVL_ST_NONE);
|
2007-12-22 15:31:24 +01:00
|
|
|
FILE_NAME(stmt_cur_, net);
|
2000-09-18 03:24:32 +02:00
|
|
|
|
|
|
|
|
stmt_cur_->type_ = IVL_ST_WHILE;
|
|
|
|
|
stmt_cur_->u_.while_.stmt_ = (struct ivl_statement_s*)
|
|
|
|
|
calloc(1, sizeof(struct ivl_statement_s));
|
|
|
|
|
|
2001-04-01 08:52:27 +02:00
|
|
|
assert(expr_ == 0);
|
|
|
|
|
net->expr()->expr_scan(this);
|
|
|
|
|
stmt_cur_->u_.while_.cond_ = expr_;
|
|
|
|
|
expr_ = 0;
|
2000-09-18 03:24:32 +02:00
|
|
|
|
|
|
|
|
/* Now generate the statement of the while loop. We know it is
|
|
|
|
|
a single statement, and we know that the
|
|
|
|
|
emit_proc_recurse() will call emit_proc() for it. */
|
|
|
|
|
|
|
|
|
|
ivl_statement_t save_cur_ = stmt_cur_;
|
|
|
|
|
stmt_cur_ = save_cur_->u_.while_.stmt_;
|
|
|
|
|
net->emit_proc_recurse(this);
|
|
|
|
|
stmt_cur_ = save_cur_;
|
|
|
|
|
}
|