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: fpga.c,v 1.10 2003/10/27 02:18:28 steve Exp $"
26 * This is the FPGA target module.
29 # include <ivl_target.h>
31 # include "fpga_priv.h"
34 /* This is the opened xnf file descriptor. It is the output that this
35 code generator writes to. */
42 int scope_has_attribute(ivl_scope_t s
, const char *name
)
45 const struct ivl_attribute_s
*a
;
46 for (i
=0; i
<ivl_scope_attr_cnt(s
); i
++) {
47 a
= ivl_scope_attr_val(s
, i
);
48 if (strcmp(a
->key
,name
) == 0)
54 static int show_process(ivl_process_t net
, void*x
)
56 ivl_scope_t scope
= ivl_process_scope(net
);
58 /* Ignore processes that are within scopes that are cells. The
59 cell_scope will generate a cell to represent the entire
61 if (scope_has_attribute(scope
, "ivl_synthesis_cell"))
64 fprintf(stderr
, "fpga target: unsynthesized behavioral code\n");
68 static void show_pads(ivl_scope_t scope
)
72 if (device
->show_pad
== 0)
75 for (idx
= 0 ; idx
< ivl_scope_sigs(scope
) ; idx
+= 1) {
76 ivl_signal_t sig
= ivl_scope_sig(scope
, idx
);
79 if (ivl_signal_port(sig
) == IVL_SIP_NONE
)
82 pad
= ivl_signal_attr(sig
, "PAD");
86 assert(device
->show_pad
);
87 device
->show_pad(sig
, pad
);
91 static void show_constants(ivl_design_t des
)
95 if (device
->show_constant
== 0)
98 for (idx
= 0 ; idx
< ivl_design_consts(des
) ; idx
+= 1) {
99 ivl_net_const_t con
= ivl_design_const(des
, idx
);
100 device
->show_constant(con
);
105 * This is the main entry point that ivl uses to invoke me, the code
108 int target_design(ivl_design_t des
)
110 ivl_scope_t root
= ivl_design_root(des
);
111 const char*path
= ivl_design_flag(des
, "-o");
113 xnf
= fopen(path
, "w");
119 part
= ivl_design_flag(des
, "part");
120 if (part
&& (part
[0] == 0))
123 arch
= ivl_design_flag(des
, "arch");
124 if (arch
&& (arch
[0] == 0))
130 device
= device_from_arch(arch
);
132 fprintf(stderr
, "Unknown architecture arch=%s\n", arch
);
136 /* Call the device driver to generate the netlist header. */
137 device
->show_header(des
);
139 /* Catch any behavioral code that is left, and write warnings
140 that it is not supported. */
141 ivl_design_process(des
, show_process
, 0);
143 /* Get the pads from the design, and draw them to connect to
144 the associated signals. */
147 /* Scan the scopes, looking for gates to draw into the output
149 show_scope_gates(root
, 0);
153 /* Call the device driver to close out the file. */
154 device
->show_footer(des
);
163 * Revision 1.10 2003/10/27 02:18:28 steve
164 * Emit constants for LPM device.
166 * Revision 1.9 2003/08/07 04:04:01 steve
167 * Add an LPM device type.
169 * Revision 1.8 2003/06/25 01:49:06 steve
172 * Revision 1.7 2003/06/24 03:55:00 steve
173 * Add ivl_synthesis_cell support for virtex2.
175 * Revision 1.6 2002/08/12 01:35:02 steve
176 * conditional ident string using autoconfig.
178 * Revision 1.5 2001/09/16 01:48:16 steve
179 * Suppor the PAD attribute on signals.
181 * Revision 1.4 2001/09/02 21:33:07 steve
182 * Rearrange the XNF code generator to be generic-xnf
183 * so that non-XNF code generation is also possible.
185 * Start into the virtex EDIF output driver.
187 * Revision 1.3 2001/09/01 02:01:30 steve
188 * identity compare, and PWR records for constants.
190 * Revision 1.2 2001/08/31 02:59:06 steve
191 * Add root port SIG records.
193 * Revision 1.1 2001/08/28 04:14:20 steve
194 * Add the fpga target.