2000-04-21 08:41:02 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2000 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
|
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
|
|
|
|
*/
|
|
|
|
|
#if !defined(WINNT)
|
2000-09-12 03:17:19 +02:00
|
|
|
#ident "$Id: iverilog.c,v 1.21 2000/09/12 01:17:19 steve Exp $"
|
2000-04-21 08:41:02 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
2000-07-12 01:30:03 +02:00
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <sys/wait.h>
|
|
|
|
|
|
2000-04-21 08:41:02 +02:00
|
|
|
#ifndef IVL_ROOT
|
|
|
|
|
# define IVL_ROOT "."
|
|
|
|
|
#endif
|
|
|
|
|
|
2000-06-16 21:00:06 +02:00
|
|
|
#ifndef RDYNAMIC
|
|
|
|
|
# define RDYNAMIC "-rdynamic"
|
|
|
|
|
#endif
|
|
|
|
|
|
2000-04-21 08:41:02 +02:00
|
|
|
const char*base = IVL_ROOT;
|
2000-07-29 19:58:20 +02:00
|
|
|
const char*mtm = 0;
|
2000-04-21 08:41:02 +02:00
|
|
|
const char*opath = "a.out";
|
2000-08-09 03:34:00 +02:00
|
|
|
const char*npath = 0;
|
2000-04-21 08:41:02 +02:00
|
|
|
const char*targ = "vvm";
|
2000-04-23 23:14:32 +02:00
|
|
|
const char*start = 0;
|
|
|
|
|
|
2000-05-04 00:14:31 +02:00
|
|
|
char warning_flags[16] = "";
|
|
|
|
|
|
2000-05-05 03:07:42 +02:00
|
|
|
char*inc_list = 0;
|
|
|
|
|
char*def_list = 0;
|
2000-05-17 05:53:29 +02:00
|
|
|
char*mod_list = 0;
|
2000-05-05 03:07:42 +02:00
|
|
|
|
2000-04-29 03:20:14 +02:00
|
|
|
char*f_list = 0;
|
|
|
|
|
|
2000-05-04 00:14:31 +02:00
|
|
|
int synth_flag = 0;
|
2000-04-21 08:41:02 +02:00
|
|
|
int verbose_flag = 0;
|
|
|
|
|
|
2000-04-26 05:33:32 +02:00
|
|
|
char tmp[4096];
|
2000-04-21 08:41:02 +02:00
|
|
|
|
2000-04-26 05:33:32 +02:00
|
|
|
static int t_null(char*cmd, unsigned ncmd)
|
2000-04-22 00:51:38 +02:00
|
|
|
{
|
|
|
|
|
int rc;
|
|
|
|
|
|
2000-05-04 00:14:31 +02:00
|
|
|
sprintf(tmp, " | %s/ivl %s", base, warning_flags);
|
2000-04-26 05:33:32 +02:00
|
|
|
rc = strlen(tmp);
|
|
|
|
|
cmd = realloc(cmd, ncmd+rc+1);
|
|
|
|
|
strcpy(cmd+ncmd, tmp);
|
2000-04-26 23:11:41 +02:00
|
|
|
ncmd += rc;
|
2000-04-26 05:33:32 +02:00
|
|
|
|
2000-04-23 23:14:32 +02:00
|
|
|
if (start) {
|
2000-04-26 05:33:32 +02:00
|
|
|
sprintf(tmp, " -s%s", start);
|
|
|
|
|
rc = strlen(tmp);
|
|
|
|
|
cmd = realloc(cmd, ncmd+rc+1);
|
|
|
|
|
strcpy(cmd+ncmd, tmp);
|
|
|
|
|
ncmd += rc;
|
2000-04-23 23:14:32 +02:00
|
|
|
}
|
2000-04-26 05:33:32 +02:00
|
|
|
|
2000-08-09 03:34:00 +02:00
|
|
|
if (npath) {
|
|
|
|
|
sprintf(tmp, " -N%s", npath);
|
|
|
|
|
rc = strlen(tmp);
|
|
|
|
|
cmd = realloc(cmd, ncmd+rc+1);
|
|
|
|
|
strcpy(cmd+ncmd, tmp);
|
|
|
|
|
ncmd += rc;
|
|
|
|
|
}
|
|
|
|
|
|
2000-07-29 19:58:20 +02:00
|
|
|
if (mtm) {
|
|
|
|
|
sprintf(tmp, " -T%s", mtm);
|
|
|
|
|
rc = strlen(tmp);
|
|
|
|
|
cmd = realloc(cmd, ncmd+rc+1);
|
|
|
|
|
strcpy(cmd+ncmd, tmp);
|
|
|
|
|
ncmd += rc;
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-26 05:33:32 +02:00
|
|
|
if (verbose_flag) {
|
|
|
|
|
sprintf(tmp, " -v");
|
|
|
|
|
rc = strlen(tmp);
|
|
|
|
|
cmd = realloc(cmd, ncmd+rc+1);
|
|
|
|
|
strcpy(cmd+ncmd, tmp);
|
|
|
|
|
ncmd += rc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sprintf(tmp, " -- -");
|
|
|
|
|
rc = strlen(tmp);
|
|
|
|
|
cmd = realloc(cmd, ncmd+rc+1);
|
|
|
|
|
strcpy(cmd+ncmd, tmp);
|
|
|
|
|
ncmd += rc;
|
2000-04-22 00:51:38 +02:00
|
|
|
|
|
|
|
|
if (verbose_flag)
|
2000-04-26 05:33:32 +02:00
|
|
|
printf("translate: %s\n", cmd);
|
2000-04-22 00:51:38 +02:00
|
|
|
|
2000-04-26 05:33:32 +02:00
|
|
|
rc = system(cmd);
|
2000-07-12 01:30:03 +02:00
|
|
|
if (rc != 0) {
|
|
|
|
|
if (WIFEXITED(rc))
|
|
|
|
|
return WEXITSTATUS(rc);
|
|
|
|
|
|
|
|
|
|
fprintf(stderr, "Command signaled: %s\n", cmd);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
2000-04-22 00:51:38 +02:00
|
|
|
}
|
|
|
|
|
|
2000-04-21 08:41:02 +02:00
|
|
|
/*
|
|
|
|
|
* This function handles the vvm target. After preprocessing, run the
|
|
|
|
|
* ivl translator to get C++, then run g++ to make an executable
|
|
|
|
|
* program out of that.
|
|
|
|
|
*/
|
2000-04-26 05:33:32 +02:00
|
|
|
static int t_vvm(char*cmd, unsigned ncmd)
|
2000-04-21 08:41:02 +02:00
|
|
|
{
|
|
|
|
|
int rc;
|
|
|
|
|
|
2000-05-04 00:14:31 +02:00
|
|
|
sprintf(tmp, " | %s/ivl %s -o %s.cc -tvvm -Fcprop %s -Fnodangle"
|
|
|
|
|
" -fVPI_MODULE_PATH=%s", base, warning_flags, opath,
|
2000-05-13 22:55:47 +02:00
|
|
|
synth_flag?"-Fsynth -Fsyn-rules":"", base);
|
2000-04-26 05:33:32 +02:00
|
|
|
|
|
|
|
|
rc = strlen(tmp);
|
|
|
|
|
cmd = realloc(cmd, ncmd+rc+1);
|
|
|
|
|
strcpy(cmd+ncmd, tmp);
|
|
|
|
|
ncmd += rc;
|
|
|
|
|
|
2000-04-29 03:20:14 +02:00
|
|
|
if (f_list) {
|
|
|
|
|
rc = strlen(f_list);
|
|
|
|
|
cmd = realloc(cmd, ncmd+rc+1);
|
2000-05-14 21:41:52 +02:00
|
|
|
strcpy(cmd+ncmd, f_list);
|
2000-04-29 03:20:14 +02:00
|
|
|
ncmd += rc;
|
|
|
|
|
}
|
|
|
|
|
|
2000-05-17 05:53:29 +02:00
|
|
|
if (mod_list) {
|
|
|
|
|
rc = strlen(mod_list);
|
|
|
|
|
cmd = realloc(cmd, ncmd+rc+1);
|
|
|
|
|
strcpy(cmd+ncmd, mod_list);
|
|
|
|
|
ncmd += rc;
|
|
|
|
|
}
|
|
|
|
|
|
2000-07-29 19:58:20 +02:00
|
|
|
if (mtm) {
|
|
|
|
|
sprintf(tmp, " -T%s", mtm);
|
|
|
|
|
rc = strlen(tmp);
|
|
|
|
|
cmd = realloc(cmd, ncmd+rc+1);
|
|
|
|
|
strcpy(cmd+ncmd, tmp);
|
|
|
|
|
ncmd += rc;
|
|
|
|
|
}
|
|
|
|
|
|
2000-08-09 03:34:00 +02:00
|
|
|
if (npath) {
|
|
|
|
|
sprintf(tmp, " -N%s", npath);
|
|
|
|
|
rc = strlen(tmp);
|
|
|
|
|
cmd = realloc(cmd, ncmd+rc+1);
|
|
|
|
|
strcpy(cmd+ncmd, tmp);
|
|
|
|
|
ncmd += rc;
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-23 23:14:32 +02:00
|
|
|
if (start) {
|
2000-04-26 05:33:32 +02:00
|
|
|
sprintf(tmp, " -s%s", start);
|
|
|
|
|
rc = strlen(tmp);
|
|
|
|
|
cmd = realloc(cmd, ncmd+rc+1);
|
|
|
|
|
strcpy(cmd+ncmd, tmp);
|
|
|
|
|
ncmd += rc;
|
2000-04-23 23:14:32 +02:00
|
|
|
}
|
2000-04-26 05:33:32 +02:00
|
|
|
sprintf(tmp, " -- -");
|
|
|
|
|
rc = strlen(tmp);
|
|
|
|
|
cmd = realloc(cmd, ncmd+rc+1);
|
|
|
|
|
strcpy(cmd+ncmd, tmp);
|
|
|
|
|
ncmd += rc;
|
|
|
|
|
|
2000-04-21 08:41:02 +02:00
|
|
|
if (verbose_flag)
|
2000-04-26 05:33:32 +02:00
|
|
|
printf("translate: %s\n", cmd);
|
2000-04-21 08:41:02 +02:00
|
|
|
|
2000-04-26 05:33:32 +02:00
|
|
|
rc = system(cmd);
|
2000-04-21 08:41:02 +02:00
|
|
|
if (rc != 0) {
|
2000-07-12 01:30:03 +02:00
|
|
|
if (WIFEXITED(rc)) {
|
|
|
|
|
fprintf(stderr, "errors translating Verilog program.\n");
|
|
|
|
|
return WEXITSTATUS(rc);
|
|
|
|
|
} else {
|
|
|
|
|
fprintf(stderr, "Command signaled: %s\n", cmd);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2000-04-21 08:41:02 +02:00
|
|
|
}
|
|
|
|
|
|
2000-06-16 21:00:06 +02:00
|
|
|
sprintf(tmp, "%s -O " RDYNAMIC " -fno-exceptions -o %s -I%s "
|
2000-05-09 02:02:13 +02:00
|
|
|
"-L%s %s.cc -lvvm %s", CXX, opath, IVL_INC, IVL_LIB,
|
2000-05-02 01:55:22 +02:00
|
|
|
opath, DLLIB);
|
2000-04-21 08:41:02 +02:00
|
|
|
|
|
|
|
|
if (verbose_flag)
|
2000-04-26 05:33:32 +02:00
|
|
|
printf("compile: %s\n", tmp);
|
2000-04-21 08:41:02 +02:00
|
|
|
|
2000-04-26 05:33:32 +02:00
|
|
|
rc = system(tmp);
|
2000-04-21 08:41:02 +02:00
|
|
|
if (rc != 0) {
|
2000-07-12 01:30:03 +02:00
|
|
|
if (WIFEXITED(rc)) {
|
|
|
|
|
fprintf(stderr, "errors compiling translated program.\n");
|
|
|
|
|
return WEXITSTATUS(rc);
|
|
|
|
|
} else {
|
|
|
|
|
fprintf(stderr, "Command signaled: %s\n", tmp);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2000-04-21 08:41:02 +02:00
|
|
|
}
|
|
|
|
|
|
2000-04-26 05:33:32 +02:00
|
|
|
sprintf(tmp, "%s.cc", opath);
|
|
|
|
|
unlink(tmp);
|
2000-04-21 08:41:02 +02:00
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-26 05:33:32 +02:00
|
|
|
static int t_xnf(char*cmd, unsigned ncmd)
|
2000-04-21 08:41:02 +02:00
|
|
|
{
|
|
|
|
|
int rc;
|
|
|
|
|
|
2000-05-13 22:55:47 +02:00
|
|
|
sprintf(tmp, " | %s/ivl %s -o %s -txnf -Fcprop -Fsynth -Fsyn-rules "
|
2000-05-04 00:14:31 +02:00
|
|
|
"-Fnodangle -Fxnfio", base, warning_flags, opath);
|
2000-04-26 05:33:32 +02:00
|
|
|
|
|
|
|
|
rc = strlen(tmp);
|
|
|
|
|
cmd = realloc(cmd, ncmd+rc+1);
|
|
|
|
|
strcpy(cmd+ncmd, tmp);
|
|
|
|
|
ncmd += rc;
|
|
|
|
|
|
2000-04-29 03:20:14 +02:00
|
|
|
if (f_list) {
|
|
|
|
|
rc = strlen(f_list);
|
|
|
|
|
cmd = realloc(cmd, ncmd+rc+1);
|
2000-05-14 21:41:52 +02:00
|
|
|
strcpy(cmd+ncmd, f_list);
|
2000-04-29 03:20:14 +02:00
|
|
|
ncmd += rc;
|
|
|
|
|
}
|
|
|
|
|
|
2000-07-29 19:58:20 +02:00
|
|
|
if (mtm) {
|
|
|
|
|
sprintf(tmp, " -T%s", mtm);
|
|
|
|
|
rc = strlen(tmp);
|
|
|
|
|
cmd = realloc(cmd, ncmd+rc+1);
|
|
|
|
|
strcpy(cmd+ncmd, tmp);
|
|
|
|
|
ncmd += rc;
|
|
|
|
|
}
|
|
|
|
|
|
2000-08-09 03:34:00 +02:00
|
|
|
if (npath) {
|
|
|
|
|
sprintf(tmp, " -N%s", npath);
|
|
|
|
|
rc = strlen(tmp);
|
|
|
|
|
cmd = realloc(cmd, ncmd+rc+1);
|
|
|
|
|
strcpy(cmd+ncmd, tmp);
|
|
|
|
|
ncmd += rc;
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-23 23:14:32 +02:00
|
|
|
if (start) {
|
2000-04-26 05:33:32 +02:00
|
|
|
sprintf(tmp, " -s%s", start);
|
|
|
|
|
rc = strlen(tmp);
|
|
|
|
|
cmd = realloc(cmd, ncmd+rc+1);
|
|
|
|
|
strcpy(cmd+ncmd, tmp);
|
|
|
|
|
ncmd += rc;
|
2000-04-23 23:14:32 +02:00
|
|
|
}
|
2000-04-26 05:33:32 +02:00
|
|
|
sprintf(tmp, " -- -");
|
|
|
|
|
rc = strlen(tmp);
|
|
|
|
|
cmd = realloc(cmd, ncmd+rc+1);
|
|
|
|
|
strcpy(cmd+ncmd, tmp);
|
|
|
|
|
ncmd += rc;
|
|
|
|
|
|
2000-04-21 08:41:02 +02:00
|
|
|
if (verbose_flag)
|
2000-04-26 05:33:32 +02:00
|
|
|
printf("translate: %s\n", cmd);
|
|
|
|
|
|
|
|
|
|
rc = system(cmd);
|
2000-07-12 01:30:03 +02:00
|
|
|
if (rc != 0) {
|
|
|
|
|
if (WIFEXITED(rc)) {
|
|
|
|
|
fprintf(stderr, "errors translating Verilog program.\n");
|
|
|
|
|
return WEXITSTATUS(rc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fprintf(stderr, "Command signaled: %s\n", cmd);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2000-04-21 08:41:02 +02:00
|
|
|
|
2000-07-12 01:30:03 +02:00
|
|
|
return 0;
|
2000-04-21 08:41:02 +02:00
|
|
|
}
|
|
|
|
|
|
2000-05-04 00:14:31 +02:00
|
|
|
static void process_warning_switch(const char*name)
|
|
|
|
|
{
|
|
|
|
|
if (warning_flags[0] == 0)
|
|
|
|
|
strcpy(warning_flags, "-W");
|
|
|
|
|
|
|
|
|
|
if (strcmp(name,"all") == 0) {
|
|
|
|
|
strcat(warning_flags, "i");
|
|
|
|
|
|
|
|
|
|
} else if (strcmp(name,"implicit") == 0) {
|
|
|
|
|
if (! strchr(warning_flags+2, 'i'))
|
|
|
|
|
strcat(warning_flags, "i");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-21 08:41:02 +02:00
|
|
|
int main(int argc, char **argv)
|
|
|
|
|
{
|
2000-04-26 05:33:32 +02:00
|
|
|
char*cmd;
|
|
|
|
|
unsigned ncmd;
|
2000-04-21 08:41:02 +02:00
|
|
|
int e_flag = 0;
|
|
|
|
|
int opt, idx;
|
|
|
|
|
char*cp;
|
|
|
|
|
|
2000-09-12 03:17:19 +02:00
|
|
|
while ((opt = getopt(argc, argv, "B:D:Ef:I:m:N::o:Ss:T:t:vW:")) != EOF) {
|
2000-04-21 08:41:02 +02:00
|
|
|
|
|
|
|
|
switch (opt) {
|
|
|
|
|
case 'B':
|
|
|
|
|
base = optarg;
|
|
|
|
|
break;
|
2000-05-05 03:07:42 +02:00
|
|
|
case 'D':
|
|
|
|
|
if (def_list == 0) {
|
|
|
|
|
def_list = malloc(strlen(" -D")+strlen(optarg)+1);
|
|
|
|
|
strcpy(def_list, " -D");
|
|
|
|
|
strcat(def_list, optarg);
|
|
|
|
|
} else {
|
|
|
|
|
def_list = realloc(def_list, strlen(def_list)
|
|
|
|
|
+ strlen(" -D")
|
|
|
|
|
+ strlen(optarg) + 1);
|
|
|
|
|
strcat(def_list, " -D");
|
|
|
|
|
strcat(def_list, optarg);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2000-04-21 08:41:02 +02:00
|
|
|
case 'E':
|
|
|
|
|
e_flag = 1;
|
|
|
|
|
break;
|
2000-04-29 03:20:14 +02:00
|
|
|
case 'f':
|
|
|
|
|
if (f_list == 0) {
|
2000-05-14 21:41:52 +02:00
|
|
|
f_list = malloc(strlen(" -f")+strlen(optarg)+1);
|
|
|
|
|
strcpy(f_list, " -f");
|
2000-04-29 03:20:14 +02:00
|
|
|
strcat(f_list, optarg);
|
|
|
|
|
} else {
|
|
|
|
|
f_list = realloc(f_list, strlen(f_list) +
|
|
|
|
|
strlen(" -f") +
|
|
|
|
|
strlen(optarg) + 1);
|
|
|
|
|
strcat(f_list, " -f");
|
|
|
|
|
strcat(f_list, optarg);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2000-05-05 03:07:42 +02:00
|
|
|
case 'I':
|
|
|
|
|
if (inc_list == 0) {
|
|
|
|
|
inc_list = malloc(strlen(" -I")+strlen(optarg)+1);
|
|
|
|
|
strcpy(inc_list, " -I");
|
|
|
|
|
strcat(inc_list, optarg);
|
|
|
|
|
} else {
|
|
|
|
|
inc_list = realloc(inc_list, strlen(inc_list)
|
|
|
|
|
+ strlen(" -I")
|
|
|
|
|
+ strlen(optarg) + 1);
|
|
|
|
|
strcat(inc_list, " -I");
|
|
|
|
|
strcat(inc_list, optarg);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2000-05-17 05:53:29 +02:00
|
|
|
case 'm':
|
|
|
|
|
if (mod_list == 0) {
|
|
|
|
|
mod_list = malloc(strlen(" -m")+strlen(optarg)+1);
|
|
|
|
|
strcpy(mod_list, " -m");
|
|
|
|
|
strcat(mod_list, optarg);
|
|
|
|
|
} else {
|
|
|
|
|
mod_list = realloc(mod_list, strlen(mod_list)
|
|
|
|
|
+ strlen(" -m")
|
|
|
|
|
+ strlen(optarg) + 1);
|
|
|
|
|
strcat(mod_list, " -m");
|
|
|
|
|
strcat(mod_list, optarg);
|
|
|
|
|
}
|
|
|
|
|
break;
|
2000-08-09 03:34:00 +02:00
|
|
|
|
|
|
|
|
case 'N':
|
|
|
|
|
npath = optarg;
|
|
|
|
|
break;
|
|
|
|
|
|
2000-04-21 08:41:02 +02:00
|
|
|
case 'o':
|
|
|
|
|
opath = optarg;
|
|
|
|
|
break;
|
2000-08-09 03:34:00 +02:00
|
|
|
|
2000-05-04 00:14:31 +02:00
|
|
|
case 'S':
|
|
|
|
|
synth_flag = 1;
|
|
|
|
|
break;
|
2000-04-23 23:14:32 +02:00
|
|
|
case 's':
|
|
|
|
|
start = optarg;
|
|
|
|
|
break;
|
2000-07-29 19:58:20 +02:00
|
|
|
case 'T':
|
|
|
|
|
if (strcmp(optarg,"min") == 0) {
|
|
|
|
|
mtm = "min";
|
|
|
|
|
} else if (strcmp(optarg,"typ") == 0) {
|
|
|
|
|
mtm = "typ";
|
|
|
|
|
} else if (strcmp(optarg,"max") == 0) {
|
|
|
|
|
mtm = "max";
|
|
|
|
|
} else {
|
|
|
|
|
fprintf(stderr, "%s: invalid -T%s argument\n",
|
|
|
|
|
argv[0], optarg);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
break;
|
2000-04-21 08:41:02 +02:00
|
|
|
case 't':
|
|
|
|
|
targ = optarg;
|
|
|
|
|
break;
|
|
|
|
|
case 'v':
|
|
|
|
|
verbose_flag = 1;
|
|
|
|
|
break;
|
2000-05-04 00:14:31 +02:00
|
|
|
case 'W':
|
|
|
|
|
process_warning_switch(optarg);
|
|
|
|
|
break;
|
2000-04-21 08:41:02 +02:00
|
|
|
case '?':
|
|
|
|
|
default:
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-23 23:14:32 +02:00
|
|
|
if (optind == argc) {
|
|
|
|
|
fprintf(stderr, "%s: No input files.\n", argv[0]);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-26 05:33:32 +02:00
|
|
|
/* Start building the preprocess command line. */
|
|
|
|
|
|
2000-05-04 22:08:20 +02:00
|
|
|
sprintf(tmp, "%s/ivlpp %s%s", base,
|
|
|
|
|
verbose_flag?" -v":"",
|
|
|
|
|
e_flag?"":" -L");
|
2000-04-26 05:33:32 +02:00
|
|
|
|
|
|
|
|
ncmd = strlen(tmp);
|
|
|
|
|
cmd = malloc(ncmd + 1);
|
2000-04-26 23:11:41 +02:00
|
|
|
strcpy(cmd, tmp);
|
2000-04-26 05:33:32 +02:00
|
|
|
|
2000-05-05 03:07:42 +02:00
|
|
|
if (inc_list) {
|
|
|
|
|
cmd = realloc(cmd, ncmd + strlen(inc_list) + 1);
|
|
|
|
|
strcat(cmd, inc_list);
|
|
|
|
|
ncmd += strlen(inc_list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (def_list) {
|
|
|
|
|
cmd = realloc(cmd, ncmd + strlen(def_list) + 1);
|
|
|
|
|
strcat(cmd, def_list);
|
|
|
|
|
ncmd += strlen(def_list);
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-26 05:33:32 +02:00
|
|
|
/* Add all the verilog source files to the preprocess command line. */
|
|
|
|
|
|
2000-04-21 08:41:02 +02:00
|
|
|
for (idx = optind ; idx < argc ; idx += 1) {
|
2000-04-26 05:33:32 +02:00
|
|
|
sprintf(tmp, " %s", argv[idx]);
|
|
|
|
|
cmd = realloc(cmd, ncmd+strlen(tmp)+1);
|
2000-04-26 23:11:41 +02:00
|
|
|
strcpy(cmd+ncmd, tmp);
|
2000-04-26 05:33:32 +02:00
|
|
|
ncmd += strlen(tmp);
|
2000-04-21 08:41:02 +02:00
|
|
|
}
|
|
|
|
|
|
2000-04-26 05:33:32 +02:00
|
|
|
|
2000-04-21 08:41:02 +02:00
|
|
|
/* If the -E flag was given on the command line, then all we
|
|
|
|
|
do is run the preprocessor and put the output where the
|
|
|
|
|
user wants it. */
|
|
|
|
|
if (e_flag) {
|
2000-07-12 01:30:03 +02:00
|
|
|
int rc;
|
2000-04-21 08:41:02 +02:00
|
|
|
if (strcmp(opath,"-") != 0) {
|
2000-04-26 05:33:32 +02:00
|
|
|
sprintf(tmp, " > %s", opath);
|
|
|
|
|
cmd = realloc(cmd, ncmd+strlen(tmp)+1);
|
|
|
|
|
strcpy(cmd+ncmd, tmp);
|
|
|
|
|
ncmd += strlen(tmp);
|
2000-04-21 08:41:02 +02:00
|
|
|
}
|
2000-04-26 05:33:32 +02:00
|
|
|
|
2000-04-21 08:41:02 +02:00
|
|
|
if (verbose_flag)
|
2000-04-26 05:33:32 +02:00
|
|
|
printf("preprocess: %s\n", cmd);
|
2000-04-21 08:41:02 +02:00
|
|
|
|
2000-07-12 01:30:03 +02:00
|
|
|
rc = system(cmd);
|
|
|
|
|
if (rc != 0) {
|
|
|
|
|
if (WIFEXITED(rc)) {
|
|
|
|
|
fprintf(stderr, "errors preprocessing Verilog program.\n");
|
|
|
|
|
return WEXITSTATUS(rc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fprintf(stderr, "Command signaled: %s\n", cmd);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
2000-04-21 08:41:02 +02:00
|
|
|
}
|
|
|
|
|
|
2000-04-22 00:51:38 +02:00
|
|
|
if (strcmp(targ,"null") == 0)
|
2000-04-26 05:33:32 +02:00
|
|
|
return t_null(cmd, ncmd);
|
2000-04-22 00:51:38 +02:00
|
|
|
else if (strcmp(targ,"vvm") == 0)
|
2000-04-26 05:33:32 +02:00
|
|
|
return t_vvm(cmd, ncmd);
|
2000-04-21 08:41:02 +02:00
|
|
|
else if (strcmp(targ,"xnf") == 0)
|
2000-04-26 05:33:32 +02:00
|
|
|
return t_xnf(cmd, ncmd);
|
2000-04-21 08:41:02 +02:00
|
|
|
else {
|
|
|
|
|
fprintf(stderr, "Unknown target: %s\n", targ);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* $Log: iverilog.c,v $
|
2000-09-12 03:17:19 +02:00
|
|
|
* Revision 1.21 2000/09/12 01:17:19 steve
|
|
|
|
|
* Oops, the -m flag takes a parameter and needs the :
|
|
|
|
|
*
|
2000-08-09 03:34:00 +02:00
|
|
|
* Revision 1.20 2000/08/09 01:34:00 steve
|
|
|
|
|
* Add the -N switch to the iverilog command.
|
|
|
|
|
*
|
2000-07-29 19:58:20 +02:00
|
|
|
* Revision 1.19 2000/07/29 17:58:20 steve
|
|
|
|
|
* Introduce min:typ:max support.
|
|
|
|
|
*
|
2000-07-12 01:30:03 +02:00
|
|
|
* Revision 1.18 2000/07/11 23:30:03 steve
|
|
|
|
|
* More detailed handling of exit status from commands.
|
|
|
|
|
*
|
2000-06-30 06:42:23 +02:00
|
|
|
* Revision 1.17 2000/06/30 04:42:23 steve
|
|
|
|
|
* Catch errors from compile that leave the low 8 bits empty.
|
|
|
|
|
*
|
2000-06-16 21:00:06 +02:00
|
|
|
* Revision 1.16 2000/06/16 19:00:06 steve
|
|
|
|
|
* Detect some hosts that do not support -rdynamic.
|
|
|
|
|
*
|
2000-05-17 05:53:29 +02:00
|
|
|
* Revision 1.15 2000/05/17 03:53:29 steve
|
|
|
|
|
* Add the module option to iverilog.
|
|
|
|
|
*
|
2000-05-14 21:41:52 +02:00
|
|
|
* Revision 1.14 2000/05/14 19:41:52 steve
|
|
|
|
|
* Fix -f flag handling.
|
|
|
|
|
*
|
2000-05-13 22:55:47 +02:00
|
|
|
* Revision 1.13 2000/05/13 20:55:47 steve
|
|
|
|
|
* Use yacc based synthesizer.
|
|
|
|
|
*
|
2000-05-09 02:02:13 +02:00
|
|
|
* Revision 1.12 2000/05/09 00:02:13 steve
|
|
|
|
|
* Parameterize LD lib in C++ command line.
|
|
|
|
|
*
|
2000-05-05 03:07:42 +02:00
|
|
|
* Revision 1.11 2000/05/05 01:07:42 steve
|
|
|
|
|
* Add the -I and -D switches to iverilog.
|
|
|
|
|
*
|
2000-05-04 22:08:20 +02:00
|
|
|
* Revision 1.10 2000/05/04 20:08:20 steve
|
|
|
|
|
* Tell ivlpp to generate line number directives.
|
|
|
|
|
*
|
2000-05-04 00:14:31 +02:00
|
|
|
* Revision 1.9 2000/05/03 22:14:31 steve
|
|
|
|
|
* More features of ivl available through iverilog.
|
|
|
|
|
*
|
2000-05-02 01:55:22 +02:00
|
|
|
* Revision 1.8 2000/05/01 23:55:22 steve
|
|
|
|
|
* Better inc and lib paths for iverilog.
|
|
|
|
|
*
|
2000-04-29 03:20:14 +02:00
|
|
|
* Revision 1.7 2000/04/29 01:20:14 steve
|
|
|
|
|
* The -f flag is now in place.
|
|
|
|
|
*
|
2000-04-26 23:11:41 +02:00
|
|
|
* Revision 1.6 2000/04/26 21:11:41 steve
|
|
|
|
|
* Mussed up command string mashing.
|
|
|
|
|
*
|
2000-04-26 05:33:32 +02:00
|
|
|
* Revision 1.5 2000/04/26 03:33:32 steve
|
|
|
|
|
* Do not set width too small to hold significant bits.
|
|
|
|
|
*
|
2000-04-23 23:14:32 +02:00
|
|
|
* Revision 1.4 2000/04/23 21:14:32 steve
|
|
|
|
|
* The -s flag.
|
|
|
|
|
*
|
2000-04-22 00:54:47 +02:00
|
|
|
* Revision 1.3 2000/04/21 22:54:47 steve
|
|
|
|
|
* module path in vvm target.
|
|
|
|
|
*
|
2000-04-22 00:51:38 +02:00
|
|
|
* Revision 1.2 2000/04/21 22:51:38 steve
|
|
|
|
|
* Support the -tnull target type.
|
|
|
|
|
*
|
2000-04-21 08:41:02 +02:00
|
|
|
* Revision 1.1 2000/04/21 06:41:03 steve
|
|
|
|
|
* Add the iverilog driver program.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|