Compile time warnings
[iverilog.git] / tgt-vvp / vvp.c
blobef714e2fb98131c0a1f1bf9938cee28ceafe9b57
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: vvp.c,v 1.17 2004/10/04 01:10:57 steve Exp $"
21 #endif
26 # include "vvp_priv.h"
27 # include <string.h>
28 # include <assert.h>
29 # include <sys/types.h>
30 # include <sys/stat.h>
32 FILE*vvp_out = 0;
34 inline static void draw_execute_header(ivl_design_t des)
36 #if !defined(__MINGW32__)
37 const char*cp = ivl_design_flag(des, "VVP_EXECUTABLE");
38 if (cp) {
39 fprintf(vvp_out, "#! %s\n", cp);
40 fchmod(fileno(vvp_out), 0755);
42 #endif
45 inline static void draw_module_declarations(ivl_design_t des)
47 const char*cp = ivl_design_flag(des, "VPI_MODULE_LIST");
49 while (*cp) {
50 char buffer[128];
51 const char*comma = strchr(cp, ',');
53 if (comma == 0)
54 comma = cp + strlen(cp);
56 strncpy(buffer, cp, comma-cp);
57 buffer[comma-cp] = 0;
58 fprintf(vvp_out, ":vpi_module \"%s\";\n", buffer);
60 cp = comma;
61 if (*cp) cp += 1;
66 int target_design(ivl_design_t des)
69 int rc;
70 ivl_scope_t *roots;
71 unsigned nroots, i;
72 const char*path = ivl_design_flag(des, "-o");
73 assert(path);
75 #ifdef HAVE_FOPEN64
76 vvp_out = fopen64(path, "w");
77 #else
78 vvp_out = fopen(path, "w");
79 #endif
80 if (vvp_out == 0) {
81 perror(path);
82 return -1;
85 draw_execute_header(des);
87 { int pre = ivl_design_time_precision(des);
88 char sign = '+';
89 if (pre < 0) {
90 pre = -pre;
91 sign = '-';
93 fprintf(vvp_out, ":vpi_time_precision %c %d;\n", sign, pre);
96 draw_module_declarations(des);
98 ivl_design_roots(des, &roots, &nroots);
99 for (i = 0; i < nroots; i++)
100 draw_scope(roots[i], 0);
102 rc = ivl_design_process(des, draw_process, 0);
104 fclose(vvp_out);
106 return rc;
110 * $Log: vvp.c,v $
111 * Revision 1.17 2004/10/04 01:10:57 steve
112 * Clean up spurious trailing white space.
114 * Revision 1.16 2003/05/16 03:22:52 steve
115 * Use fopen64 to open output file.
117 * Revision 1.15 2002/08/12 01:35:03 steve
118 * conditional ident string using autoconfig.
120 * Revision 1.14 2002/08/11 23:47:04 steve
121 * Add missing Log and Ident strings.