From 0153a25061e7196e0784cb361b1332e96883937d Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Thu, 19 Jun 2008 19:13:50 -0700 Subject: [PATCH] Elaborate nets with real-valued parameters. --- elab_net.cc | 26 +++++++++++++++++++++++++- netlist.cc | 5 +++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/elab_net.cc b/elab_net.cc index 4b5370e34..f00936882 100644 --- a/elab_net.cc +++ b/elab_net.cc @@ -1794,8 +1794,32 @@ NetNet* PEIdent::elaborate_net(Design*des, NetScope*scope, that connects to a signal with the correct name. */ if (par != 0) { + // Detect and handle the special case that we have a + // real valued parameter. Return a NetLiteral and a + // properly typed net. + if (const NetECReal*pc = dynamic_cast(par)) { + NetLiteral*tmp = new NetLiteral(scope, scope->local_symbol(), + pc->value()); + des->add_node(tmp); + tmp->set_line(*par); + sig = new NetNet(scope, scope->local_symbol(), + NetNet::IMPLICIT); + sig->set_line(*tmp); + sig->data_type(tmp->data_type()); + sig->local_flag(true); + + connect(tmp->pin(0), sig->pin(0)); + return sig; + } + const NetEConst*pc = dynamic_cast(par); - assert(pc); + if (pc == 0) { + cerr << get_fileline() << ": internal error: " + << "Non-consant parameter value?: " << *par << endl; + cerr << get_fileline() << ": : " + << "Expression type is " << par->expr_type() << endl; + } + ivl_assert(*this, pc); verinum pvalue = pc->value(); /* If the parameter has declared dimensions, then apply diff --git a/netlist.cc b/netlist.cc index db630eb6b..d1565aab0 100644 --- a/netlist.cc +++ b/netlist.cc @@ -1505,6 +1505,11 @@ NetLiteral::~NetLiteral() { } +ivl_variable_type_t NetLiteral::data_type() const +{ + return IVL_VT_REAL; +} + const verireal& NetLiteral::value_real() const { return real_;