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: emit_jed.c,v 1.5 2002/08/12 01:35:03 steve Exp $"
33 static void draw_macrocell_modes(FILE*jfd
)
39 for (idx
= 0 ; idx
< pins
; idx
+= 1) {
41 unsigned ffirst
, flast
, tmp
;
42 struct pal_bind_s
*cur
= bind_pin
+ idx
;
46 cfuses
= pal_sop_cfuses(cur
->sop
);
47 mcnt
= 1 << pal_sop_cfuses(cur
->sop
);
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
))
55 if (!cur
->reg
&& pal_sop_is_register(cur
->sop
))
58 if (cur
->sop_inv
&& !pal_sop_is_invert(cur
->sop
))
61 if (!cur
->sop_inv
&& pal_sop_is_invert(cur
->sop
))
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
);
78 assert(flast
== (ffirst
+ cfuses
- 1));
80 str
= malloc(cfuses
+1);
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';
86 str
[pal_sop_cfuse(cur
->sop
, tmp
)-ffirst
] = '0';
90 fprintf(jfd
, "L%05u %s* Note: ", ffirst
, str
);
92 fprintf(jfd
, "%s ", ivl_nexus_name(cur
->nexus
));
94 { int pin
= pal_sop_pin(cur
->sop
);
96 fprintf(jfd
, "pin %d: ", pin
);
98 if (pal_sop_is_register(cur
->sop
))
99 fprintf(jfd
, "<registered");
101 fprintf(jfd
, "<unregistered");
103 if (pal_sop_is_invert(cur
->sop
))
104 fprintf(jfd
, ", invert");
106 fprintf(jfd
, "> *\n");
112 int emit_jedec(const char*path
)
116 jfd
= fopen(path
, "w");
118 fprintf(stderr
, "unable to open ``%s'' for output.\n", path
);
122 fprintf(jfd
, "\002This file created by Icarus Verilog/PAL\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
);
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.