Add support for text macros with arguments.
[iverilog.git] / tgt-fpga / gates.c
blobb6f6857b156d64bf0bc8e0a2b8c8cbfbea0bad38
1 /*
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)
8 * any later version.
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
19 #ifdef HAVE_CVS_IDENT
20 #ident "$Id: gates.c,v 1.14 2003/11/12 03:20:14 steve Exp $"
21 #endif
23 # include <ivl_target.h>
24 # include "fpga_priv.h"
25 # include <assert.h>
27 static void show_cell_scope(ivl_scope_t scope)
29 if (device->show_cell_scope == 0) {
30 fprintf(stderr, "fpga.tgt: ivl_synthesis_cell(scope)"
31 " not supported by this target.\n");
32 return;
35 device->show_cell_scope(scope);
38 static void show_gate_logic(ivl_net_logic_t net)
40 if (device->show_logic == 0) {
41 fprintf(stderr, "fpga.tgt: IVL LOGIC not supported"
42 " by this target.\n");
43 return;
46 assert(device->show_logic);
47 device->show_logic(net);
50 static void show_gate_lpm(ivl_lpm_t net)
52 switch (ivl_lpm_type(net)) {
54 case IVL_LPM_ADD:
55 if (device->show_add == 0) {
56 fprintf(stderr, "fpga.tgt: IVL_LPM_ADD not supported"
57 " by this target.\n");
58 return;
60 device->show_add(net);
61 break;
63 case IVL_LPM_SUB:
64 if (device->show_sub == 0) {
65 fprintf(stderr, "fpga.tgt: IVL_LPM_SUB not supported"
66 " by this target.\n");
67 return;
69 device->show_sub(net);
70 break;
72 case IVL_LPM_CMP_EQ:
73 if (device->show_cmp_eq == 0) {
74 fprintf(stderr, "fpga.tgt: IVL_LPM_CMP_EQ not supported"
75 " by this target.\n");
76 return;
78 device->show_cmp_eq(net);
79 break;
81 case IVL_LPM_CMP_NE:
82 if (device->show_cmp_ne == 0) {
83 fprintf(stderr, "fpga.tgt: IVL_LPM_CMP_NE not supported"
84 " by this target.\n");
85 return;
87 device->show_cmp_ne(net);
88 break;
90 case IVL_LPM_CMP_GE:
91 if (device->show_cmp_ge == 0) {
92 fprintf(stderr, "fpga.tgt: IVL_LPM_CMP_GE not supported"
93 " by this target.\n");
94 return;
96 device->show_cmp_ge(net);
97 break;
99 case IVL_LPM_CMP_GT:
100 if (device->show_cmp_gt == 0) {
101 fprintf(stderr, "fpga.tgt: IVL_LPM_CMP_GT not supported"
102 " by this target.\n");
103 return;
105 device->show_cmp_gt(net);
106 break;
108 case IVL_LPM_FF:
109 if (device->show_dff == 0) {
110 fprintf(stderr, "fpga.tgt: IVL_LPM_FF not supported"
111 " by this target.\n");
112 return;
114 device->show_dff(net);
115 break;
117 case IVL_LPM_MUX:
118 if (device->show_mux == 0) {
119 fprintf(stderr, "fpga.tgt: IVL_LPM_MUX not supported"
120 " by this target.\n");
121 return;
123 device->show_mux(net);
124 break;
126 case IVL_LPM_MULT:
127 if (device->show_mult == 0) {
128 fprintf(stderr, "fpga.tgt: IVL_LPM_MULT not supported"
129 " by this target.\n");
130 return;
132 device->show_mult(net);
133 break;
135 case IVL_LPM_SHIFTL:
136 if (device->show_shiftl == 0) {
137 fprintf(stderr, "fpga.tgt: IVL_LPM_SHIFTL not supported"
138 " by this target.\n");
139 return;
141 device->show_shiftl(net);
142 break;
144 case IVL_LPM_SHIFTR:
145 if (device->show_shiftr == 0) {
146 fprintf(stderr, "fpga.tgt: IVL_LPM_SHIFTR not supported"
147 " by this target.\n");
148 return;
150 device->show_shiftr(net);
151 break;
153 default:
154 fprintf(stderr, "fpga.tgt: unknown LPM type %u\n",
155 ivl_lpm_type(net));
156 break;
160 int show_scope_gates(ivl_scope_t net, void*x)
162 unsigned idx;
164 if (scope_has_attribute(net, "ivl_synthesis_cell")) {
165 show_cell_scope(net);
166 return 0;
169 for (idx = 0 ; idx < ivl_scope_logs(net) ; idx += 1)
170 show_gate_logic(ivl_scope_log(net, idx));
172 for (idx = 0 ; idx < ivl_scope_lpms(net) ; idx += 1)
173 show_gate_lpm(ivl_scope_lpm(net, idx));
175 return ivl_scope_children(net, show_scope_gates, 0);
179 * $Log: gates.c,v $
180 * Revision 1.14 2003/11/12 03:20:14 steve
181 * devices need show_cmp_gt
183 * Revision 1.13 2003/08/09 03:23:03 steve
184 * Add support for IVL_LPM_MULT device.
186 * Revision 1.12 2003/08/07 04:04:01 steve
187 * Add an LPM device type.
189 * Revision 1.11 2003/06/24 03:55:01 steve
190 * Add ivl_synthesis_cell support for virtex2.
192 * Revision 1.10 2002/10/28 02:05:56 steve
193 * Add Virtex code generators for left shift,
194 * subtraction, and GE comparators.
196 * Revision 1.9 2002/08/12 01:35:03 steve
197 * conditional ident string using autoconfig.
199 * Revision 1.8 2002/08/11 23:47:04 steve
200 * Add missing Log and Ident strings.
202 * Revision 1.7 2001/09/09 22:23:28 steve
203 * Virtex support for mux devices and adders
204 * with carry chains. Also, make Virtex specific
205 * implementations of primitive logic.
207 * Revision 1.6 2001/09/02 21:33:07 steve
208 * Rearrange the XNF code generator to be generic-xnf
209 * so that non-XNF code generation is also possible.
211 * Start into the virtex EDIF output driver.