Merge branch 'master' of ssh://steve-icarus@icarus.com/home/u/icarus/steve/git/verilog

This commit is contained in:
Stephen Williams 2008-01-08 17:16:38 -08:00
commit 1db3c75ce6
21 changed files with 288 additions and 251 deletions

View File

@ -103,11 +103,12 @@ bool PWire::set_port_type(NetNet::PortType pt)
bool PWire::set_data_type(ivl_variable_type_t dt)
{
if (data_type_ != IVL_VT_NO_TYPE)
if (data_type_ != IVL_VT_NO_TYPE) {
if (data_type_ != dt)
return false;
else
return true;
}
assert(data_type_ == IVL_VT_NO_TYPE);
data_type_ = dt;

View File

@ -16,12 +16,12 @@
# 59 Temple Place - Suite 330
# Boston, MA 02111-1307, USA
#
#ident "$Id: Makefile.in,v 1.7 2004/10/13 22:01:34 steve Exp $"
#ident "$Id: Makefile.in,v 1.7.2.1 2006/10/04 17:08:59 steve Exp $"
#
#
SHELL = /bin/sh
VERSION = 0.8
VERSION = 0.8.3
prefix = @prefix@
exec_prefix = @exec_prefix@
@ -48,7 +48,7 @@ LDFLAGS = @LDFLAGS@
all: iverilog-vpi@EXEEXT@
clean:
rm -f *.o
rm -f *.o config.h
rm -f iverilog-vpi@EXEEXT@
distclean: clean
@ -60,9 +60,14 @@ iverilog-vpi@EXEEXT@: $O
$(CC) $(LDFLAGS) $O -o iverilog-vpi@EXEEXT@ @EXTRALIBS@
main.o: main.c
main.o: main.c config.h
$(CC) $(CPPFLAGS) $(CFLAGS) -c $(srcdir)/main.c
config.h: config.h.in
sed -e 's;@IVLCC@;@CC@;' -e 's;@IVLCXX@;@CXX@;' \
-e 's;@IVLCFLAGS@;@CXXFLAGS@;' \
-e 's;@SHARED@;@shared@;' $< > $@
# Windows specific...
res.o: res.rc
windres -i res.rc -o res.o

8
driver-vpi/config.h.in Normal file
View File

@ -0,0 +1,8 @@
/* For now do not put the Icarus Verilog include or library paths here.
* They are generated from a registry entry the user must set (-ivl=).
* This may change in the future once I have thought about it more. */
#define IVERILOG_VPI_CC "@IVLCC@"
#define IVERILOG_VPI_CXX "@IVLCXX@"
#define IVERILOG_VPI_CFLAGS " @IVLCFLAGS@"
#define IVERILOG_VPI_LDFLAGS "@SHARED@"
#define IVERILOG_VPI_LDLIBS "-lveriuser -lvpi"

View File

@ -32,28 +32,27 @@
#include <windows.h>
/* Macros used for compiling and linking */
static void setup_ivl_environment();
#define IVERILOG_VPI_CC "gcc" /* no .exe extension */
#define IVERILOG_VPI_CXX "gcc" /* no .exe extension */
#define IVERILOG_VPI_CFLAGS "-O" /* -I appended later */
#define IVERILOG_VPI_LD "gcc" /* no .exe extension */
#define IVERILOG_VPI_LDFLAGS "-shared -Wl,--enable-auto-image-base"
#define IVERILOG_VPI_LDLIBS "-lveriuser -lvpi" /* -L prepended later */
/* The compile options: compiler, flags, etc. are in here */
#include "config.h"
/* pointers to global strings */
static struct global_strings {
char *pCCSRC; /* list of C source files */
char *pCXSRC; /* list of C++ source files */
char *pCCSRC; /* list of C source files (*.c) */
char *pCXSRC; /* list of C++ source files (*.cc, *.cpp) */
char *pOBJ; /* list of object files */
char *pLIB; /* list of library files */
char *pINCS; /* list of include directories */
char *pDEFS; /* list of definitions */
char *pOUT; /* output file name (.vpi extension), if 0 length then no source files specified */
char *pMINGW; /* path to MinGW directory */
char *pIVL; /* path to IVL directory */
char *pCFLAGS; /* CFLAGS option */
char *pLDLIBS; /* LDLIBS option */
char *pNewPath; /* new PATH environment variable setting */
char *pLD; /* what to use for a linker */
} gstr;
@ -70,6 +69,8 @@ static void myExit(int exitVal)
deInitDynString(gstr.pCXSRC);
deInitDynString(gstr.pOBJ);
deInitDynString(gstr.pLIB);
deInitDynString(gstr.pINCS);
deInitDynString(gstr.pDEFS);
deInitDynString(gstr.pOUT);
deInitDynString(gstr.pMINGW);
deInitDynString(gstr.pIVL);
@ -84,7 +85,7 @@ static void myExit(int exitVal)
static void usage()
{
fprintf(stderr,"usage: iverilog-vpi [--name=name] [-llibrary] [-mingw=dir] [-ivl=dir] sourcefile...\n");
fprintf(stderr,"usage: iverilog-vpi [src and obj files]...\n");
fprintf(stderr," or iverilog-vpi -mingw=dir\n");
fprintf(stderr," or iverilog-vpi -ivl=dir\n");
myExit(1);
@ -110,12 +111,16 @@ static void init()
initDynString(&gstr.pCXSRC);
initDynString(&gstr.pOBJ);
initDynString(&gstr.pLIB);
initDynString(&gstr.pINCS);
initDynString(&gstr.pDEFS);
initDynString(&gstr.pOUT);
initDynString(&gstr.pMINGW);
initDynString(&gstr.pIVL);
initDynString(&gstr.pCFLAGS);
initDynString(&gstr.pLDLIBS);
initDynString(&gstr.pNewPath);
/* By default use the C compiler to link the programs. */
gstr.pLD = IVERILOG_VPI_CC;
}
/* return true if "str" is terminated with with "end", case insensitive */
@ -281,67 +286,120 @@ static int parse(int argc, char *argv[])
char dot_o_ext[] = ".o";
char name_option[] = "--name=";
char lib_option[] = "-l";
char inc_option[] = "-I";
char mingw_option[] = "-mingw=";
char ivl_option[] = "-ivl=";
char def_option[] = "-D";
if (argc == 1)
return 0;
if (argc == 1) return 0;
for (idx=1; idx<argc; ++idx) {
if (endsIn(dot_c_ext,argv[idx])) { /* check for C source files */
/* Check for C source files (*.c) */
if (endsIn(dot_c_ext, argv[idx])) {
++srcFileCnt;
append(&gstr.pCCSRC,argv[idx]);
append(&gstr.pCCSRC," ");
append(&gstr.pCCSRC, argv[idx]);
append(&gstr.pCCSRC, " ");
if (!*gstr.pOUT)
assignn(&gstr.pOUT,argv[idx],strlen(argv[idx])-strlen(dot_c_ext));
assignn(&gstr.pOUT, argv[idx],
strlen(argv[idx])-strlen(dot_c_ext));
}
else if (endsIn(dot_cc_ext,argv[idx])) { /* check for C++ source files */
/* Check for C++ source files (*.cc) */
else if (endsIn(dot_cc_ext, argv[idx])) {
/* We need to link with the C++ compiler. */
gstr.pLD = IVERILOG_VPI_CXX;
++srcFileCnt;
append(&gstr.pCXSRC,argv[idx]);
append(&gstr.pCXSRC," ");
append(&gstr.pCXSRC, argv[idx]);
append(&gstr.pCXSRC, " ");
if (!*gstr.pOUT)
assignn(&gstr.pOUT,argv[idx],strlen(argv[idx])-strlen(dot_cc_ext));
assignn(&gstr.pOUT, argv[idx],
strlen(argv[idx])-strlen(dot_cc_ext));
}
else if (endsIn(dot_cpp_ext,argv[idx])) { /* check for C++ source files */
/* Check for C++ source files (*.cpp) */
else if (endsIn(dot_cpp_ext, argv[idx])) {
/* We need to link with the C++ compiler. */
gstr.pLD = IVERILOG_VPI_CXX;
++srcFileCnt;
append(&gstr.pCXSRC,argv[idx]);
append(&gstr.pCXSRC," ");
append(&gstr.pCXSRC, argv[idx]);
append(&gstr.pCXSRC, " ");
if (!*gstr.pOUT)
assignn(&gstr.pOUT,argv[idx],strlen(argv[idx])-strlen(dot_cpp_ext));
assignn(&gstr.pOUT, argv[idx],
strlen(argv[idx])-strlen(dot_cpp_ext));
}
else if (endsIn(dot_o_ext,argv[idx])) { /* check for compiled object files */
/* Check for compiled object files */
else if (endsIn(dot_o_ext, argv[idx])) {
++srcFileCnt;
append(&gstr.pOBJ,argv[idx]);
append(&gstr.pOBJ," ");
append(&gstr.pOBJ, argv[idx]);
if (!*gstr.pOUT)
assignn(&gstr.pOUT,argv[idx],strlen(argv[idx])-strlen(dot_o_ext));
assignn(&gstr.pOUT, argv[idx],
strlen(argv[idx])-strlen(dot_o_ext));
}
else if (startsWith(name_option,argv[idx])) { /* check for --name option */
assignn(&gstr.pOUT,argv[idx]+sizeof(name_option)-1,strlen(argv[idx])-(sizeof(name_option)-1));
/* Check for the --name option */
else if (startsWith(name_option, argv[idx])) {
assignn(&gstr.pOUT, argv[idx]+sizeof(name_option)-1,
strlen(argv[idx])-(sizeof(name_option)-1));
}
else if (startsWith(lib_option,argv[idx])) { /* check for -l option */
append(&gstr.pLIB,argv[idx]);
append(&gstr.pLIB," ");
/* Check for the -l option */
else if (startsWith(lib_option, argv[idx])) {
append(&gstr.pLIB, " ");
append(&gstr.pLIB, argv[idx]);
}
else if (startsWith(mingw_option,argv[idx])) /* check for -mingw option */
assignn(&gstr.pMINGW,argv[idx]+sizeof(mingw_option)-1,strlen(argv[idx])-(sizeof(mingw_option)-1));
else if (startsWith(ivl_option,argv[idx])) /* check for -ivl option */
assignn(&gstr.pIVL,argv[idx]+sizeof(ivl_option)-1,strlen(argv[idx])-(sizeof(ivl_option)-1));
else
return 0; /* different from iverilog-vpi.sh, we don't ignore accept arguments */
/* Check for the -I option */
else if (startsWith(inc_option, argv[idx])) {
append(&gstr.pINCS, " ");
append(&gstr.pINCS, argv[idx]);
}
/* Check for the -D option */
else if (startsWith(def_option, argv[idx])) {
append(&gstr.pDEFS, " ");
append(&gstr.pDEFS, argv[idx]);
}
/* Check for the -mingw option */
else if (startsWith(mingw_option, argv[idx]))
assignn(&gstr.pMINGW, argv[idx]+sizeof(mingw_option)-1,
strlen(argv[idx])-(sizeof(mingw_option)-1));
/* Check for the -ivl option */
else if (startsWith(ivl_option, argv[idx]))
assignn(&gstr.pIVL, argv[idx]+sizeof(ivl_option)-1,
strlen(argv[idx])-(sizeof(ivl_option)-1));
/* Check for the --cflags option */
else if (stricmp("--cflags", argv[idx]) == 0) {
setup_ivl_environment();
printf("%s\n", gstr.pCFLAGS);
myExit(0);
}
/* Check for the --ldflags option */
else if (stricmp("--ldflags", argv[idx]) == 0) {
printf("%s\n", IVERILOG_VPI_LDFLAGS);
myExit(0);
}
/* Check for the --ldlibs option */
else if (stricmp("--ldlibs", argv[idx]) == 0) {
setup_ivl_environment();
printf("%s\n", gstr.pLDLIBS);
myExit(0);
}
/* Check for the --install-dir option */
else if (stricmp("--install-dir", argv[idx]) == 0) {
setup_ivl_environment();
printf("%s\\\\lib\\\\ivl\\\\.\n", gstr.pIVL);
myExit(0);
}
/* This is different than iverilog-vpi.sh, we don't
* ignore unknown arguments */
else return 0;
}
if (0 == srcFileCnt)
assign(&gstr.pOUT,""); /* in case they used --name with no source files */
/* In case there is a --name without source/object files */
if (0 == srcFileCnt) assign(&gstr.pOUT,"");
if (!*gstr.pOUT) { /* normally it's an error if there are no *.c,*.cc,*.o files */
if (!*gstr.pMINGW && !*gstr.pIVL) /* unless they are just setting the IVL or MinGW registry entries */
usage();
}
else {
append(&gstr.pOUT,".vpi"); /* the result file should have a .vpi extension */
append(&gstr.pOUT," ");
}
/* Normally it's an error if there are no source or object files */
/* Unless we are setting the IVL or MinGW registry entries */
if (!*gstr.pOUT) {
if (!*gstr.pMINGW && !*gstr.pIVL) return 0;
} else
/* We have a valid result file so add the .vpi extension */
append(&gstr.pOUT, ".vpi");
return 1;
}
@ -411,9 +469,7 @@ static void setup_mingw_environment()
if (*gstr.pMINGW) {
checkMingwDir(gstr.pMINGW);
SetRegistryKey(IVL_REGKEY_MINGW,gstr.pMINGW);
}
else
if (!GetRegistryKey(IVL_REGKEY_MINGW,&gstr.pMINGW)) {
} else if (!GetRegistryKey(IVL_REGKEY_MINGW,&gstr.pMINGW)) {
fprintf(stderr,"error: can not locate the MinGW root directory, use the -mingw option of\n");
fprintf(stderr," iverilog-vpi.exe to point to the MinGW root directory. For\n");
fprintf(stderr," a Windows command shell the option would be something like\n");
@ -422,13 +478,15 @@ static void setup_mingw_environment()
myExit(5);
}
assign(&gstr.pNewPath,"PATH="); /* create new path */
/* Create new path with MinGW in it */
assign(&gstr.pNewPath,"PATH=");
append(&gstr.pNewPath,gstr.pMINGW);
appendBackSlash(&gstr.pNewPath);
append(&gstr.pNewPath,"bin;");
append(&gstr.pNewPath,pOldPATH);
_putenv(gstr.pNewPath); /* place new path in environment variable */
/* Place new path in environment */
_putenv(gstr.pNewPath);
}
/* see if we can find iverilog root */
@ -440,9 +498,7 @@ static void setup_ivl_environment()
if (*gstr.pIVL) {
checkIvlDir(gstr.pIVL);
SetRegistryKey(IVL_REGKEY_IVL,gstr.pIVL);
}
else
if (!GetRegistryKey(IVL_REGKEY_IVL,&gstr.pIVL)) {
} else if (!GetRegistryKey(IVL_REGKEY_IVL,&gstr.pIVL)) {
fprintf(stderr,"error: can not locate the Icarus Verilog root directory, use the -ivl option\n");
fprintf(stderr," of iverilog-vpi.exe to point to the Icarus Verilog root directory.\n");
fprintf(stderr," For a Windows command shell the option would be something like\n");
@ -451,16 +507,14 @@ static void setup_ivl_environment()
myExit(6);
}
/* build up the CFLAGS option string */
/* Build up the CFLAGS option string */
assign(&gstr.pCFLAGS,IVERILOG_VPI_CFLAGS);
append(&gstr.pCFLAGS," -I");
append(&gstr.pCFLAGS,gstr.pIVL);
appendBackSlash(&gstr.pCFLAGS);
append(&gstr.pCFLAGS,"include");
/* build up the LDFLAGS option string */
/* Build up the LDFLAGS option string */
assign(&gstr.pLDLIBS,"-L");
append(&gstr.pLDLIBS,gstr.pIVL);
appendBackSlash(&gstr.pLDLIBS);
@ -470,37 +524,47 @@ static void setup_ivl_environment()
/* compile source modules */
static void compile(char *pSource, char **pObject, char *ext, int *compile_errors, char *compiler)
static void compile(char *pSource, char **pObject, int *compile_errors, char *compiler)
{
char *ptr1 = pSource;
char *ptr2 = strchr(pSource,' ');
char *buf=0,*src=0,*obj=0;
char *ptr2 = strchr(ptr1, ' ');
char *buf=0, *src=0, *obj=0;
while (ptr2) {
int len = ptr2 - ptr1;
assignn(&src,ptr1,len);
char *ostart;
int olen;
assignn(&src, ptr1, len);
assignn(&obj,ptr1,len-strlen(ext)); /* strip off the extension */
append (&obj,".o");
/* Build the object file name */
ostart = strrchr(ptr1, '/') + 1;
olen = strrchr(ptr1, '.') - ostart;
assignn(&obj, ostart, olen);
append(&obj, ".o");
assign (&buf,compiler);
append (&buf," -c -o ");
append (&buf,obj);
append (&buf," ");
append (&buf,gstr.pCFLAGS);
append (&buf," ");
append (&buf,src);
/* Build the compile line */
assign(&buf, compiler);
append(&buf, " -c -o ");
append(&buf, obj);
append(&buf, " ");
append(&buf, gstr.pDEFS);
append(&buf, " ");
append(&buf, gstr.pCFLAGS);
append(&buf, " ");
append(&buf, gstr.pINCS);
append(&buf, " ");
append(&buf, src);
append (pObject,obj);
append (pObject," ");
append (pObject, " ");
append (pObject, obj);
printf("%s\n",buf);
printf("Compiling %s...\n", src);
if (system(buf))
++*compile_errors;
if (system(buf)) ++*compile_errors;
ptr1 = ptr2 + 1; /* advance to next token */
ptr2 = strchr(ptr1,' ');
/* advance to next token */
ptr1 = ptr2 + 1;
ptr2 = strchr(ptr1, ' ');
}
free(buf);
@ -515,43 +579,44 @@ static void compile_and_link()
char *buf=0;
int iRet, compile_errors = 0;
/* print out the mingw and ivl directories to help the user debug problems */
/* To make the output match iverilog-vpi.sh do not print out the
* root directories */
printf("info: %s will be used as the MinGW root directory.\n",gstr.pMINGW);
// printf("MinGW root directory: %s.\n", gstr.pMINGW);
checkMingwDir(gstr.pMINGW);
printf("info: %s will be used as the Icarus Verilog root directory.\n",gstr.pIVL);
// printf("Icarus Verilog root directory: %s.\n", gstr.pIVL);
checkIvlDir(gstr.pIVL);
/* compile */
compile(gstr.pCCSRC,&gstr.pOBJ,".c" ,&compile_errors,IVERILOG_VPI_CC ); /* compile the C source files */
compile(gstr.pCXSRC,&gstr.pOBJ,".cc",&compile_errors,IVERILOG_VPI_CXX); /* compile the C++ source files */
/* compile the C source files (*.c) */
compile(gstr.pCCSRC, &gstr.pOBJ, &compile_errors, IVERILOG_VPI_CC );
/* compile the C++ source files (*.cc, *.cpp) */
compile(gstr.pCXSRC, &gstr.pOBJ, &compile_errors, IVERILOG_VPI_CXX);
if (compile_errors) {
fprintf(stderr,"iverilog-vpi: Some %d files failed to compile.\n",compile_errors);
fprintf(stderr,"iverilog-vpi: %d file(s) failed to compile.\n",
compile_errors);
myExit(2);
}
/* link */
/* link */
assign(&buf, gstr.pLD);
append(&buf, " -o ");
append(&buf, gstr.pOUT);
append(&buf, " ");
append(&buf, IVERILOG_VPI_LDFLAGS);
append(&buf, " ");
append(&buf, gstr.pOBJ);
append(&buf, " ");
append(&buf, gstr.pLIB);
append(&buf, " ");
append(&buf, gstr.pLDLIBS);
assign(&buf,IVERILOG_VPI_LD);
append(&buf," -o ");
append(&buf,gstr.pOUT); /* has a trailing space */
append(&buf,IVERILOG_VPI_LDFLAGS);
append(&buf," ");
append(&buf,gstr.pOBJ) /* has a trailing space */;
append(&buf,gstr.pLIB); /* has a trailing space */
append(&buf,gstr.pLDLIBS);
printf("%s\n",buf);
printf("Making %s from %s...\n", gstr.pOUT,gstr.pOBJ);
iRet = system(buf);
free(buf);
if (iRet)
myExit(3);
if (iRet) myExit(3);
}
/* program execution starts here */
@ -560,14 +625,14 @@ int main(int argc, char *argv[])
{
init();
if (!parse(argc,argv))
usage();
if (!parse(argc,argv)) usage();
setup_mingw_environment();
setup_ivl_environment();
if (*gstr.pOUT) /* are there any *.c,*.cc,*.o files specified */
compile_and_link();
/* are there any source or object files specified */
if (*gstr.pOUT) compile_and_link();
myExit(0);
return 0; // eliminate warnings.
}

View File

@ -1,5 +1,6 @@
%option nounput
%option noinput
%{
/*

View File

@ -213,17 +213,19 @@ NetNet* PEBinary::elaborate_net_add_(Design*des, NetScope*scope,
// Pad out the operands, if necessary, the match the width of
// the adder device.
if (lsig->vector_width() < width)
if (lsig->vector_width() < width) {
if (expr_signed)
lsig = pad_to_width_signed(des, lsig, width);
else
lsig = pad_to_width(des, lsig, width);
}
if (rsig->vector_width() < width)
if (rsig->vector_width() < width) {
if (expr_signed)
rsig = pad_to_width_signed(des, rsig, width);
else
rsig = pad_to_width(des, rsig, width);
}
// Check that the argument types match.
if (lsig->data_type() != rsig->data_type()) {

View File

@ -444,8 +444,8 @@ bool PGenerate::generate_scope_condit_(Design*des, NetScope*container, bool else
// If the condition evaluates as false, then do not create the
// scope.
if (test->value().as_long() == 0 && !else_flag
|| test->value().as_long() != 0 && else_flag) {
if ( (test->value().as_long() == 0 && !else_flag)
|| (test->value().as_long() != 0 && else_flag) ) {
if (debug_elaborate)
cerr << get_fileline() << ": debug: Generate condition "
<< (else_flag? "(else)" : "(if)")

View File

@ -3405,8 +3405,8 @@ void PSpecPath::elaborate(Design*des, NetScope*scope) const
NetNet*src_sig = scope->find_signal(*cur_src);
assert(src_sig);
if (src_sig->port_type() != NetNet::PINPUT
& src_sig->port_type() != NetNet::PINOUT) {
if ( (src_sig->port_type() != NetNet::PINPUT)
&& (src_sig->port_type() != NetNet::PINOUT) ) {
cerr << get_fileline() << ": error: Path source "
<< *cur_src << " must be an input or inout port."

View File

@ -157,7 +157,7 @@ done
if test $compile_errors -gt 0
then
echo "Some ($compile_errors) files failed to compile."
echo "$0: $compile_errors file(s) failed to compile."
exit $compile_errors
fi

View File

@ -159,6 +159,7 @@ static int ma_parenthesis_level = 0;
%option stack
%option nounput
%option noinput
%option noyy_top_state
%x PPINCLUDE

View File

@ -1,6 +1,7 @@
%option never-interactive
%option nounput
%option noinput
%{
/*
@ -26,6 +27,7 @@
# include "sdf_parse_priv.h"
# include "sdf_parse.h"
# include <stdlib.h>
# include <string.h>
# include <strings.h>
# include <assert.h>

View File

@ -16,9 +16,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: sys_convert.c,v 1.7 2007/03/14 04:05:51 steve Exp $"
#endif
# include "vpi_config.h"
# include "vpi_user.h"
@ -86,48 +83,60 @@ static void double2bits(double real, PLI_UINT32 bits[2])
#endif
}
static void error_message(vpiHandle callh, const char* msg)
{
vpi_printf("ERROR: %s line %d: ", vpi_get_str(vpiFile, callh),
(int)vpi_get(vpiLineNo, callh));
vpi_printf(msg, vpi_get_str(vpiName, callh));
vpi_control(vpiFinish, 1);
}
static PLI_INT32 sizetf_32 (PLI_BYTE8*x) { return 32; }
static PLI_INT32 sizetf_64 (PLI_BYTE8*x) { return 64; }
static PLI_INT32 sys_convert_compiletf(PLI_BYTE8*name)
{
vpiHandle call_hand, argv, arg;
PLI_INT32 rtn = 0;
vpiHandle callh = vpi_handle(vpiSysTfCall, 0);
vpiHandle argv = vpi_iterate(vpiArgument, callh);
vpiHandle arg;
call_hand = vpi_handle(vpiSysTfCall, 0);
argv = vpi_iterate(vpiArgument, call_hand);
/* Check that there is an argument. */
if (argv == 0) {
error_message(callh, "%s requires one argument.\n");
return 0;
}
/* In Icarus if we have an argv we have at least one argument. */
arg = vpi_scan(argv);
if (!argv) {
vpi_printf("ERROR: %s requires a parameter.\n",
vpi_get_str(vpiName, call_hand));
rtn = -1;
}
/* Validate the argument. Only $bitstoreal for now. */
if (!strcmp("$bitstoreal", name) && vpi_get(vpiSize, arg) != 64) {
vpi_printf("ERROR: %s requires 64-bit argument.\n",
vpi_get_str(vpiName, call_hand));
rtn = -1;
error_message(callh, "%s requires a 64-bit argument.\n");
return 0;
}
/* free iterator */
vpi_free_object(argv);
/* Save the argument away to make the calltf faster. */
vpi_put_userdata(callh, (void *) arg);
return rtn;
/* These functions only take one argument. */
arg = vpi_scan(argv);
if (arg != 0) {
error_message(callh, "%s takes only one argument.\n");
return 0;
}
/* vpi_scan() returning 0 (NULL) had already freed argv. */
return 0;
}
static PLI_INT32 sys_bitstoreal_calltf(PLI_BYTE8*user)
{
vpiHandle sys, argv, arg;
vpiHandle callh = vpi_handle(vpiSysTfCall, 0);
vpiHandle arg = (vpiHandle) vpi_get_userdata(callh);
s_vpi_value value;
PLI_UINT32 bits[2];
/* find argument handle */
sys = vpi_handle(vpiSysTfCall, 0);
argv = vpi_iterate(vpiArgument, sys);
arg = vpi_scan(argv);
/* get value */
value.format = vpiVectorVal;
vpi_get_value(arg, &value);
@ -139,24 +148,17 @@ static PLI_INT32 sys_bitstoreal_calltf(PLI_BYTE8*user)
value.format = vpiRealVal;
/* return converted value */
vpi_put_value(sys, &value, 0, vpiNoDelay);
/* free iterator */
vpi_free_object(argv);
vpi_put_value(callh, &value, 0, vpiNoDelay);
return 0;
}
static PLI_INT32 sys_itor_calltf(PLI_BYTE8*user)
{
vpiHandle sys, argv, arg;
vpiHandle callh = vpi_handle(vpiSysTfCall, 0);
vpiHandle arg = (vpiHandle) vpi_get_userdata(callh);
s_vpi_value value;
/* find argument handle */
sys = vpi_handle(vpiSysTfCall, 0);
argv = vpi_iterate(vpiArgument, sys);
arg = vpi_scan(argv);
/* get value */
value.format = vpiIntVal;
vpi_get_value(arg, &value);
@ -166,27 +168,20 @@ static PLI_INT32 sys_itor_calltf(PLI_BYTE8*user)
value.format = vpiRealVal;
/* return converted value */
vpi_put_value(sys, &value, 0, vpiNoDelay);
/* free iterator */
vpi_free_object(argv);
vpi_put_value(callh, &value, 0, vpiNoDelay);
return 0;
}
static PLI_INT32 sys_realtobits_calltf(PLI_BYTE8*user)
{
vpiHandle sys, argv, arg;
vpiHandle callh = vpi_handle(vpiSysTfCall, 0);
vpiHandle arg = (vpiHandle) vpi_get_userdata(callh);
s_vpi_value value;
static struct t_vpi_vecval res[2];
PLI_UINT32 bits[2];
/* find argument handle */
sys = vpi_handle(vpiSysTfCall, 0);
argv = vpi_iterate(vpiArgument, sys);
arg = vpi_scan(argv);
/* get value */
value.format = vpiRealVal;
vpi_get_value(arg, &value);
@ -203,25 +198,18 @@ static PLI_INT32 sys_realtobits_calltf(PLI_BYTE8*user)
value.value.vector = res;
/* return converted value */
vpi_put_value(sys, &value, 0, vpiNoDelay);
/* free iterator */
vpi_free_object(argv);
vpi_put_value(callh, &value, 0, vpiNoDelay);
return 0;
}
static PLI_INT32 sys_rtoi_calltf(PLI_BYTE8*user)
{
vpiHandle sys, argv, arg;
vpiHandle callh = vpi_handle(vpiSysTfCall, 0);
vpiHandle arg = (vpiHandle) vpi_get_userdata(callh);
s_vpi_value value;
static struct t_vpi_vecval res;
/* find argument handle */
sys = vpi_handle(vpiSysTfCall, 0);
argv = vpi_iterate(vpiArgument, sys);
arg = vpi_scan(argv);
/* get value */
value.format = vpiRealVal;
vpi_get_value(arg, &value);
@ -234,10 +222,7 @@ static PLI_INT32 sys_rtoi_calltf(PLI_BYTE8*user)
value.value.vector = &res;
/* return converted value */
vpi_put_value(sys, &value, 0, vpiNoDelay);
/* free iterator */
vpi_free_object(argv);
vpi_put_value(callh, &value, 0, vpiNoDelay);
return 0;
}
@ -279,27 +264,3 @@ void sys_convert_register()
vpi_register_systf(&tf_data);
}
/*
* $Log: sys_convert.c,v $
* Revision 1.7 2007/03/14 04:05:51 steve
* VPI tasks take PLI_BYTE* by the standard.
*
* Revision 1.6 2006/10/30 22:45:37 steve
* Updates for Cygwin portability (pr1585922)
*
* Revision 1.5 2004/02/15 18:03:30 steve
* Cleanup of warnings.
*
* Revision 1.4 2004/01/21 01:22:53 steve
* Give the vip directory its own configure and vpi_config.h
*
* Revision 1.3 2003/03/17 21:59:54 steve
* Implement $itor and $bitstoreal
*
* Revision 1.2 2003/03/10 23:40:10 steve
* Add support for $rtoi
*
* Revision 1.1 2003/03/07 02:44:34 steve
* Implement $realtobits.
*
*/

View File

@ -1,5 +1,6 @@
%option nounput
%option noinput
%{
/*

View File

@ -629,7 +629,7 @@ void compile_functor(char*label, char*type, unsigned width,
/* If both the strengths are the default strong drive, then
there is no need for a specialized driver. Attach the label
to this node and we are finished. */
if (strength_aware || ostr0 == 6 && ostr1 == 6) {
if (strength_aware || (ostr0 == 6 && ostr1 == 6)) {
define_functor_symbol(label, net);
free(label);
return;

View File

@ -144,6 +144,7 @@ int main(int argc, char*argv[])
const char *logfile_name = 0x0;
FILE *logfile = 0x0;
extern void vpi_set_vlog_info(int, char**);
extern bool stop_is_finish;
#ifdef __MINGW32__
/* In the Windows world, we get the first module path
@ -159,7 +160,10 @@ int main(int argc, char*argv[])
}
#endif
while ((opt = getopt(argc, argv, "+hl:M:m:sv")) != EOF) switch (opt) {
/* For non-interactive runs we do not want to run the interactive
* debugger, so make $stop just execute a $finish. */
stop_is_finish = false;
while ((opt = getopt(argc, argv, "+hl:M:m:nsv")) != EOF) switch (opt) {
case 'h':
fprintf(stderr,
"Usage: vvp [options] input-file [+plusargs...]\n"
@ -169,6 +173,7 @@ int main(int argc, char*argv[])
" -M path VPI module directory\n"
" -M - Clear VPI module path\n"
" -m module Load vpi module.\n"
" -n Non-interctive ($stop = $finish).\n"
" -s $stop right away.\n"
" -v Verbose progress messages.\n" );
exit(0);
@ -186,6 +191,9 @@ int main(int argc, char*argv[])
case 'm':
module_tab[module_cnt++] = optarg;
break;
case 'n':
stop_is_finish = true;
break;
case 's':
schedule_stop(0);
break;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2006-2007 Stephen Williams (steve@icarus.com)
* Copyright (c) 2006-2008 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
@ -51,7 +51,8 @@ void sfunc_core::recv_vec4_from_inputs(unsigned port)
obj->bits = value(port);
invoke_function_();
/* Schedule the actual call after this finishes. */
schedule_generic(this, 0, false);
}
void sfunc_core::recv_real_from_inputs(unsigned port)
@ -64,10 +65,11 @@ void sfunc_core::recv_real_from_inputs(unsigned port)
obj->value = value_r(port);
invoke_function_();
/* Schedule the actual call after this finishes. */
schedule_generic(this, 0, false);
}
void sfunc_core::invoke_function_()
void sfunc_core::run_run()
{
vpip_execute_vpi_call(0, sys_);
}

View File

@ -1,7 +1,7 @@
#ifndef __sfunc_H
#define __sfunc_H
/*
* Copyright (c) 2006 Stephen Williams (steve@icarus.com)
* Copyright (c) 2006-2008 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
@ -18,13 +18,10 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: sfunc.h,v 1.1 2006/06/18 04:15:50 steve Exp $"
#endif
# include "pointers.h"
class sfunc_core : public vvp_wide_fun_core {
class sfunc_core : public vvp_wide_fun_core, protected vvp_gen_event_s {
public:
sfunc_core(vvp_net_t*ptr, vpiHandle sys, unsigned argc, vpiHandle*argv);
@ -34,7 +31,8 @@ class sfunc_core : public vvp_wide_fun_core {
void recv_vec4_from_inputs(unsigned port);
void recv_real_from_inputs(unsigned port);
void invoke_function_();
void run_run();
private:
vpiHandle sys_;
@ -42,10 +40,4 @@ class sfunc_core : public vvp_wide_fun_core {
vpiHandle*argv_;
};
/*
* $Log: sfunc.h,v $
* Revision 1.1 2006/06/18 04:15:50 steve
* Add support for system functions in continuous assignments.
*
*/
#endif

View File

@ -43,6 +43,7 @@
#endif
struct __vpiScope*stop_current_scope = 0;
bool stop_is_finish; /* When set, $stop acts like $finish (set in main.cc). */
#ifndef USE_READLINE
static char* readline_stub(const char*prompt)
@ -474,6 +475,13 @@ static void invoke_command(char*txt)
void stop_handler(int rc)
{
/* The user may be running in a non-interactive environment, so
* they want $stop and <Control-C> to be the same as $finish. */
if (stop_is_finish) {
schedule_finish(0);
return;
}
vpi_mcd_printf(1,"** VVP Stop(%d) **\n", rc);
vpi_mcd_printf(1,"** Current simulation time is %" TIME_FMT "u ticks.\n",
schedule_simtime());
@ -503,29 +511,3 @@ void stop_handler(int rc)
vpi_mcd_printf(1,"** Continue **\n");
}
/*
* $Log: stop.cc,v $
* Revision 1.16 2006/06/18 04:15:50 steve
* Add support for system functions in continuous assignments.
*
* Revision 1.15 2005/11/25 18:35:38 steve
* stop/continue messages go through MCD for logging.
*
* Revision 1.14 2005/09/20 18:34:02 steve
* Clean up compiler warnings.
*
* Revision 1.13 2005/01/29 06:29:17 steve
* Support interactive mode even without readline.
*
* Revision 1.12 2004/10/04 01:10:59 steve
* Clean up spurious trailing white space.
*
* Revision 1.11 2004/02/21 00:44:34 steve
* Add load command to interactive stop.
* Support decimal constants passed interactive to system tasks.
*
* Revision 1.10 2003/11/07 05:58:02 steve
* Fix conditional compilation of readline history.
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001-2007 Stephen Williams (steve@icarus.com)
* Copyright (c) 2001-2008 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
@ -224,8 +224,8 @@ static vpiHandle sysfunc_put_value(vpiHandle ref, p_vpi_value vp)
unsigned long aval = vp->value.vector[word].aval;
unsigned long bval = vp->value.vector[word].bval;
for (unsigned idx = 0 ; (wdx+idx) < (unsigned)rfp->vwid ;
idx += 1)
for (unsigned idx = 0 ; (wdx+idx) < (unsigned)rfp->vwid &&
idx < 32; idx += 1)
{
int bit = (aval&1) | ((bval<<1)&2);
vvp_bit4_t bit4;
@ -339,7 +339,8 @@ static vpiHandle sysfunc_put_4net_value(vpiHandle ref, p_vpi_value vp)
unsigned long aval = vp->value.vector[word].aval;
unsigned long bval = vp->value.vector[word].bval;
for (unsigned idx = 0 ; (wdx+idx) < vwid ; idx += 1) {
for (unsigned idx = 0 ; (wdx+idx) < vwid && idx < 32;
idx += 1) {
int bit = (aval&1) | ((bval<<1)&2);
vvp_bit4_t bit4;

View File

@ -41,6 +41,11 @@ the module. However, if the name includes at least one directory
character, then the search path is not scanned and the name is assumed
to be a complete file name.
.TP 8
.B -n
This flag makes $stop or a <Control-C> a synonym for $finish.
It can be used to give the program a more meaningful interface when
running in a non-interactive environment.
.TP 8
.B -s
Stop. This will cause the simulation to stop in the beginning, before
any events are scheduled. This allows the interactive user to get

View File

@ -597,7 +597,7 @@ bool vvp_vector4_t::has_xz() const
unsigned long mask = size_%BITS_PER_WORD;
if (mask > 0) {
mask = WORD_X_BITS >> 2*(BITS_PER_WORD - mask);
return 0 != bits_ptr_[words]&mask;
return 0 != (bits_ptr_[words]&mask);
}
return false;