Direct support for string parameters.

This commit is contained in:
steve 2003-03-10 23:37:07 +00:00
parent 66697ca6e9
commit 654ad4c97e
8 changed files with 138 additions and 259 deletions

View File

@ -1,7 +1,7 @@
/*
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
*
* $Id: README.txt,v 1.42 2003/02/09 23:33:26 steve Exp $
* $Id: README.txt,v 1.43 2003/03/10 23:37:07 steve Exp $
*/
VVP SIMULATION ENGINE
@ -89,6 +89,36 @@ There are some special symbols that in certain contexts have special
meanings. As inputs to functors, the symbols "C<0>", "C<1>", "C<x>"
and "C<z>" represent a constant driver of the given value.
SCOPE STATEMENTS:
PARAMETER STATEMENTS:
Parameters are named constants within a scope. These parameters have a
type and value, and also a label so that they can be referenced as VPI
objects.
The syntax of a parameter is:
<label> .param <name>, <type>, <value>;
The <name> is a string that names the parameter. The name is placed in
the current scope as a vpiParameter object. The <type> is one of the
following:
real -- The parameter has a real value
string -- The parameter has a string value
[<msb>,<lsb>,<s>]
-- The parameter is a vector, with specified
indices. The <s> is s or u for signed or
unsigned.
The value, then, is appropriate for the data type. For example:
P_123 .param "hello", string, "Hello, World.";
FUNCTOR STATEMENTS:
A functor statement is a statement that uses the ``.functor''

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: compile.cc,v 1.155 2003/02/27 20:36:29 steve Exp $"
#ident "$Id: compile.cc,v 1.156 2003/03/10 23:37:07 steve Exp $"
#endif
# include "arith.h"
@ -1519,8 +1519,23 @@ void compile_net(char*label, char*name, int msb, int lsb, bool signed_flag,
free(argv);
}
void compile_param_string(char*label, char*name, char*str, char*value)
{
assert(strcmp(str,"string") == 0);
free(str);
vpiHandle obj = vpip_make_string_param(name, value);
compile_vpi_symbol(label, obj);
vpip_attach_to_current_scope(obj);
free(label);
}
/*
* $Log: compile.cc,v $
* Revision 1.156 2003/03/10 23:37:07 steve
* Direct support for string parameters.
*
* Revision 1.155 2003/02/27 20:36:29 steve
* Add the cvt/vr instruction.
*
@ -1543,55 +1558,5 @@ void compile_net(char*label, char*name, int msb, int lsb, bool signed_flag,
* Revision 1.149 2003/01/26 18:16:22 steve
* Add %cvt/ir and %cvt/ri instructions, and support
* real values passed as arguments to VPI tasks.
*
* Revision 1.148 2003/01/25 23:48:06 steve
* Add thread word array, and add the instructions,
* %add/wr, %cmp/wr, %load/wr, %mul/wr and %set/wr.
*
* Revision 1.147 2002/12/21 00:55:58 steve
* The $time system task returns the integer time
* scaled to the local units. Change the internal
* implementation of vpiSystemTime the $time functions
* to properly account for this. Also add $simtime
* to get the simulation time.
*
* Revision 1.146 2002/11/21 22:43:13 steve
* %set/x0 instruction to support bounds checking.
*
* Revision 1.145 2002/11/08 04:59:58 steve
* Add the %assign/v0 instruction.
*
* Revision 1.144 2002/11/07 02:32:39 steve
* Add vector set and load instructions.
*
* Revision 1.143 2002/09/18 04:29:55 steve
* Add support for binary NOR operator.
*
* Revision 1.142 2002/09/18 02:55:18 steve
* Allow forward references of memories.
*
* Revision 1.141 2002/09/12 15:49:43 steve
* Add support for binary nand operator.
*
* Revision 1.140 2002/08/28 18:38:07 steve
* Add the %subi instruction, and use it where possible.
*
* Revision 1.139 2002/08/28 17:15:06 steve
* Add the %load/nx opcode to index vpi nets.
*
* Revision 1.138 2002/08/22 03:38:40 steve
* Fix behavioral eval of x?a:b expressions.
*
* Revision 1.137 2002/08/12 01:35:07 steve
* conditional ident string using autoconfig.
*
* Revision 1.136 2002/07/15 00:21:42 steve
* Fix initialization of symbol table string heap.
*
* Revision 1.135 2002/07/05 20:08:44 steve
* Count different types of functors.
*
* Revision 1.134 2002/07/05 17:14:15 steve
* Names of vpi objects allocated as vpip_strings.
*/

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: compile.h,v 1.49 2003/02/09 23:33:26 steve Exp $"
#ident "$Id: compile.h,v 1.50 2003/03/10 23:37:07 steve Exp $"
#endif
# include <stdio.h>
@ -121,6 +121,9 @@ extern void compile_timescale(long units);
extern void compile_vpi_symbol(const char*label, vpiHandle obj);
extern void compile_vpi_lookup(vpiHandle *objref, char*label);
extern void compile_param_string(char*label, char*name,
char*str, char*value);
/*
* This function schedules a lookup of an indexed label. The ref
* points to the vvp_ipoint_t that receives the result. The result may
@ -261,6 +264,9 @@ extern void compile_net(char*label, char*name,
/*
* $Log: compile.h,v $
* Revision 1.50 2003/03/10 23:37:07 steve
* Direct support for string parameters.
*
* Revision 1.49 2003/02/09 23:33:26 steve
* Spelling fixes.
*
@ -284,149 +290,5 @@ extern void compile_net(char*label, char*name,
*
* Revision 1.44 2002/07/15 00:21:42 steve
* Fix initialization of symbol table string heap.
*
* Revision 1.43 2002/06/21 04:58:55 steve
* Add support for special integer vectors.
*
* Revision 1.42 2002/05/18 02:34:11 steve
* Add vpi support for named events.
*
* Add vpi_mode_flag to track the mode of the
* vpi engine. This is for error checking.
*
* Revision 1.41 2002/03/18 00:19:34 steve
* Add the .ufunc statement.
*
* Revision 1.40 2002/01/03 04:19:02 steve
* Add structural modulus support down to vvp.
*
* Revision 1.39 2001/12/14 02:04:49 steve
* Support strength syntax on functors.
*
* Revision 1.38 2001/12/06 03:31:24 steve
* Support functor delays for gates and UDP devices.
* (Stephan Boettcher)
*
* Revision 1.37 2001/11/06 03:07:22 steve
* Code rearrange. (Stephan Boettcher)
*
* Revision 1.36 2001/11/01 03:00:19 steve
* Add force/cassign/release/deassign support. (Stephan Boettcher)
*
* Revision 1.35 2001/10/31 04:27:46 steve
* Rewrite the functor type to have fewer functor modes,
* and use objects to manage the different types.
* (Stephan Boettcher)
*
* Revision 1.34 2001/10/16 02:47:37 steve
* Add arith/div object.
*
* Revision 1.33 2001/10/15 02:58:27 steve
* Carry the type of the scope (Stephan Boettcher)
*
* Revision 1.32 2001/07/11 04:43:57 steve
* support postpone of $systask parameters. (Stephan Boettcher)
*
* Revision 1.31 2001/07/07 02:57:33 steve
* Add the .shift/r functor.
*
* Revision 1.30 2001/07/06 04:46:44 steve
* Add structural left shift (.shift/l)
*
* Revision 1.29 2001/06/30 23:03:17 steve
* support fast programming by only writing the bits
* that are listed in the input file.
*
* Revision 1.28 2001/06/16 23:45:05 steve
* Add support for structural multiply in t-dll.
* Add code generators and vvp support for both
* structural and behavioral multiply.
*
* Revision 1.27 2001/06/15 04:07:58 steve
* Add .cmp statements for structural comparison.
*
* Revision 1.26 2001/06/15 03:28:31 steve
* Change the VPI call process so that loaded .vpi modules
* use a function table instead of implicit binding.
*
* Revision 1.25 2001/06/07 03:09:03 steve
* Implement .arith/sub subtraction.
*
* Revision 1.24 2001/06/05 03:05:41 steve
* Add structural addition.
*
* Revision 1.23 2001/05/20 00:46:12 steve
* Add support for system function calls.
*
* Revision 1.22 2001/05/09 04:23:18 steve
* Now that the interactive debugger exists,
* there is no use for the output dump.
*
* Revision 1.21 2001/05/09 02:53:25 steve
* Implement the .resolv syntax.
*
* Revision 1.20 2001/05/02 04:05:17 steve
* Remove the init parameter of functors, and instead use
* the special C<?> symbols to initialize inputs. This is
* clearer and more regular.
*
* Revision 1.19 2001/05/01 01:09:39 steve
* Add support for memory objects. (Stephan Boettcher)
*
* Revision 1.18 2001/04/25 04:35:05 steve
* Document the UDP implementation.
*
* Revision 1.17 2001/04/24 02:23:59 steve
* Support for UDP devices in VVP (Stephen Boettcher)
*
* Revision 1.16 2001/04/18 04:21:23 steve
* Put threads into scopes.
*
* Revision 1.15 2001/04/14 05:10:56 steve
* support the .event/or statement.
*
* Revision 1.14 2001/04/05 01:34:26 steve
* Add the .var/s and .net/s statements for VPI support.
*
* Revision 1.13 2001/04/01 06:40:45 steve
* Support empty statements for hanging labels.
*
* Revision 1.12 2001/03/29 03:46:36 steve
* Support named events as mode 2 functors.
*
* Revision 1.11 2001/03/26 04:00:39 steve
* Add the .event statement and the %wait instruction.
*
* Revision 1.10 2001/03/25 00:35:35 steve
* Add the .net statement.
*
* Revision 1.9 2001/03/23 02:40:22 steve
* Add the :module header statement.
*
* Revision 1.8 2001/03/22 22:38:14 steve
* Detect undefined system tasks at compile time.
*
* Revision 1.7 2001/03/21 05:13:03 steve
* Allow var objects as vpiHandle arguments to %vpi_call.
*
* Revision 1.6 2001/03/20 06:16:24 steve
* Add support for variable vectors.
*
* Revision 1.5 2001/03/18 04:35:18 steve
* Add support for string constants to VPI.
*
* Revision 1.4 2001/03/18 00:37:55 steve
* Add support for vpi scopes.
*
* Revision 1.3 2001/03/16 01:44:34 steve
* Add structures for VPI support, and all the %vpi_call
* instruction. Get linking of VPI modules to work.
*
* Revision 1.2 2001/03/11 22:42:11 steve
* Functor values and propagation.
*
* Revision 1.1 2001/03/11 00:29:38 steve
* Add the vvp engine to cvs.
*
*/
#endif

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: lexor.lex,v 1.38 2003/02/09 23:33:26 steve Exp $"
#ident "$Id: lexor.lex,v 1.39 2003/03/10 23:37:07 steve Exp $"
#endif
# include "parse_misc.h"
@ -95,6 +95,7 @@
".functor" { return K_FUNCTOR; }
".net" { return K_NET; }
".net/s" { return K_NET_S; }
".param" { return K_PARAM; }
".resolv" { return K_RESOLV; }
".scope" { return K_SCOPE; }
".shift/l" { return K_SHIFTL; }
@ -176,6 +177,9 @@ int yywrap()
/*
* $Log: lexor.lex,v $
* Revision 1.39 2003/03/10 23:37:07 steve
* Direct support for string parameters.
*
* Revision 1.38 2003/02/09 23:33:26 steve
* Spelling fixes.
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT)
#ident "$Id: parse.y,v 1.51 2003/02/09 23:33:26 steve Exp $"
#ident "$Id: parse.y,v 1.52 2003/03/10 23:37:07 steve Exp $"
#endif
# include "parse_misc.h"
@ -59,7 +59,7 @@ extern FILE*yyin;
%token K_ARITH_DIV K_ARITH_MOD K_ARITH_MULT K_ARITH_SUB K_ARITH_SUM
%token K_CMP_GE K_CMP_GT
%token K_EVENT K_EVENT_OR K_FUNCTOR K_NET K_NET_S
%token K_EVENT K_EVENT_OR K_FUNCTOR K_NET K_NET_S K_PARAM
%token K_RESOLV K_SCOPE K_SHIFTL K_SHIFTR K_THREAD K_TIMESCALE K_UFUNC
%token K_UDP K_UDP_C K_UDP_S
%token K_MEM K_MEM_P K_MEM_I
@ -339,6 +339,12 @@ statement
| T_LABEL K_NET_S T_STRING ',' T_NUMBER ',' T_NUMBER ',' symbols_net ';'
{ compile_net($1, $3, $5, $7, true, $9.cnt, $9.vect); }
/* Parameter statements come in a few simple forms. The most basic
is the string parameter. */
| T_LABEL K_PARAM T_STRING ',' T_SYMBOL ',' T_STRING ';'
{ compile_param_string($1, $3, $5, $7); }
/* Oh and by the way, empty statements are OK as well. */
| ';'
@ -569,6 +575,9 @@ int compile_design(const char*path)
/*
* $Log: parse.y,v $
* Revision 1.52 2003/03/10 23:37:07 steve
* Direct support for string parameters.
*
* Revision 1.51 2003/02/09 23:33:26 steve
* Spelling fixes.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: stop.cc,v 1.5 2003/03/08 20:59:41 steve Exp $"
#ident "$Id: stop.cc,v 1.6 2003/03/10 23:37:07 steve Exp $"
#endif
/*
@ -96,7 +96,7 @@ static void cmd_call(unsigned argc, char*argv[])
for (unsigned tmp = 0 ; (tmp < ntable)&& !handle ; tmp += 1) {
struct __vpiScope*scope;
struct __vpiSignal*sig;
const char*name;
switch (table[tmp]->vpi_type->type_code) {
@ -112,11 +112,11 @@ static void cmd_call(unsigned argc, char*argv[])
case vpiReg:
case vpiNet:
sig = (struct __vpiSignal*) table[tmp];
if (strcmp(sig->name, argv[idx+1]) == 0)
case vpiParameter:
name = vpi_get_str(vpiName,table[tmp]);
if (strcmp(argv[idx+1], name) == 0)
handle = table[tmp];
break;
}
}
@ -195,6 +195,10 @@ static void cmd_list(unsigned, char*[])
printf("module : %s\n", scope->name);
break;
case vpiParameter:
printf("param : %s\n", vpi_get_str(vpiName, table[idx]));
break;
case vpiReg:
sig = (struct __vpiSignal*) table[idx];
if ((sig->msb == 0) && (sig->lsb == 0))
@ -416,6 +420,9 @@ void stop_handler(int rc)
/*
* $Log: stop.cc,v $
* Revision 1.6 2003/03/10 23:37:07 steve
* Direct support for string parameters.
*
* Revision 1.5 2003/03/08 20:59:41 steve
* Missing include ctype.h.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: vpi_const.cc,v 1.23 2003/03/10 19:14:27 steve Exp $"
#ident "$Id: vpi_const.cc,v 1.24 2003/03/10 23:37:07 steve Exp $"
#endif
# include "vpi_priv.h"
@ -64,7 +64,8 @@ static void string_value(vpiHandle ref, p_vpi_value vp)
char *cp;
struct __vpiStringConst*rfp = (struct __vpiStringConst*)ref;
assert(ref->vpi_type->type_code == vpiConstant);
assert((ref->vpi_type->type_code == vpiConstant)
|| ((ref->vpi_type->type_code == vpiParameter)));
switch (vp->format) {
case vpiObjTypeVal:
@ -198,6 +199,51 @@ vpiHandle vpip_make_string_const(char*text, bool persistent_flag)
}
struct __vpiStringParam : public __vpiStringConst {
const char*basename;
};
static char* string_param_get_str(int code, vpiHandle obj)
{
struct __vpiStringParam*rfp = (struct __vpiStringParam*)obj;
assert(obj->vpi_type->type_code == vpiParameter);
switch (code) {
case vpiName:
return const_cast<char*>(rfp->basename);
default:
return 0;
}
}
static const struct __vpirt vpip_string_param_rt = {
vpiParameter,
string_get,
string_param_get_str,
string_value,
0,
0,
0,
0,
0
};
vpiHandle vpip_make_string_param(char*name, char*text)
{
struct __vpiStringParam*obj;
obj = (struct __vpiStringParam*)
malloc(sizeof (struct __vpiStringParam));
obj->base.vpi_type = &vpip_string_param_rt;
obj->value = text;
obj->basename = name;
return &obj->base;
}
static int binary_get(int code, vpiHandle ref)
{
struct __vpiBinaryConst*rfp = (struct __vpiBinaryConst*)ref;
@ -585,6 +631,9 @@ vpiHandle vpip_make_dec_const(int value)
/*
* $Log: vpi_const.cc,v $
* Revision 1.24 2003/03/10 23:37:07 steve
* Direct support for string parameters.
*
* Revision 1.23 2003/03/10 19:14:27 steve
* More carful about shifting beyond word size.
*
@ -602,56 +651,5 @@ vpiHandle vpip_make_dec_const(int value)
*
* Revision 1.18 2002/06/23 18:23:09 steve
* trivial performance boost.
*
* Revision 1.17 2002/06/14 22:05:28 steve
* sign extend signed vectors vpiIntVal.
*
* Revision 1.16 2002/05/17 04:12:19 steve
* Rewire vpiMemory and vpiMemoryWord handles to
* support proper iteration of words, and the
* vpiIndex value.
*
* Revision 1.15 2002/04/27 23:26:24 steve
* Trim leading nulls from string forms.
*
* Revision 1.14 2002/04/27 22:36:39 steve
* Support drawing vpiBinaryConst in hex.
*
* Revision 1.13 2002/04/14 03:53:20 steve
* Allow signed constant vectors for call_vpi parameters.
*
* Revision 1.12 2002/03/18 05:33:24 steve
* vpip_bits_to_dec_str takes a bit array in a specific format.
*
* Revision 1.11 2002/02/03 01:01:51 steve
* Use Larrys bits-to-decimal-string code.
*
* Revision 1.10 2002/01/31 04:28:17 steve
* Full support for $readmem ranges (Tom Verbeure)
*
* Revision 1.8 2002/01/15 03:21:18 steve
* Support DesSTrVal for binary constants.
*
* Revision 1.7 2001/09/15 18:27:05 steve
* Make configure detect malloc.h
*
* Revision 1.6 2001/08/08 00:57:20 steve
* Unused variable warnings.
*
* Revision 1.5 2001/07/11 04:40:52 steve
* Get endian of vpiIntVal from constants.
*
* Revision 1.4 2001/04/04 05:07:19 steve
* Get intval from a binary constant.
*
* Revision 1.3 2001/04/04 04:33:08 steve
* Take vector form as parameters to vpi_call.
*
* Revision 1.2 2001/04/02 00:24:31 steve
* Take numbers as system task parameters.
*
* Revision 1.1 2001/03/18 04:35:18 steve
* Add support for string constants to VPI.
*
*/

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: vpi_priv.h,v 1.51 2003/03/06 04:32:00 steve Exp $"
#ident "$Id: vpi_priv.h,v 1.52 2003/03/10 23:37:07 steve Exp $"
#endif
# include "vpi_user.h"
@ -273,6 +273,7 @@ struct __vpiStringConst {
};
vpiHandle vpip_make_string_const(char*text, bool persistent =true);
vpiHandle vpip_make_string_param(char*name, char*value);
struct __vpiBinaryConst {
struct __vpiHandle base;
@ -412,6 +413,9 @@ extern char *need_result_buf(unsigned cnt, vpi_rbuf_t type);
/*
* $Log: vpi_priv.h,v $
* Revision 1.52 2003/03/10 23:37:07 steve
* Direct support for string parameters.
*
* Revision 1.51 2003/03/06 04:32:00 steve
* Use hashed name strings for identifiers.
*