Add a mark at simulation end for vcd/lxt/lxt2 files.
[iverilog.git] / vpi / sys_table.c
blobceb7e00332ce7869f205753186802cb220b25114
1 /*
2 * Copyright (c) 1999 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: sys_table.c,v 1.26 2006/08/03 05:06:04 steve Exp $"
21 #endif
23 # include "vpi_config.h"
24 # include "vpi_user.h"
25 # include <stdio.h>
26 # include <stdlib.h>
27 # include <string.h>
29 extern void sys_convert_register();
30 extern void sys_fileio_register();
31 extern void sys_finish_register();
32 extern void sys_deposit_register();
33 extern void sys_display_register();
34 extern void sys_plusargs_register();
35 extern void sys_random_register();
36 extern void sys_random_mti_register();
37 extern void sys_readmem_register();
38 extern void sys_scanf_register();
39 extern void sys_time_register();
40 extern void sys_vcd_register();
41 extern void sys_vcdoff_register();
43 #ifdef HAVE_LIBZ
44 #ifdef HAVE_LIBBZ2
45 extern void sys_lxt_register();
46 #else
47 static void sys_lxt_register() { fputs("LXT support disabled since libbzip2 not available\n",stderr); exit(1); }
48 #endif
49 extern void sys_lxt2_register();
50 #else
51 static void sys_lxt_register() { fputs("LXT support disabled since zlib not available\n",stderr); exit(1); }
52 static void sys_lxt2_register() { fputs("LXT2 support disabled since zlib not available\n",stderr); exit(1); }
53 #endif
55 static void sys_lxt_or_vcd_register()
57 int idx;
58 struct t_vpi_vlog_info vlog_info;
60 char*dumper;
62 /* Get the dumper of choice from the IVERILOG_DUMPER
63 environment variable. */
64 dumper = getenv("IVERILOG_DUMPER");
65 if (dumper) {
66 char*cp = strchr(dumper,'=');
67 if (cp != 0)
68 dumper = cp + 1;
70 } else {
71 dumper = "vcd";
74 /* Scan the extended arguments, looking for flags that select
75 major features. This can override the environment variable
76 settings. */
77 vpi_get_vlog_info(&vlog_info);
79 for (idx = 0 ; idx < vlog_info.argc ; idx += 1) {
81 if (strcmp(vlog_info.argv[idx],"-lxt") == 0) {
82 dumper = "lxt";
84 } else if (strcmp(vlog_info.argv[idx],"-lxt-space") == 0) {
85 dumper = "lxt";
87 } else if (strcmp(vlog_info.argv[idx],"-lxt-speed") == 0) {
88 dumper = "lxt";
90 } else if (strcmp(vlog_info.argv[idx],"-lxt-none") == 0) {
91 dumper = "none";
93 } else if (strcmp(vlog_info.argv[idx],"-lxt2") == 0) {
94 dumper = "lxt2";
96 } else if (strcmp(vlog_info.argv[idx],"-lxt2-space") == 0) {
97 dumper = "lxt2";
99 } else if (strcmp(vlog_info.argv[idx],"-lxt2-speed") == 0) {
100 dumper = "lxt2";
102 } else if (strcmp(vlog_info.argv[idx],"-lxt2-none") == 0) {
103 dumper = "none";
105 } else if (strcmp(vlog_info.argv[idx],"-lx2") == 0) {
106 dumper = "lxt2";
108 } else if (strcmp(vlog_info.argv[idx],"-lx2-space") == 0) {
109 dumper = "lxt2";
111 } else if (strcmp(vlog_info.argv[idx],"-lx2-speed") == 0) {
112 dumper = "lxt2";
114 } else if (strcmp(vlog_info.argv[idx],"-lx2-none") == 0) {
115 dumper = "none";
117 } else if (strcmp(vlog_info.argv[idx],"-vcd") == 0) {
118 dumper = "vcd";
120 } else if (strcmp(vlog_info.argv[idx],"-vcd-off") == 0) {
121 dumper = "none";
123 } else if (strcmp(vlog_info.argv[idx],"-vcd-none") == 0) {
124 dumper = "none";
129 if (strcmp(dumper, "vcd") == 0)
130 sys_vcd_register();
132 else if (strcmp(dumper, "VCD") == 0)
133 sys_vcd_register();
135 else if (strcmp(dumper, "lxt") == 0)
136 sys_lxt_register();
138 else if (strcmp(dumper, "LXT") == 0)
139 sys_lxt_register();
141 else if (strcmp(dumper, "lxt2") == 0)
142 sys_lxt2_register();
144 else if (strcmp(dumper, "LXT2") == 0)
145 sys_lxt2_register();
147 else if (strcmp(dumper, "lx2") == 0)
148 sys_lxt2_register();
150 else if (strcmp(dumper, "LX2") == 0)
151 sys_lxt2_register();
153 else if (strcmp(dumper, "none") == 0)
154 sys_vcdoff_register();
156 else if (strcmp(dumper, "NONE") == 0)
157 sys_vcdoff_register();
159 else {
160 fprintf(stderr, "system.vpi: Unknown dumper format: %s\n",
161 dumper);
162 sys_vcd_register();
166 void (*vlog_startup_routines[])() = {
167 sys_convert_register,
168 sys_fileio_register,
169 sys_finish_register,
170 sys_deposit_register,
171 sys_display_register,
172 sys_plusargs_register,
173 sys_random_register,
174 sys_random_mti_register,
175 sys_readmem_register,
176 sys_scanf_register,
177 sys_time_register,
178 sys_lxt_or_vcd_register,