2 * Copyright (c) 2001 Stephen Williams (steve@icarus.com)
4 * This source code is free software; you can redistribute it
5 * and/or modify it in source code form under the terms of the GNU
6 * General Public License as published by the Free Software
7 * Foundation; either version 2 of the License, or (at your option)
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
20 #ident "$Id: mangle.c,v 1.6 2002/08/12 01:35:03 steve Exp $"
23 # include "fpga_priv.h"
30 static size_t xnf_mangle_scope_name(ivl_scope_t net
, char*buf
, size_t nbuf
)
33 ivl_scope_t parent
= ivl_scope_parent(net
);
36 cnt
= xnf_mangle_scope_name(parent
, buf
, nbuf
);
44 strcpy(buf
, ivl_scope_basename(net
));
50 void xnf_mangle_logic_name(ivl_net_logic_t net
, char*buf
, size_t nbuf
)
52 size_t cnt
= xnf_mangle_scope_name(ivl_logic_scope(net
), buf
, nbuf
);
54 strcpy(buf
+cnt
, ivl_logic_basename(net
));
57 void xnf_mangle_lpm_name(ivl_lpm_t net
, char*buf
, size_t nbuf
)
59 size_t cnt
= xnf_mangle_scope_name(ivl_lpm_scope(net
), buf
, nbuf
);
61 strcpy(buf
+cnt
, ivl_lpm_basename(net
));
65 * Nexus names are used in pin records to connect things together. It
66 * almost doesn't matter what the nexus name is, but for readability
67 * we choose a name that is close to the nexus name. This function
68 * converts the existing name to a name that XNF can use.
70 * For speed, this function saves the calculated string into the real
71 * nexus by using the private pointer. Every nexus is used at least
72 * twice, so this cuts the mangling time in half at least.
74 const char* xnf_mangle_nexus_name(ivl_nexus_t net
)
76 char*name
= ivl_nexus_get_private(net
);
83 name
= malloc(strlen(ivl_nexus_name(net
)) + 1);
84 strcpy(name
, ivl_nexus_name(net
));
86 for (cp
= name
; *cp
; cp
+= 1) switch (*cp
) {
95 ivl_nexus_set_private(net
, name
);
101 * Revision 1.6 2002/08/12 01:35:03 steve
102 * conditional ident string using autoconfig.
104 * Revision 1.5 2002/08/11 23:47:04 steve
105 * Add missing Log and Ident strings.
107 * Revision 1.4 2001/09/15 18:27:04 steve
108 * Make configure detect malloc.h
110 * Revision 1.3 2001/09/02 21:33:07 steve
111 * Rearrange the XNF code generator to be generic-xnf
112 * so that non-XNF code generation is also possible.
114 * Start into the virtex EDIF output driver.
116 * Revision 1.2 2001/08/30 04:31:05 steve
117 * Mangle nexus names.
119 * Revision 1.1 2001/08/28 04:14:20 steve
120 * Add the fpga target.