iverilog/vpi/sys_table.c

223 lines
6.5 KiB
C
Raw Permalink Normal View History

/*
* Copyright (c) 1999-2018 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
* General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
2012-08-29 03:41:23 +02:00
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
# include "vpi_config.h"
2002-04-06 23:33:29 +02:00
# include "vpi_user.h"
# include "vcd_priv.h"
2002-04-06 23:33:29 +02:00
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
extern void sys_convert_register(void);
extern void sys_countdrivers_register(void);
extern void sys_darray_register(void);
extern void sys_fileio_register(void);
extern void sys_finish_register(void);
extern void sys_deposit_register(void);
extern void sys_display_register(void);
extern void sys_plusargs_register(void);
extern void sys_queue_register(void);
extern void sys_random_register(void);
extern void sys_random_mti_register(void);
extern void sys_readmem_register(void);
extern void sys_scanf_register(void);
extern void sys_sdf_register(void);
extern void sys_time_register(void);
extern void sys_vcd_register(void);
extern void sys_vcdoff_register(void);
extern void sys_special_register(void);
extern void table_model_register(void);
extern void vams_simparam_register(void);
2003-09-13 03:28:47 +02:00
#ifdef HAVE_LIBZ
#ifdef HAVE_LIBBZ2
extern void sys_lxt_register(void);
#else
static void sys_lxt_register(void) { fputs("LXT support disabled since libbzip2 not available\n",stderr); exit(1); }
#endif
extern void sys_lxt2_register(void);
extern void sys_fst_register(void);
2003-09-13 03:28:47 +02:00
#else
static void sys_lxt_register(void) { fputs("LXT support disabled since zlib not available\n",stderr); exit(1); }
static void sys_lxt2_register(void) { fputs("LXT2 support disabled since zlib not available\n",stderr); exit(1); }
static void sys_fst_register(void) { fputs("FST support disabled since zlib not available\n",stderr); exit(1); }
2003-09-13 03:28:47 +02:00
#endif
static void sys_lxt_or_vcd_register(void)
2002-04-06 23:33:29 +02:00
{
int idx;
struct t_vpi_vlog_info vlog_info;
const char*dumper;
2002-04-06 23:33:29 +02:00
/* Get the dumper of choice from the IVERILOG_DUMPER
environment variable. */
dumper = getenv("IVERILOG_DUMPER");
if (dumper) {
char*cp = strchr(dumper,'=');
if (cp != 0)
dumper = cp + 1;
} else {
dumper = "vcd";
}
/* Scan the extended arguments, looking for flags that select
major features. This can override the environment variable
settings. */
vpi_get_vlog_info(&vlog_info);
for (idx = 0 ; idx < vlog_info.argc ; idx += 1) {
if (strcmp(vlog_info.argv[idx],"-fst") == 0) {
dumper = "fst";
} else if (strcmp(vlog_info.argv[idx],"-fst-space") == 0) {
dumper = "fst";
} else if (strcmp(vlog_info.argv[idx],"-fst-speed") == 0) {
dumper = "fst";
} else if (strcmp(vlog_info.argv[idx],"-fst-space-speed") == 0) {
dumper = "fst";
} else if (strcmp(vlog_info.argv[idx],"-fst-speed-space") == 0) {
dumper = "fst";
} else if (strcmp(vlog_info.argv[idx],"-fst-none") == 0) {
dumper = "none";
} else if (strcmp(vlog_info.argv[idx],"-lxt") == 0) {
dumper = "lxt";
} else if (strcmp(vlog_info.argv[idx],"-lxt-space") == 0) {
dumper = "lxt";
} else if (strcmp(vlog_info.argv[idx],"-lxt-speed") == 0) {
dumper = "lxt";
2003-03-06 21:04:42 +01:00
} else if (strcmp(vlog_info.argv[idx],"-lxt-none") == 0) {
dumper = "none";
2003-09-01 06:04:03 +02:00
} else if (strcmp(vlog_info.argv[idx],"-lxt2") == 0) {
dumper = "lxt2";
} else if (strcmp(vlog_info.argv[idx],"-lxt2-space") == 0) {
dumper = "lxt2";
} else if (strcmp(vlog_info.argv[idx],"-lxt2-speed") == 0) {
dumper = "lxt2";
} else if (strcmp(vlog_info.argv[idx],"-lxt2-none") == 0) {
dumper = "none";
} else if (strcmp(vlog_info.argv[idx],"-lx2") == 0) {
dumper = "lxt2";
} else if (strcmp(vlog_info.argv[idx],"-lx2-space") == 0) {
dumper = "lxt2";
} else if (strcmp(vlog_info.argv[idx],"-lx2-speed") == 0) {
dumper = "lxt2";
} else if (strcmp(vlog_info.argv[idx],"-lx2-none") == 0) {
dumper = "none";
} else if (strcmp(vlog_info.argv[idx],"-vcd") == 0) {
dumper = "vcd";
2003-03-06 21:04:42 +01:00
} else if (strcmp(vlog_info.argv[idx],"-vcd-off") == 0) {
dumper = "none";
} else if (strcmp(vlog_info.argv[idx],"-vcd-none") == 0) {
dumper = "none";
} else if (strcmp(vlog_info.argv[idx],"-none") == 0) {
dumper = "none";
} else if (strncmp(vlog_info.argv[idx],"-dumpfile=",10) == 0) {
vcd_set_dump_path_default(vlog_info.argv[idx]+10);
}
}
2002-04-06 23:33:29 +02:00
if (strcmp(dumper, "vcd") == 0)
sys_vcd_register();
else if (strcmp(dumper, "VCD") == 0)
sys_vcd_register();
else if (strcmp(dumper, "fst") == 0)
sys_fst_register();
else if (strcmp(dumper, "FST") == 0)
sys_fst_register();
2002-04-06 23:33:29 +02:00
else if (strcmp(dumper, "lxt") == 0)
sys_lxt_register();
else if (strcmp(dumper, "LXT") == 0)
sys_lxt_register();
2003-09-01 06:04:03 +02:00
else if (strcmp(dumper, "lxt2") == 0)
sys_lxt2_register();
else if (strcmp(dumper, "LXT2") == 0)
sys_lxt2_register();
else if (strcmp(dumper, "lx2") == 0)
sys_lxt2_register();
else if (strcmp(dumper, "LX2") == 0)
sys_lxt2_register();
2003-03-06 21:04:42 +01:00
else if (strcmp(dumper, "none") == 0)
sys_vcdoff_register();
else if (strcmp(dumper, "NONE") == 0)
sys_vcdoff_register();
2002-04-06 23:33:29 +02:00
else {
vpi_mcd_printf(1, "system.vpi: Unknown dumper format: %s,"
" using VCD instead.\n", dumper);
2002-04-06 23:33:29 +02:00
sys_vcd_register();
}
}
void (*vlog_startup_routines[])(void) = {
2003-03-07 03:44:33 +01:00
sys_convert_register,
sys_countdrivers_register,
sys_darray_register,
2003-10-30 05:52:54 +01:00
sys_fileio_register,
sys_finish_register,
2001-04-26 02:01:33 +02:00
sys_deposit_register,
sys_display_register,
2002-04-07 06:37:53 +02:00
sys_plusargs_register,
Add the stochastic (queue) tasks/function This patch adds full support for the stochastic tasks/functions except the mean inter-arrival and average wait statistics are not currently available. These will be added in a later patch. This implementation goes a bit beyond the standard and supports the following: 1. The job and inform arguments support 32 bit four state values. 2. The id for all routines, the job and inform arguments for $q_add(), the statistic code for $q_exam() along with the queue type and maximum length arguments for $q_initialize() can be less than or equal to 32 bits. The argument will be sign extended if needed to fill the internal 32 bit value. 3. The job and inform arguments to $q_remove() and the status argument for all the routines must be 32 bits, but do not have to be an integer variable (e.g. a 32 bit register or part select is OK). 4. An undefined bit in the id argument for any of the routines will return a status of 2 (undefined queue id). Undefined bits are not automatically converted to zero. 5. Undefined bits in the $q_initialize() queue type and maximum length arguments or the $q_exam() statistic code argument are also flagged as an error (are not converted to zero). 6. The $q_full() function returns 2 on error, the other routines that return a value $q_remove() job/inform arguments and the $q_exam() statistic value argument will usually return x on error. 7. An invalid statistic code will set the $q_exam() status to 8. 8. The $q_exam() statistic value argument can be 32 bits or larger. This allows returning large statistical time values. 9. All time values are internally saved in simulation time units. They will be converted to the calling module's time unit (with rounding) before they are returned. 10. If a $q_exam() statistical value is too large to fit into the variable the maximum positive value will be returned and the status code will be set to 9 (value is too large). 11. If a statistical value is currently undefined $q_exam() will return 10 (no statistical information) (e.g. using code 5 on an empty queue).
2011-04-11 02:16:25 +02:00
sys_queue_register,
sys_random_register,
sys_random_mti_register,
sys_readmem_register,
2006-08-03 07:06:04 +02:00
sys_scanf_register,
2000-11-01 04:19:36 +01:00
sys_time_register,
2002-04-06 23:33:29 +02:00
sys_lxt_or_vcd_register,
sys_sdf_register,
sys_special_register,
table_model_register,
vams_simparam_register,
0
};