Handle wide ports of macros.

This commit is contained in:
steve 2003-03-30 03:43:44 +00:00
parent 6e01d390bf
commit 3878f3c770
2 changed files with 67 additions and 13 deletions

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: d-virtex2.c,v 1.2 2003/03/24 02:29:04 steve Exp $" #ident "$Id: d-virtex2.c,v 1.3 2003/03/30 03:43:44 steve Exp $"
#endif #endif
# include "device.h" # include "device.h"
@ -291,12 +291,29 @@ static void virtex2_show_header(ivl_design_t des)
if (ivl_signal_attr(sig, "PAD") != 0) if (ivl_signal_attr(sig, "PAD") != 0)
continue; continue;
edif_portconfig(edf, pidx, ivl_signal_basename(sig), if (ivl_signal_pins(sig) == 1) {
ivl_signal_port(sig)); edif_portconfig(edf, pidx, ivl_signal_basename(sig),
ivl_signal_port(sig));
assert(ivl_signal_pins(sig) == 1); assert(ivl_signal_pins(sig) == 1);
jnt = edif_joint_of_nexus(edf, ivl_signal_pin(sig, 0)); jnt = edif_joint_of_nexus(edf, ivl_signal_pin(sig, 0));
edif_port_to_joint(jnt, edf, pidx); edif_port_to_joint(jnt, edf, pidx);
} else {
const char*name = ivl_signal_basename(sig);
ivl_signal_port_t dir = ivl_signal_port(sig);
char buf[128];
unsigned bit;
for (bit = 0 ; bit < ivl_signal_pins(sig) ; bit += 1) {
const char*tmp;
sprintf(buf, "%s[%u]", name, bit);
tmp = strdup(buf);
edif_portconfig(edf, pidx+bit, tmp, dir);
jnt = edif_joint_of_nexus(edf,ivl_signal_pin(sig,bit));
edif_port_to_joint(jnt, edf, pidx+bit);
}
}
pidx += ivl_signal_pins(sig); pidx += ivl_signal_pins(sig);
} }
@ -1141,6 +1158,9 @@ const struct device_s d_virtex2_edif = {
/* /*
* $Log: d-virtex2.c,v $ * $Log: d-virtex2.c,v $
* Revision 1.3 2003/03/30 03:43:44 steve
* Handle wide ports of macros.
*
* Revision 1.2 2003/03/24 02:29:04 steve * Revision 1.2 2003/03/24 02:29:04 steve
* Give proper basenames to PAD signals. * Give proper basenames to PAD signals.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: edif.c,v 1.2 2003/03/24 02:29:04 steve Exp $" #ident "$Id: edif.c,v 1.3 2003/03/30 03:43:44 steve Exp $"
#endif #endif
# include "edif.h" # include "edif.h"
@ -62,6 +62,7 @@ struct edif_xlibrary_s {
struct __cell_port { struct __cell_port {
const char*name; const char*name;
const char*ename;
ivl_signal_port_t dir; ivl_signal_port_t dir;
}; };
@ -94,6 +95,15 @@ struct edif_joint_s {
struct edif_joint_s*next; struct edif_joint_s*next;
}; };
static int is_edif_name(const char*text)
{
static const char*edif_name_chars = "abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789";
return (strspn(text, edif_name_chars) == strlen(text));
}
edif_t edif_create(const char*design_name, unsigned nports) edif_t edif_create(const char*design_name, unsigned nports)
{ {
edif_t edf = malloc(sizeof(struct edif_s)); edif_t edf = malloc(sizeof(struct edif_s));
@ -115,6 +125,15 @@ void edif_portconfig(edif_t edf, unsigned idx,
assert(idx < edf->nports); assert(idx < edf->nports);
edf->ports[idx].name = name; edf->ports[idx].name = name;
if (is_edif_name(name)) {
edf->ports[idx].ename = 0;
} else {
char buf[16];
sprintf(buf, "PORT%u", idx);
edf->ports[idx].ename = strdup(buf);
}
edf->ports[idx].dir = dir; edf->ports[idx].dir = dir;
} }
@ -273,7 +292,6 @@ void edif_add_to_joint(edif_joint_t jnt, edif_cellref_t cell, unsigned port)
jnt->links = jc; jnt->links = jc;
} }
/* /*
* This function takes all the data structures that have been * This function takes all the data structures that have been
* assembled by the code generator, and writes them into an EDIF * assembled by the code generator, and writes them into an EDIF
@ -352,7 +370,14 @@ void edif_print(FILE*fd, edif_t edf)
fprintf(fd, " (interface\n"); fprintf(fd, " (interface\n");
for (idx = 0 ; idx < edf->nports ; idx += 1) { for (idx = 0 ; idx < edf->nports ; idx += 1) {
fprintf(fd, " (port %s ", edf->ports[idx].name); fprintf(fd, " (port ");
if (edf->ports[idx].ename == 0)
fprintf(fd, "%s ", edf->ports[idx].name);
else
fprintf(fd, "(rename %s \"%s\") ",
edf->ports[idx].ename,
edf->ports[idx].name);
switch (edf->ports[idx].dir) { switch (edf->ports[idx].dir) {
case IVL_SIP_INPUT: case IVL_SIP_INPUT:
fprintf(fd, "(direction INPUT)"); fprintf(fd, "(direction INPUT)");
@ -405,13 +430,19 @@ void edif_print(FILE*fd, edif_t edf)
fprintf(fd, " (joined"); fprintf(fd, " (joined");
for (jc = jnt->links ; jc ; jc = jc->next) { for (jc = jnt->links ; jc ; jc = jc->next) {
if (jc->cell) if (jc->cell) {
fprintf(fd, " (portRef %s (instanceRef U%u))", fprintf(fd, " (portRef %s (instanceRef U%u))",
jc->cell->cell->ports[jc->port].name, jc->cell->cell->ports[jc->port].name,
jc->cell->u); jc->cell->u);
else } else {
fprintf(fd, " (portRef %s)", /* Reference to a port of the main cell. */
edf->ports[jc->port].name); if (edf->ports[jc->port].ename)
fprintf(fd, " (portRef %s)",
edf->ports[jc->port].ename);
else
fprintf(fd, " (portRef %s)",
edf->ports[jc->port].name);
}
} }
fprintf(fd, "))\n"); fprintf(fd, "))\n");
} }
@ -441,6 +472,9 @@ void edif_print(FILE*fd, edif_t edf)
/* /*
* $Log: edif.c,v $ * $Log: edif.c,v $
* Revision 1.3 2003/03/30 03:43:44 steve
* Handle wide ports of macros.
*
* Revision 1.2 2003/03/24 02:29:04 steve * Revision 1.2 2003/03/24 02:29:04 steve
* Give proper basenames to PAD signals. * Give proper basenames to PAD signals.
* *