2002-04-21 06:59:07 +02:00
|
|
|
/*
|
2025-10-21 07:45:05 +02:00
|
|
|
* Copyright (c) 2002-2025 Stephen Williams (steve@icarus.com)
|
2002-04-21 06:59:07 +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.
|
|
|
|
|
*
|
|
|
|
|
* 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.
|
2002-04-21 06:59:07 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
# include "config.h"
|
|
|
|
|
|
2019-09-30 05:17:45 +02:00
|
|
|
# include <iostream>
|
|
|
|
|
# include <set>
|
2002-04-21 06:59:07 +02:00
|
|
|
# include <cassert>
|
|
|
|
|
# include <typeinfo>
|
2009-09-05 11:15:10 +02:00
|
|
|
# include "compiler.h"
|
2002-04-21 06:59:07 +02:00
|
|
|
# include "netlist.h"
|
|
|
|
|
# include "netmisc.h"
|
|
|
|
|
|
2021-11-04 17:12:04 +01:00
|
|
|
using namespace std;
|
|
|
|
|
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetExpr::nex_input(bool, bool, bool) const
|
2002-04-21 06:59:07 +02:00
|
|
|
{
|
2007-12-20 18:31:01 +01:00
|
|
|
cerr << get_fileline()
|
2002-04-21 06:59:07 +02:00
|
|
|
<< ": internal error: nex_input not implemented: "
|
|
|
|
|
<< *this << endl;
|
2017-12-27 23:41:43 +01:00
|
|
|
return new NexusSet;
|
2002-04-21 06:59:07 +02:00
|
|
|
}
|
|
|
|
|
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetProc::nex_input(bool, bool, bool) const
|
2002-04-21 06:59:07 +02:00
|
|
|
{
|
2007-12-20 18:31:01 +01:00
|
|
|
cerr << get_fileline()
|
2002-04-21 06:59:07 +02:00
|
|
|
<< ": internal error: NetProc::nex_input not implemented"
|
|
|
|
|
<< endl;
|
2017-12-27 23:41:43 +01:00
|
|
|
return new NexusSet;
|
2002-04-21 06:59:07 +02:00
|
|
|
}
|
|
|
|
|
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetEArrayPattern::nex_input(bool rem_out, bool always_sens, bool nested_func) const
|
2013-10-10 05:15:10 +02:00
|
|
|
{
|
|
|
|
|
NexusSet*result = new NexusSet;
|
|
|
|
|
for (size_t idx = 0 ; idx < items_.size() ; idx += 1) {
|
|
|
|
|
if (items_[idx]==0) continue;
|
|
|
|
|
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet*tmp = items_[idx]->nex_input(rem_out, always_sens, nested_func);
|
2013-10-10 05:15:10 +02:00
|
|
|
if (tmp == 0) continue;
|
|
|
|
|
|
|
|
|
|
result->add(*tmp);
|
|
|
|
|
delete tmp;
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetEBinary::nex_input(bool rem_out, bool always_sens, bool nested_func) const
|
2002-04-21 06:59:07 +02:00
|
|
|
{
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet*result = left_->nex_input(rem_out, always_sens, nested_func);
|
|
|
|
|
NexusSet*tmp = right_->nex_input(rem_out, always_sens, nested_func);
|
2002-04-21 06:59:07 +02:00
|
|
|
result->add(*tmp);
|
|
|
|
|
delete tmp;
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetEConcat::nex_input(bool rem_out, bool always_sens, bool nested_func) const
|
2002-04-21 06:59:07 +02:00
|
|
|
{
|
2017-12-27 23:41:43 +01:00
|
|
|
if (parms_[0] == NULL) return new NexusSet;
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet*result = parms_[0]->nex_input(rem_out, always_sens, nested_func);
|
2012-06-25 00:33:40 +02:00
|
|
|
for (unsigned idx = 1 ; idx < parms_.size() ; idx += 1) {
|
2008-08-14 21:40:53 +02:00
|
|
|
if (parms_[idx] == NULL) {
|
|
|
|
|
delete result;
|
2017-12-27 23:41:43 +01:00
|
|
|
return new NexusSet;
|
2008-08-14 21:40:53 +02:00
|
|
|
}
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet*tmp = parms_[idx]->nex_input(rem_out, always_sens, nested_func);
|
2002-04-21 06:59:07 +02:00
|
|
|
result->add(*tmp);
|
|
|
|
|
delete tmp;
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetEAccess::nex_input(bool, bool, bool) const
|
2008-07-31 03:01:41 +02:00
|
|
|
{
|
|
|
|
|
return new NexusSet;
|
|
|
|
|
}
|
|
|
|
|
|
2002-04-21 06:59:07 +02:00
|
|
|
/*
|
|
|
|
|
* A constant has not inputs, so always return an empty set.
|
|
|
|
|
*/
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetEConst::nex_input(bool, bool, bool) const
|
2002-04-21 06:59:07 +02:00
|
|
|
{
|
|
|
|
|
return new NexusSet;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetECReal::nex_input(bool, bool, bool) const
|
2003-01-26 22:15:58 +01:00
|
|
|
{
|
|
|
|
|
return new NexusSet;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetEEvent::nex_input(bool, bool, bool) const
|
2003-04-22 06:48:29 +02:00
|
|
|
{
|
|
|
|
|
return new NexusSet;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetELast::nex_input(bool, bool, bool) const
|
2014-08-17 01:11:40 +02:00
|
|
|
{
|
|
|
|
|
return new NexusSet;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetENetenum::nex_input(bool, bool, bool) const
|
2010-11-21 00:09:32 +01:00
|
|
|
{
|
|
|
|
|
return new NexusSet;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetENew::nex_input(bool, bool, bool) const
|
2012-11-17 18:20:13 +01:00
|
|
|
{
|
|
|
|
|
return new NexusSet;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetENull::nex_input(bool, bool, bool) const
|
2012-11-12 02:42:31 +01:00
|
|
|
{
|
|
|
|
|
return new NexusSet;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetEProperty::nex_input(bool, bool, bool) const
|
2012-11-25 19:13:05 +01:00
|
|
|
{
|
|
|
|
|
return new NexusSet;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetEScope::nex_input(bool, bool, bool) const
|
2002-04-21 06:59:07 +02:00
|
|
|
{
|
|
|
|
|
return new NexusSet;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetESelect::nex_input(bool rem_out, bool always_sens, bool nested_func) const
|
2019-09-30 01:57:09 +02:00
|
|
|
{
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet*result = base_? base_->nex_input(rem_out, always_sens, nested_func) : new NexusSet();
|
|
|
|
|
NexusSet*tmp = expr_->nex_input(rem_out, always_sens, nested_func);
|
2019-09-30 01:57:09 +02:00
|
|
|
bool const_select = result->size() == 0;
|
|
|
|
|
if (always_sens && const_select) {
|
2025-10-21 07:45:05 +02:00
|
|
|
if (const NetEConst *val = dynamic_cast <NetEConst*> (base_)) {
|
2019-09-30 01:57:09 +02:00
|
|
|
assert(select_type() == IVL_SEL_OTHER);
|
2025-10-21 07:45:05 +02:00
|
|
|
if (const NetESignal *sig = dynamic_cast<NetESignal*> (expr_)) {
|
2019-09-30 01:57:09 +02:00
|
|
|
delete tmp;
|
2019-10-28 21:21:09 +01:00
|
|
|
tmp = sig->nex_input_base(rem_out, always_sens, nested_func,
|
|
|
|
|
val->value().as_unsigned(), expr_width());
|
2019-09-30 01:57:09 +02:00
|
|
|
} else {
|
|
|
|
|
cerr << get_fileline() << ": Sorry, cannot determine the sensitivity "
|
|
|
|
|
<< "for the select of " << *expr_ << ", using all bits." << endl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-04-21 06:59:07 +02:00
|
|
|
result->add(*tmp);
|
|
|
|
|
delete tmp;
|
2009-06-19 19:11:57 +02:00
|
|
|
/* See the comment for NetESignal below. */
|
2019-09-30 01:57:09 +02:00
|
|
|
if (base_ && ! always_sens && warn_sens_entire_vec) {
|
2009-06-19 19:11:57 +02:00
|
|
|
cerr << get_fileline() << ": warning: @* is sensitive to all "
|
|
|
|
|
"bits in '" << *expr_ << "'." << endl;
|
|
|
|
|
}
|
2002-04-21 06:59:07 +02:00
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-16 23:36:53 +01:00
|
|
|
/*
|
|
|
|
|
* The $fread, etc. system functions can have NULL arguments.
|
|
|
|
|
*/
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetESFunc::nex_input(bool rem_out, bool always_sens, bool nested_func) const
|
2002-04-21 06:59:07 +02:00
|
|
|
{
|
2017-12-27 23:41:43 +01:00
|
|
|
NexusSet*result = new NexusSet;
|
2002-04-21 06:59:07 +02:00
|
|
|
|
2017-12-27 23:41:43 +01:00
|
|
|
if (parms_.empty()) return result;
|
|
|
|
|
|
|
|
|
|
for (unsigned idx = 0 ; idx < parms_.size() ; idx += 1) {
|
2010-11-16 23:36:53 +01:00
|
|
|
if (parms_[idx]) {
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet*tmp = parms_[idx]->nex_input(rem_out, always_sens, nested_func);
|
2010-11-16 23:36:53 +01:00
|
|
|
result->add(*tmp);
|
|
|
|
|
delete tmp;
|
|
|
|
|
}
|
2002-04-21 06:59:07 +02:00
|
|
|
}
|
2017-12-27 23:41:43 +01:00
|
|
|
|
2002-04-21 06:59:07 +02:00
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetEShallowCopy::nex_input(bool, bool, bool) const
|
2013-04-28 04:54:13 +02:00
|
|
|
{
|
|
|
|
|
return new NexusSet;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetESignal::nex_input(bool rem_out, bool always_sens, bool nested_func) const
|
2019-09-30 01:57:09 +02:00
|
|
|
{
|
2019-10-28 21:21:09 +01:00
|
|
|
return nex_input_base(rem_out, always_sens, nested_func, 0, 0);
|
2019-09-30 01:57:09 +02:00
|
|
|
}
|
|
|
|
|
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetESignal::nex_input_base(bool rem_out, bool always_sens, bool nested_func,
|
|
|
|
|
unsigned base, unsigned width) const
|
2002-04-21 06:59:07 +02:00
|
|
|
{
|
2009-06-19 19:11:57 +02:00
|
|
|
/*
|
|
|
|
|
* This is not what I would expect for the various selects (bit,
|
|
|
|
|
* part, index, array). This code adds all the bits/array words
|
|
|
|
|
* instead of building the appropriate select and then using it
|
|
|
|
|
* as the trigger. Other simulators also add everything.
|
|
|
|
|
*/
|
2019-09-30 01:57:09 +02:00
|
|
|
bool const_select = false;
|
|
|
|
|
unsigned const_word = 0;
|
2002-04-21 06:59:07 +02:00
|
|
|
NexusSet*result = new NexusSet;
|
2011-01-31 08:24:47 +01:00
|
|
|
/* Local signals are not added to the sensitivity list. */
|
|
|
|
|
if (net_->local_flag()) return result;
|
2009-06-19 19:11:57 +02:00
|
|
|
/* If we have an array index add it to the sensitivity list. */
|
|
|
|
|
if (word_) {
|
|
|
|
|
NexusSet*tmp;
|
2019-10-28 21:21:09 +01:00
|
|
|
tmp = word_->nex_input(rem_out, always_sens, nested_func);
|
2009-06-19 19:11:57 +02:00
|
|
|
result->add(*tmp);
|
|
|
|
|
delete tmp;
|
2019-09-30 01:57:09 +02:00
|
|
|
if (!always_sens && warn_sens_entire_arr) {
|
2009-09-05 11:15:10 +02:00
|
|
|
cerr << get_fileline() << ": warning: @* is sensitive to all "
|
2012-05-26 00:58:29 +02:00
|
|
|
<< net_->unpacked_count() << " words in array '"
|
2009-09-05 11:15:10 +02:00
|
|
|
<< name() << "'." << endl;
|
|
|
|
|
}
|
2025-10-21 07:45:05 +02:00
|
|
|
if (always_sens) if (const NetEConst *val = dynamic_cast <NetEConst*> (word_)) {
|
2019-09-30 01:57:09 +02:00
|
|
|
const_select = true;
|
|
|
|
|
const_word = val->value().as_unsigned();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((base == 0) && (width == 0)) width = net_->vector_width();
|
|
|
|
|
|
|
|
|
|
if (const_select) {
|
|
|
|
|
result->add(net_->pin(const_word).nexus(), base, width);
|
|
|
|
|
} else {
|
|
|
|
|
for (unsigned idx = 0 ; idx < net_->pin_count() ; idx += 1)
|
|
|
|
|
result->add(net_->pin(idx).nexus(), base, width);
|
2009-06-19 19:11:57 +02:00
|
|
|
}
|
2002-04-21 06:59:07 +02:00
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetETernary::nex_input(bool rem_out, bool always_sens, bool nested_func) const
|
2002-04-21 06:59:07 +02:00
|
|
|
{
|
|
|
|
|
NexusSet*tmp;
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet*result = cond_->nex_input(rem_out, always_sens, nested_func);
|
2002-04-21 06:59:07 +02:00
|
|
|
|
2019-10-28 21:21:09 +01:00
|
|
|
tmp = true_val_->nex_input(rem_out, always_sens, nested_func);
|
2002-04-21 06:59:07 +02:00
|
|
|
result->add(*tmp);
|
|
|
|
|
delete tmp;
|
|
|
|
|
|
2019-10-28 21:21:09 +01:00
|
|
|
tmp = false_val_->nex_input(rem_out, always_sens, nested_func);
|
2002-04-21 06:59:07 +02:00
|
|
|
result->add(*tmp);
|
|
|
|
|
delete tmp;
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-13 14:47:24 +02:00
|
|
|
// Get the contribution of a function call in a always_comb block
|
|
|
|
|
static void func_always_sens(NetFuncDef *func, NexusSet *result,
|
|
|
|
|
bool rem_out, bool nested_func)
|
|
|
|
|
{
|
|
|
|
|
// Avoid recursive function calls.
|
|
|
|
|
static set<NetFuncDef*> func_set;
|
|
|
|
|
if (!nested_func)
|
|
|
|
|
func_set.clear();
|
|
|
|
|
|
|
|
|
|
if (!func_set.insert(func).second)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<NexusSet> tmp(func->proc()->nex_input(rem_out, true, true));
|
|
|
|
|
// Remove the function inputs
|
|
|
|
|
std::unique_ptr<NexusSet> in(new NexusSet);
|
|
|
|
|
for (unsigned idx = 0; idx < func->port_count(); idx++) {
|
|
|
|
|
NetNet *net = func->port(idx);
|
|
|
|
|
assert(net->pin_count() == 1);
|
|
|
|
|
in->add(net->pin(0).nexus(), 0, net->vector_width());
|
|
|
|
|
}
|
|
|
|
|
tmp->rem(*in);
|
|
|
|
|
result->add(*tmp);
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetEUFunc::nex_input(bool rem_out, bool always_sens, bool nested_func) const
|
2002-04-21 06:59:07 +02:00
|
|
|
{
|
|
|
|
|
NexusSet*result = new NexusSet;
|
2019-09-30 05:17:45 +02:00
|
|
|
|
2012-05-29 01:49:41 +02:00
|
|
|
for (unsigned idx = 0 ; idx < parms_.size() ; idx += 1) {
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet*tmp = parms_[idx]->nex_input(rem_out, always_sens, nested_func);
|
2017-11-20 16:48:35 +01:00
|
|
|
result->add(*tmp);
|
|
|
|
|
delete tmp;
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-13 14:47:24 +02:00
|
|
|
if (always_sens)
|
|
|
|
|
func_always_sens(func_->func_def(), result, rem_out, nested_func);
|
2002-04-21 06:59:07 +02:00
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetEUnary::nex_input(bool rem_out, bool always_sens, bool nested_func) const
|
2002-04-21 06:59:07 +02:00
|
|
|
{
|
2019-10-28 21:21:09 +01:00
|
|
|
return expr_->nex_input(rem_out, always_sens, nested_func);
|
2002-04-21 06:59:07 +02:00
|
|
|
}
|
|
|
|
|
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetAlloc::nex_input(bool, bool, bool) const
|
2017-12-27 23:41:43 +01:00
|
|
|
{
|
|
|
|
|
return new NexusSet;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetAssign_::nex_input(bool rem_out, bool always_sens, bool nested_func) const
|
2004-09-04 06:24:15 +02:00
|
|
|
{
|
2017-12-27 23:41:43 +01:00
|
|
|
assert(! nest_);
|
2006-04-16 02:15:43 +02:00
|
|
|
NexusSet*result = new NexusSet;
|
2017-12-27 23:41:43 +01:00
|
|
|
|
2007-01-16 06:44:14 +01:00
|
|
|
if (word_) {
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet*tmp = word_->nex_input(rem_out, always_sens, nested_func);
|
2006-04-16 02:15:43 +02:00
|
|
|
result->add(*tmp);
|
|
|
|
|
delete tmp;
|
|
|
|
|
}
|
|
|
|
|
if (base_) {
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet*tmp = base_->nex_input(rem_out, always_sens, nested_func);
|
2006-04-16 02:15:43 +02:00
|
|
|
result->add(*tmp);
|
|
|
|
|
delete tmp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
2004-09-04 06:24:15 +02:00
|
|
|
}
|
|
|
|
|
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetAssignBase::nex_input(bool rem_out, bool always_sens, bool nested_func) const
|
2002-04-21 06:59:07 +02:00
|
|
|
{
|
2017-12-27 23:41:43 +01:00
|
|
|
NexusSet*result = new NexusSet;
|
|
|
|
|
// For the deassign and release statements there is no R-value.
|
|
|
|
|
if (rval_) {
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet*tmp = rval_->nex_input(rem_out, always_sens, nested_func);
|
2017-12-27 23:41:43 +01:00
|
|
|
result->add(*tmp);
|
|
|
|
|
delete tmp;
|
|
|
|
|
}
|
2004-09-04 06:24:15 +02:00
|
|
|
|
2008-01-29 21:19:59 +01:00
|
|
|
/* It is possible that the lval_ can have nex_input values. In
|
2004-09-04 06:24:15 +02:00
|
|
|
particular, index expressions are statement inputs as well,
|
|
|
|
|
so should be addressed here. */
|
2025-10-21 07:45:05 +02:00
|
|
|
for (const NetAssign_*cur = lval_ ; cur ; cur = cur->more) {
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet*tmp = cur->nex_input(rem_out, always_sens, nested_func);
|
2004-09-04 06:24:15 +02:00
|
|
|
result->add(*tmp);
|
|
|
|
|
delete tmp;
|
|
|
|
|
}
|
|
|
|
|
|
2002-04-21 19:43:12 +02:00
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2002-08-19 00:07:16 +02:00
|
|
|
/*
|
|
|
|
|
* The nex_input of a begin/end block is the NexusSet of bits that the
|
|
|
|
|
* block reads from outside the block. That means it is the union of
|
|
|
|
|
* the nex_input for all the substatements.
|
|
|
|
|
*
|
|
|
|
|
* The input set for a sequential set is not exactly the union of the
|
|
|
|
|
* input sets because there is the possibility of intermediate values,
|
|
|
|
|
* that don't deserve to be in the input set. To wit:
|
|
|
|
|
*
|
|
|
|
|
* begin
|
|
|
|
|
* t = a + b;
|
|
|
|
|
* c = ~t;
|
|
|
|
|
* end
|
|
|
|
|
*
|
|
|
|
|
* In this example, "t" should not be in the input set because it is
|
|
|
|
|
* used by the sequence as a temporary value.
|
|
|
|
|
*/
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetBlock::nex_input(bool rem_out, bool always_sens, bool nested_func) const
|
2002-04-21 19:43:12 +02:00
|
|
|
{
|
2017-12-27 23:41:43 +01:00
|
|
|
if (last_ == 0) return new NexusSet;
|
2002-04-21 19:43:12 +02:00
|
|
|
|
2019-09-30 01:57:09 +02:00
|
|
|
if (! always_sens && (type_ != SEQU)) {
|
2007-12-20 18:31:01 +01:00
|
|
|
cerr << get_fileline() << ": internal error: Sorry, "
|
2002-08-19 00:07:16 +02:00
|
|
|
<< "I don't know how to synthesize fork/join blocks."
|
|
|
|
|
<< endl;
|
2017-12-27 23:41:43 +01:00
|
|
|
return new NexusSet;
|
2002-08-19 00:07:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetProc*cur = last_->next_;
|
|
|
|
|
/* This is the accumulated input set. */
|
|
|
|
|
NexusSet*result = new NexusSet;
|
|
|
|
|
/* This is an accumulated output set. */
|
|
|
|
|
NexusSet*prev = new NexusSet;
|
|
|
|
|
|
|
|
|
|
do {
|
|
|
|
|
/* Get the inputs for the current statement. */
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet*tmp = cur->nex_input(rem_out, always_sens, nested_func);
|
2002-08-19 00:07:16 +02:00
|
|
|
|
2007-09-19 20:32:01 +02:00
|
|
|
/* Add the current input set to the accumulated input set. */
|
2017-12-27 23:41:43 +01:00
|
|
|
result->add(*tmp);
|
2002-04-21 19:43:12 +02:00
|
|
|
delete tmp;
|
2002-08-19 00:07:16 +02:00
|
|
|
|
2013-10-27 00:25:09 +02:00
|
|
|
/* Add the current outputs to the accumulated output set if
|
|
|
|
|
* they are going to be removed from the input set below. */
|
|
|
|
|
if (rem_out) cur->nex_output(*prev);
|
2002-08-19 00:07:16 +02:00
|
|
|
|
2002-07-15 01:47:58 +02:00
|
|
|
cur = cur->next_;
|
2002-08-19 00:07:16 +02:00
|
|
|
} while (cur != last_->next_);
|
2002-04-21 19:43:12 +02:00
|
|
|
|
2007-09-19 20:32:01 +02:00
|
|
|
/* Remove from the input set those bits that are outputs
|
|
|
|
|
from other statements. They aren't really inputs
|
|
|
|
|
to the block, just internal intermediate values. */
|
|
|
|
|
if (rem_out) result->rem(*prev);
|
2013-10-29 00:08:52 +01:00
|
|
|
delete prev;
|
2007-09-19 20:32:01 +02:00
|
|
|
|
2002-04-21 06:59:07 +02:00
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* The inputs to a case statement are the inputs to the expression,
|
|
|
|
|
* the inputs to all the guards, and the inputs to all the guarded
|
|
|
|
|
* statements.
|
|
|
|
|
*/
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetCase::nex_input(bool rem_out, bool always_sens, bool nested_func) const
|
2002-04-21 06:59:07 +02:00
|
|
|
{
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet*result = expr_->nex_input(rem_out, always_sens, nested_func);
|
2002-04-21 06:59:07 +02:00
|
|
|
|
2014-06-14 03:01:41 +02:00
|
|
|
for (size_t idx = 0 ; idx < items_.size() ; idx += 1) {
|
2002-04-21 06:59:07 +02:00
|
|
|
|
2003-10-26 05:50:46 +01:00
|
|
|
/* Skip cases that have empty statements. */
|
|
|
|
|
if (items_[idx].statement == 0)
|
|
|
|
|
continue;
|
|
|
|
|
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet*tmp = items_[idx].statement->nex_input(rem_out, always_sens, nested_func);
|
2002-04-21 06:59:07 +02:00
|
|
|
result->add(*tmp);
|
|
|
|
|
delete tmp;
|
|
|
|
|
|
2002-11-16 06:45:41 +01:00
|
|
|
/* Usually, this is the guard expression. The default
|
|
|
|
|
case is special and is identified by a null
|
|
|
|
|
guard. The default guard obviously has no input. */
|
|
|
|
|
if (items_[idx].guard) {
|
2019-10-28 21:21:09 +01:00
|
|
|
tmp = items_[idx].guard->nex_input(rem_out, always_sens, nested_func);
|
2002-11-16 06:45:41 +01:00
|
|
|
result->add(*tmp);
|
|
|
|
|
delete tmp;
|
|
|
|
|
}
|
2002-04-21 06:59:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetCondit::nex_input(bool rem_out, bool always_sens, bool nested_func) const
|
2002-04-21 19:43:12 +02:00
|
|
|
{
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet*result = expr_->nex_input(rem_out, always_sens, nested_func);
|
2017-12-27 23:41:43 +01:00
|
|
|
|
2002-04-21 19:43:12 +02:00
|
|
|
if (if_ != 0) {
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet*tmp = if_->nex_input(rem_out, always_sens, nested_func);
|
2002-04-21 19:43:12 +02:00
|
|
|
result->add(*tmp);
|
|
|
|
|
delete tmp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (else_ != 0) {
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet*tmp = else_->nex_input(rem_out, always_sens, nested_func);
|
2002-04-21 19:43:12 +02:00
|
|
|
result->add(*tmp);
|
|
|
|
|
delete tmp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetDisable::nex_input(bool, bool, bool) const
|
2017-12-27 23:41:43 +01:00
|
|
|
{
|
|
|
|
|
return new NexusSet;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetDoWhile::nex_input(bool rem_out, bool always_sens, bool nested_func) const
|
2013-09-17 05:01:06 +02:00
|
|
|
{
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet*result = cond_->nex_input(rem_out, always_sens, nested_func);
|
2017-12-27 23:41:43 +01:00
|
|
|
|
|
|
|
|
if (proc_) {
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet*tmp = proc_->nex_input(rem_out, always_sens, nested_func);
|
2017-12-27 23:41:43 +01:00
|
|
|
result->add(*tmp);
|
|
|
|
|
delete tmp;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-17 05:01:06 +02:00
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetEvTrig::nex_input(bool, bool, bool) const
|
2017-12-27 23:41:43 +01:00
|
|
|
{
|
|
|
|
|
return new NexusSet;
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-20 08:21:12 +01:00
|
|
|
NexusSet* NetEvNBTrig::nex_input(bool, bool, bool) const
|
|
|
|
|
{
|
|
|
|
|
return new NexusSet;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetEvWait::nex_input(bool rem_out, bool always_sens, bool nested_func) const
|
2016-10-17 04:01:26 +02:00
|
|
|
{
|
2017-12-27 23:41:43 +01:00
|
|
|
NexusSet*result = new NexusSet;
|
|
|
|
|
|
|
|
|
|
if (statement_) {
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet*tmp = statement_->nex_input(rem_out, always_sens, nested_func);
|
2017-12-27 23:41:43 +01:00
|
|
|
result->add(*tmp);
|
|
|
|
|
delete tmp;
|
|
|
|
|
}
|
2016-10-20 17:25:34 +02:00
|
|
|
|
2016-10-17 04:01:26 +02:00
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetForever::nex_input(bool rem_out, bool always_sens, bool nested_func) const
|
2002-04-21 19:43:12 +02:00
|
|
|
{
|
2017-12-27 23:41:43 +01:00
|
|
|
NexusSet*result = new NexusSet;
|
|
|
|
|
|
|
|
|
|
if (statement_) {
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet*tmp = statement_->nex_input(rem_out, always_sens, nested_func);
|
2017-12-27 23:41:43 +01:00
|
|
|
result->add(*tmp);
|
|
|
|
|
delete tmp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
2002-04-21 19:43:12 +02:00
|
|
|
}
|
|
|
|
|
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetForLoop::nex_input(bool rem_out, bool always_sens, bool nested_func) const
|
2014-05-02 05:37:33 +02:00
|
|
|
{
|
2017-12-27 23:41:43 +01:00
|
|
|
NexusSet*result = new NexusSet;
|
2014-05-02 05:37:33 +02:00
|
|
|
|
2017-12-27 23:41:43 +01:00
|
|
|
if (init_expr_) {
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet*tmp = init_expr_->nex_input(rem_out, always_sens, nested_func);
|
2017-12-27 23:41:43 +01:00
|
|
|
result->add(*tmp);
|
|
|
|
|
delete tmp;
|
|
|
|
|
}
|
2014-05-02 05:37:33 +02:00
|
|
|
|
2017-12-27 23:41:43 +01:00
|
|
|
if (condition_) {
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet*tmp = condition_->nex_input(rem_out, always_sens, nested_func);
|
2017-12-27 23:41:43 +01:00
|
|
|
result->add(*tmp);
|
|
|
|
|
delete tmp;
|
|
|
|
|
}
|
2014-05-02 05:37:33 +02:00
|
|
|
|
2017-12-27 23:41:43 +01:00
|
|
|
if (step_statement_) {
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet*tmp = step_statement_->nex_input(rem_out, always_sens, nested_func);
|
2017-12-27 23:41:43 +01:00
|
|
|
result->add(*tmp);
|
|
|
|
|
delete tmp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (statement_) {
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet*tmp = statement_->nex_input(rem_out, always_sens, nested_func);
|
2017-12-27 23:41:43 +01:00
|
|
|
result->add(*tmp);
|
|
|
|
|
delete tmp;
|
|
|
|
|
}
|
2014-05-02 05:37:33 +02:00
|
|
|
|
2016-03-05 18:43:25 +01:00
|
|
|
if (gn_shared_loop_index_flag) {
|
2017-12-27 23:41:43 +01:00
|
|
|
NexusSet*tmp = new NexusSet();
|
2016-03-05 18:43:25 +01:00
|
|
|
for (unsigned idx = 0 ; idx < index_->pin_count() ; idx += 1)
|
|
|
|
|
tmp->add(index_->pin(idx).nexus(), 0, index_->vector_width());
|
|
|
|
|
|
|
|
|
|
result->rem(*tmp);
|
|
|
|
|
delete tmp;
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-02 05:37:33 +02:00
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetFree::nex_input(bool, bool, bool) const
|
2002-04-21 19:43:12 +02:00
|
|
|
{
|
2017-12-27 23:41:43 +01:00
|
|
|
return new NexusSet;
|
2002-04-21 19:43:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* The NetPDelay statement is a statement of the form
|
|
|
|
|
*
|
|
|
|
|
* #<expr> <statement>
|
|
|
|
|
*
|
|
|
|
|
* The nex_input set is the input set of the <statement>. Do *not*
|
|
|
|
|
* include the input set of the <expr> because it does not affect the
|
2008-12-29 22:02:21 +01:00
|
|
|
* result. The statement can be omitted.
|
2002-04-21 19:43:12 +02:00
|
|
|
*/
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetPDelay::nex_input(bool rem_out, bool always_sens, bool nested_func) const
|
2002-04-21 19:43:12 +02:00
|
|
|
{
|
2017-12-27 23:41:43 +01:00
|
|
|
NexusSet*result = new NexusSet;
|
|
|
|
|
|
|
|
|
|
if (statement_) {
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet*tmp = statement_->nex_input(rem_out, always_sens, nested_func);
|
2017-12-27 23:41:43 +01:00
|
|
|
result->add(*tmp);
|
|
|
|
|
delete tmp;
|
|
|
|
|
}
|
|
|
|
|
|
2002-04-21 19:43:12 +02:00
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetRepeat::nex_input(bool rem_out, bool always_sens, bool nested_func) const
|
2002-04-21 19:43:12 +02:00
|
|
|
{
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet*result = expr_->nex_input(rem_out, always_sens, nested_func);
|
2017-12-27 23:41:43 +01:00
|
|
|
|
|
|
|
|
if (statement_) {
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet*tmp = statement_->nex_input(rem_out, always_sens, nested_func);
|
2017-12-27 23:41:43 +01:00
|
|
|
result->add(*tmp);
|
|
|
|
|
delete tmp;
|
|
|
|
|
}
|
|
|
|
|
|
2002-04-21 19:43:12 +02:00
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-16 23:36:53 +01:00
|
|
|
/*
|
|
|
|
|
* The $display, etc. system tasks can have NULL arguments.
|
|
|
|
|
*/
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetSTask::nex_input(bool rem_out, bool always_sens, bool nested_func) const
|
2002-04-21 19:43:12 +02:00
|
|
|
{
|
2017-12-27 23:41:43 +01:00
|
|
|
NexusSet*result = new NexusSet;
|
2002-04-21 19:43:12 +02:00
|
|
|
|
2017-12-27 23:41:43 +01:00
|
|
|
if (parms_.empty()) return result;
|
|
|
|
|
|
|
|
|
|
for (unsigned idx = 0 ; idx < parms_.size() ; idx += 1) {
|
2010-11-16 23:36:53 +01:00
|
|
|
if (parms_[idx]) {
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet*tmp = parms_[idx]->nex_input(rem_out, always_sens, nested_func);
|
2010-11-16 23:36:53 +01:00
|
|
|
result->add(*tmp);
|
|
|
|
|
delete tmp;
|
|
|
|
|
}
|
2002-04-21 19:43:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* The NetUTask represents a call to a user defined task. There are no
|
|
|
|
|
* parameters to consider, because the compiler already removed them
|
|
|
|
|
* and converted them to blocking assignments.
|
|
|
|
|
*/
|
2022-10-13 14:47:24 +02:00
|
|
|
NexusSet* NetUTask::nex_input(bool rem_out, bool always_sens, bool nested_func) const
|
2002-04-21 19:43:12 +02:00
|
|
|
{
|
2022-10-13 14:47:24 +02:00
|
|
|
NexusSet *result = new NexusSet;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Let the contents of void functions contribute to the sensitivity list
|
|
|
|
|
* of always_comb blocks
|
|
|
|
|
*/
|
|
|
|
|
if (always_sens && task_->type() == NetScope::FUNC)
|
|
|
|
|
func_always_sens(task_->func_def(), result, rem_out, nested_func);
|
|
|
|
|
|
|
|
|
|
return result;
|
2002-04-21 19:43:12 +02:00
|
|
|
}
|
|
|
|
|
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet* NetWhile::nex_input(bool rem_out, bool always_sens, bool nested_func) const
|
2002-04-21 19:43:12 +02:00
|
|
|
{
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet*result = cond_->nex_input(rem_out, always_sens, nested_func);
|
2017-12-27 23:41:43 +01:00
|
|
|
|
|
|
|
|
if (proc_) {
|
2019-10-28 21:21:09 +01:00
|
|
|
NexusSet*tmp = proc_->nex_input(rem_out, always_sens, nested_func);
|
2017-12-27 23:41:43 +01:00
|
|
|
result->add(*tmp);
|
|
|
|
|
delete tmp;
|
|
|
|
|
}
|
|
|
|
|
|
2002-04-21 19:43:12 +02:00
|
|
|
return result;
|
|
|
|
|
}
|