diff --git a/ivl.def b/ivl.def index 801c966e4..086d50b26 100644 --- a/ivl.def +++ b/ivl.def @@ -288,6 +288,7 @@ ivl_udp_file ivl_udp_lineno ivl_udp_name ivl_udp_nin +ivl_udp_port ivl_udp_row ivl_udp_rows ivl_udp_sequ diff --git a/ivl_target.h b/ivl_target.h index deb046635..fcde050c5 100644 --- a/ivl_target.h +++ b/ivl_target.h @@ -1040,6 +1040,7 @@ extern unsigned ivl_udp_rows(ivl_udp_t net); extern const char* ivl_udp_name(ivl_udp_t net); extern const char* ivl_udp_file(ivl_udp_t net); extern unsigned ivl_udp_lineno(ivl_udp_t net); +extern const char* ivl_udp_port(ivl_udp_t net, unsigned idx); extern const char* ivl_lpm_file(ivl_lpm_t net); extern unsigned ivl_lpm_lineno(ivl_lpm_t net); diff --git a/net_udp.cc b/net_udp.cc index a2d7aa3d0..e9ca4e0bd 100644 --- a/net_udp.cc +++ b/net_udp.cc @@ -79,3 +79,14 @@ char NetUDP::get_initial() const assert(0); return 'x'; } + +unsigned NetUDP::port_count() const +{ + return udp->ports.count(); +} + +string NetUDP::port_name(unsigned idx) const +{ + assert(idx < udp->ports.count()); + return udp->ports[idx]; +} diff --git a/netlist.h b/netlist.h index 403ad6a4a..51fc92dd1 100644 --- a/netlist.h +++ b/netlist.h @@ -42,6 +42,7 @@ # include "LineInfo.h" # include "svector.h" # include "Attrib.h" +# include "PUdp.h" #ifdef HAVE_IOSFWD # include @@ -2144,7 +2145,6 @@ class NetUReduce : public NetNode { * 1 are listed. * */ -#include "PUdp.h" class NetUDP : public NetNode { @@ -2169,6 +2169,9 @@ class NetUDP : public NetNode { unsigned udp_lineno() const { return udp->get_lineno(); } char get_initial() const; + unsigned port_count() const; + string port_name(unsigned idx) const; + private: mutable unsigned table_idx; PUdp *udp; diff --git a/t-dll-api.cc b/t-dll-api.cc index 37c0255c4..49a640c19 100644 --- a/t-dll-api.cc +++ b/t-dll-api.cc @@ -867,6 +867,14 @@ extern "C" char ivl_udp_init(ivl_udp_t net) return net->init; } +extern "C" const char* ivl_udp_port(ivl_udp_t net, unsigned idx) +{ + assert(idx <= net->nin); + assert(net->ports); + assert(net->ports[idx].c_str()); + return net->ports[idx].c_str(); +} + extern "C" const char* ivl_udp_row(ivl_udp_t net, unsigned idx) { assert(idx < net->nrows); diff --git a/t-dll.cc b/t-dll.cc index 1141626d8..2ae7b0c93 100644 --- a/t-dll.cc +++ b/t-dll.cc @@ -1270,38 +1270,36 @@ void dll_target::udp(const NetUDP*net) static map udps; ivl_udp_t u; - if (udps.find(net->udp_name()) != udps.end()) - { - u = udps[net->udp_name()]; - } - else - { - u = new struct ivl_udp_s; - u->nrows = net->rows(); - u->table = (ivl_udp_s::ccharp_t*)malloc((u->nrows+1)*sizeof(char*)); - u->table[u->nrows] = 0x0; - u->nin = net->nin(); - u->sequ = net->is_sequential(); - u->file = net->udp_file(); - u->lineno = net->udp_lineno(); - if (u->sequ) - u->init = net->get_initial(); - else - u->init = 'x'; - u->name = net->udp_name(); - string inp; - char out; - unsigned int i = 0; - if (net->first(inp, out)) - do - { - string tt = inp+out; - u->table[i++] = strings_.add(tt.c_str()); - } while (net->next(inp, out)); - assert(i==u->nrows); + if (udps.find(net->udp_name()) != udps.end()) { + u = udps[net->udp_name()]; + } else { + u = new struct ivl_udp_s; + u->nrows = net->rows(); + u->table = (ivl_udp_s::ccharp_t*)malloc((u->nrows+1)*sizeof(char*)); + u->table[u->nrows] = 0x0; + u->nin = net->nin(); + u->sequ = net->is_sequential(); + u->file = net->udp_file(); + u->lineno = net->udp_lineno(); + if (u->sequ) u->init = net->get_initial(); + else u->init = 'x'; + u->name = net->udp_name(); + string inp; + char out; + unsigned int i = 0; + if (net->first(inp, out)) do { + string tt = inp+out; + u->table[i++] = strings_.add(tt.c_str()); + } while (net->next(inp, out)); + assert(i==u->nrows); + assert((u->nin + 1) == net->port_count()); + u->ports = new string [u->nin + 1]; + for(unsigned idx = 0; idx <= u->nin; idx += 1) { + u->ports[idx] = net->port_name(idx); + } - udps[net->udp_name()] = u; - } + udps[net->udp_name()] = u; + } obj->udp = u; diff --git a/t-dll.h b/t-dll.h index 56aae7b02..0ff28e3da 100644 --- a/t-dll.h +++ b/t-dll.h @@ -517,6 +517,7 @@ struct ivl_udp_s { ccharp_t*table; // zero terminated array of pointers perm_string file; unsigned lineno; + string*ports; }; /*