$finish() now stops at the end of the time step not immediately.
[iverilog.git] / tgt-pal / emit_jed.c
blob7a74ff1271021e3ad9ea5b9cb5ba0d6dc597bc97
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: emit_jed.c,v 1.5 2002/08/12 01:35:03 steve Exp $"
21 #endif
23 # include "config.h"
25 # include "priv.h"
26 # include <stdio.h>
27 #ifdef HAVE_MALLOC_H
28 # include <malloc.h>
29 #endif
30 # include <stdlib.h>
31 # include <assert.h>
33 static void draw_macrocell_modes(FILE*jfd)
35 unsigned idx;
36 unsigned cfuses;
37 unsigned mode, mcnt;
39 for (idx = 0 ; idx < pins ; idx += 1) {
40 char*str;
41 unsigned ffirst, flast, tmp;
42 struct pal_bind_s*cur = bind_pin + idx;
43 if (cur->sop == 0)
44 continue;
46 cfuses = pal_sop_cfuses(cur->sop);
47 mcnt = 1 << pal_sop_cfuses(cur->sop);
48 mode = 0;
49 for (mode = 0 ; mode < mcnt ; mode += 1) {
51 pal_sop_set_mode(cur->sop, mode);
52 if (cur->reg && !pal_sop_is_register(cur->sop))
53 continue;
55 if (!cur->reg && pal_sop_is_register(cur->sop))
56 continue;
58 if (cur->sop_inv && !pal_sop_is_invert(cur->sop))
59 continue;
61 if (!cur->sop_inv && pal_sop_is_invert(cur->sop))
62 continue;
64 break;
67 assert(mode < mcnt);
69 ffirst = pal_sop_cfuse(cur->sop, 0);
70 flast = pal_sop_cfuse(cur->sop, 0);
71 for (tmp = 1 ; tmp < cfuses ; tmp += 1) {
72 unsigned f = pal_sop_cfuse(cur->sop, tmp);
73 if (f < ffirst)
74 ffirst = f;
75 if (f > flast)
76 flast = f;
78 assert(flast == (ffirst + cfuses - 1));
80 str = malloc(cfuses+1);
81 str[cfuses] = 0;
82 for (tmp = 0 ; tmp < cfuses ; tmp += 1) {
83 if (mode & (1 << (cfuses-tmp-1)))
84 str[pal_sop_cfuse(cur->sop, tmp)-ffirst] = '1';
85 else
86 str[pal_sop_cfuse(cur->sop, tmp)-ffirst] = '0';
90 fprintf(jfd, "L%05u %s* Note: ", ffirst, str);
91 if (cur->nexus)
92 fprintf(jfd, "%s ", ivl_nexus_name(cur->nexus));
94 { int pin = pal_sop_pin(cur->sop);
95 if (pin > 0)
96 fprintf(jfd, "pin %d: ", pin);
98 if (pal_sop_is_register(cur->sop))
99 fprintf(jfd, "<registered");
100 else
101 fprintf(jfd, "<unregistered");
103 if (pal_sop_is_invert(cur->sop))
104 fprintf(jfd, ", invert");
106 fprintf(jfd, "> *\n");
108 free(str);
112 int emit_jedec(const char*path)
114 FILE*jfd;
116 jfd = fopen(path, "w");
117 if (jfd == 0) {
118 fprintf(stderr, "unable to open ``%s'' for output.\n", path);
119 return -1;
122 fprintf(jfd, "\002This file created by Icarus Verilog/PAL\n");
123 fprintf(jfd, "*\n");
125 fprintf(jfd, "QF%u* Number of fuses*\n", pal_fuses(pal));
126 fprintf(jfd, "F0* Note: Default fuse set to 0*\n");
127 fprintf(jfd, "G0* Note: Security fuse NOT blown.*\n");
129 draw_macrocell_modes(jfd);
131 fclose(jfd);
132 return 0;
136 * $Log: emit_jed.c,v $
137 * Revision 1.5 2002/08/12 01:35:03 steve
138 * conditional ident string using autoconfig.
140 * Revision 1.4 2001/09/15 18:27:04 steve
141 * Make configure detect malloc.h
143 * Revision 1.3 2001/07/25 03:10:50 steve
144 * Create a config.h.in file to hold all the config
145 * junk, and support gcc 3.0. (Stephan Boettcher)
147 * Revision 1.2 2001/01/09 04:41:32 steve
148 * Clean up the jedec header that is written.
150 * Revision 1.1 2001/01/09 03:10:48 steve
151 * Generate the jedec to configure the macrocells.