From 4100ff71ef11b2fae8cae9e7f75b4ee6f6be4c41 Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Thu, 3 Jan 2008 20:13:56 -0800 Subject: [PATCH] Data type handling of module ports. Fix data type handling of module ports. When ports are declared as ports and given data types in different statements, the parser incorrectly (and silently) dropped the intended data type for the default LOGIC type. --- PWire.cc | 5 +++++ pform.cc | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/PWire.cc b/PWire.cc index 84d1dca71..1b375ddc3 100644 --- a/PWire.cc +++ b/PWire.cc @@ -113,6 +113,11 @@ bool PWire::set_data_type(ivl_variable_type_t dt) return true; } +ivl_variable_type_t PWire::get_data_type() const +{ + return data_type_; +} + void PWire::set_signed(bool flag) { signed_ = flag; diff --git a/pform.cc b/pform.cc index a2798a28d..b5b803fdb 100644 --- a/pform.cc +++ b/pform.cc @@ -34,6 +34,8 @@ # include # include +# include "ivl_assert.h" + map pform_modules; map pform_primitives; @@ -1313,9 +1315,17 @@ void pform_makewire(const vlltype&li, const char*nm, FILE_NAME(cur, li.text, li.first_line); + bool flag; switch (dt) { case IVL_VT_REAL: - cur->set_data_type(dt); + flag = cur->set_data_type(dt); + if (flag == false) { + cerr << cur->get_fileline() << ": internal error: " + << " wire data type handling mismatch. Cannot change " + << cur->get_data_type() + << " to " << dt << "." << endl; + } + ivl_assert(*cur, flag); cur->set_range(0, 0, SR_NET); cur->set_signed(true); break; @@ -1417,7 +1427,7 @@ void pform_set_port_type(perm_string nm, NetNet::PortType pt, pform_name_t name = hier_name(nm); PWire*cur = pform_cur_module->get_wire(name); if (cur == 0) { - cur = new PWire(name, NetNet::IMPLICIT, NetNet::PIMPLICIT, IVL_VT_LOGIC); + cur = new PWire(name, NetNet::IMPLICIT, NetNet::PIMPLICIT, IVL_VT_NO_TYPE); FILE_NAME(cur, file, lineno); pform_cur_module->add_wire(cur); }