Skip to content

Commit

Permalink
Add support for getting the original port names of a UDP definition.
Browse files Browse the repository at this point in the history
This patch adds support to the compiler/ivl interface for getting the
original UDP definition port names. ivl_udp_port() was added to get
this information.
  • Loading branch information
caryr authored and steveicarus committed Mar 1, 2011
1 parent 757611b commit 53abd7a
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 33 deletions.
1 change: 1 addition & 0 deletions ivl.def
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions ivl_target.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
11 changes: 11 additions & 0 deletions net_udp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
5 changes: 4 additions & 1 deletion netlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
# include "LineInfo.h"
# include "svector.h"
# include "Attrib.h"
# include "PUdp.h"

#ifdef HAVE_IOSFWD
# include <iosfwd>
Expand Down Expand Up @@ -2144,7 +2145,6 @@ class NetUReduce : public NetNode {
* 1 are listed.
*
*/
#include "PUdp.h"

class NetUDP : public NetNode {

Expand All @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions t-dll-api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
62 changes: 30 additions & 32 deletions t-dll.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1270,38 +1270,36 @@ void dll_target::udp(const NetUDP*net)
static map<perm_string,ivl_udp_t> 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);

udps[net->udp_name()] = 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);
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;
}

obj->udp = u;

Expand Down
1 change: 1 addition & 0 deletions t-dll.h
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ struct ivl_udp_s {
ccharp_t*table; // zero terminated array of pointers
perm_string file;
unsigned lineno;
string*ports;
};

/*
Expand Down

0 comments on commit 53abd7a

Please sign in to comment.