Add the .var/s and .net/s statements for VPI support.
This commit is contained in:
parent
898639d7bf
commit
6a236061de
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
* $Id: README.txt,v 1.12 2001/04/02 02:28:13 steve Exp $
|
||||
* $Id: README.txt,v 1.13 2001/04/05 01:34:26 steve Exp $
|
||||
*/
|
||||
|
||||
VVP SIMULATION ENGINE
|
||||
|
|
@ -105,7 +105,8 @@ A variable is a bit vector that can be written by behavioral code (so
|
|||
has no structural input) and propagates its output to a functor. The
|
||||
general syntax of a variable is:
|
||||
|
||||
<label> .var "name", <msb>, <lsb>;
|
||||
<label> .var "name", <msb>, <lsb>;
|
||||
<label> .var/s "name", <msb>, <lsb>;
|
||||
|
||||
The "name" is the declared base name of the original variable, for the
|
||||
sake of VPI code that might access it. The variable is placed in the
|
||||
|
|
@ -134,7 +135,9 @@ third input selects the source to use. The default is to select the
|
|||
assignment input.
|
||||
|
||||
The variable statement also creates a VPI object of the appropriate
|
||||
type. See the vpi.txt file for details about that object.
|
||||
type. See the vpi.txt file for details about that object. The msb and
|
||||
lsb values are set from the parameters of the .var or .var/s, and the
|
||||
vpiReg is marked unsigned for .var, or signed for .var/s
|
||||
|
||||
Note that nets in a design do not necessarily have a specific functor
|
||||
or object allocated to them. Nets are just something that behavioral
|
||||
|
|
@ -149,7 +152,8 @@ it (unless it uses a force) and it is given a different VPI type
|
|||
code. The syntax of a .net statement is also similar to but not
|
||||
exactly the same as the .var statement:
|
||||
|
||||
<label> .net "name", <msb>, <lsb>, <symbols_list>;
|
||||
<label> .net "name", <msb>, <lsb>, <symbols_list>;
|
||||
<label> .net/s "name", <msb>, <lsb>, <symbols_list>;
|
||||
|
||||
A .net statement creates a functor for each bit of the vector in
|
||||
exactly the same way that a .var creates functors. The truth table for
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: compile.cc,v 1.29 2001/04/05 01:12:28 steve Exp $"
|
||||
#ident "$Id: compile.cc,v 1.30 2001/04/05 01:34:26 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "compile.h"
|
||||
|
|
@ -558,7 +558,8 @@ vpiHandle compile_vpi_lookup(const char*label)
|
|||
* A variable is a special functor, so we allocate that functor and
|
||||
* write the label into the symbol table.
|
||||
*/
|
||||
void compile_variable(char*label, char*name, int msb, int lsb)
|
||||
void compile_variable(char*label, char*name, int msb, int lsb,
|
||||
bool signed_flag)
|
||||
{
|
||||
unsigned wid = ((msb > lsb)? msb-lsb : lsb-msb) + 1;
|
||||
vvp_ipoint_t fdx = functor_allocate(wid);
|
||||
|
|
@ -575,13 +576,13 @@ void compile_variable(char*label, char*name, int msb, int lsb)
|
|||
}
|
||||
|
||||
/* Make the vpiHandle for the reg. */
|
||||
vpiHandle obj = vpip_make_reg(name, msb, lsb, fdx);
|
||||
vpiHandle obj = vpip_make_reg(name, msb, lsb, signed_flag, fdx);
|
||||
compile_vpi_symbol(label, obj);
|
||||
|
||||
free(label);
|
||||
}
|
||||
|
||||
void compile_net(char*label, char*name, int msb, int lsb,
|
||||
void compile_net(char*label, char*name, int msb, int lsb, bool signed_flag,
|
||||
unsigned argc, struct symb_s*argv)
|
||||
{
|
||||
unsigned wid = ((msb > lsb)? msb-lsb : lsb-msb) + 1;
|
||||
|
|
@ -623,7 +624,7 @@ void compile_net(char*label, char*name, int msb, int lsb,
|
|||
}
|
||||
|
||||
/* Make the vpiHandle for the reg. */
|
||||
vpiHandle obj = vpip_make_net(name, msb, lsb, fdx);
|
||||
vpiHandle obj = vpip_make_net(name, msb, lsb, signed_flag, fdx);
|
||||
compile_vpi_symbol(label, obj);
|
||||
|
||||
free(label);
|
||||
|
|
@ -713,6 +714,9 @@ void compile_dump(FILE*fd)
|
|||
|
||||
/*
|
||||
* $Log: compile.cc,v $
|
||||
* Revision 1.30 2001/04/05 01:34:26 steve
|
||||
* Add the .var/s and .net/s statements for VPI support.
|
||||
*
|
||||
* Revision 1.29 2001/04/05 01:12:28 steve
|
||||
* Get signed compares working correctly in vvp.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: compile.h,v 1.13 2001/04/01 06:40:45 steve Exp $"
|
||||
#ident "$Id: compile.h,v 1.14 2001/04/05 01:34:26 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include <stdio.h>
|
||||
|
|
@ -122,9 +122,11 @@ extern void compile_thread(char*start_sym);
|
|||
/*
|
||||
* This function is called to create a var vector with the given name.
|
||||
*/
|
||||
extern void compile_variable(char*label, char*name, int msb, int lsb);
|
||||
extern void compile_variable(char*label, char*name,
|
||||
int msb, int lsb, bool signed_flag);
|
||||
|
||||
extern void compile_net(char*label, char*name, int msb, int lsb,
|
||||
extern void compile_net(char*label, char*name,
|
||||
int msb, int lsb, bool signed_flag,
|
||||
unsigned argc, struct symb_s*argv);
|
||||
|
||||
/*
|
||||
|
|
@ -135,6 +137,9 @@ extern void compile_dump(FILE*fd);
|
|||
|
||||
/*
|
||||
* $Log: compile.h,v $
|
||||
* 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.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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.10 2001/04/04 04:33:08 steve Exp $"
|
||||
#ident "$Id: lexor.lex,v 1.11 2001/04/05 01:34:26 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "parse_misc.h"
|
||||
|
|
@ -68,9 +68,11 @@
|
|||
".event" { return K_EVENT; }
|
||||
".functor" { return K_FUNCTOR; }
|
||||
".net" { return K_NET; }
|
||||
".net/s" { return K_NET_S; }
|
||||
".scope" { return K_SCOPE; }
|
||||
".thread" { return K_THREAD; }
|
||||
".var" { return K_VAR; }
|
||||
".var/s" { return K_VAR_S; }
|
||||
|
||||
|
||||
/* instructions start with a % character. The compiler decides what
|
||||
|
|
@ -123,6 +125,9 @@ int yywrap()
|
|||
|
||||
/*
|
||||
* $Log: lexor.lex,v $
|
||||
* Revision 1.11 2001/04/05 01:34:26 steve
|
||||
* Add the .var/s and .net/s statements for VPI support.
|
||||
*
|
||||
* Revision 1.10 2001/04/04 04:33:08 steve
|
||||
* Take vector form as parameters to vpi_call.
|
||||
*
|
||||
|
|
|
|||
18
vvp/parse.y
18
vvp/parse.y
|
|
@ -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.17 2001/04/04 04:33:08 steve Exp $"
|
||||
#ident "$Id: parse.y,v 1.18 2001/04/05 01:34:26 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "parse_misc.h"
|
||||
|
|
@ -51,7 +51,8 @@ extern FILE*yyin;
|
|||
};
|
||||
|
||||
|
||||
%token K_EVENT K_FUNCTOR K_NET K_SCOPE K_THREAD K_VAR K_vpi_call
|
||||
%token K_EVENT K_FUNCTOR K_NET K_NET_S K_SCOPE K_THREAD
|
||||
%token K_VAR K_VAR_S K_vpi_call
|
||||
%token K_vpi_module
|
||||
|
||||
%token <text> T_INSTR
|
||||
|
|
@ -161,13 +162,19 @@ statement
|
|||
the variable in the netlist. */
|
||||
|
||||
| T_LABEL K_VAR T_STRING ',' T_NUMBER ',' T_NUMBER ';'
|
||||
{ compile_variable($1, $3, $5, $7); }
|
||||
{ compile_variable($1, $3, $5, $7, false); }
|
||||
|
||||
| T_LABEL K_VAR_S T_STRING ',' T_NUMBER ',' T_NUMBER ';'
|
||||
{ compile_variable($1, $3, $5, $7, true); }
|
||||
|
||||
/* Net statements are similar to .var statements, except that they
|
||||
declare nets, and they have an input list. */
|
||||
|
||||
| T_LABEL K_NET T_STRING ',' T_NUMBER ',' T_NUMBER ',' symbols ';'
|
||||
{ compile_net($1, $3, $5, $7, $9.cnt, $9.vect); }
|
||||
{ compile_net($1, $3, $5, $7, false, $9.cnt, $9.vect); }
|
||||
|
||||
| T_LABEL K_NET_S T_STRING ',' T_NUMBER ',' T_NUMBER ',' symbols ';'
|
||||
{ compile_net($1, $3, $5, $7, true, $9.cnt, $9.vect); }
|
||||
|
||||
/* Oh and by the way, empty statements are OK as well. */
|
||||
|
||||
|
|
@ -316,6 +323,9 @@ int compile_design(const char*path)
|
|||
|
||||
/*
|
||||
* $Log: parse.y,v $
|
||||
* Revision 1.18 2001/04/05 01:34:26 steve
|
||||
* Add the .var/s and .net/s statements for VPI support.
|
||||
*
|
||||
* Revision 1.17 2001/04/04 04:33:08 steve
|
||||
* Take vector form as parameters to vpi_call.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: vpi_priv.h,v 1.11 2001/04/04 17:43:19 steve Exp $"
|
||||
#ident "$Id: vpi_priv.h,v 1.12 2001/04/05 01:34:26 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "vpi_user.h"
|
||||
|
|
@ -106,9 +106,9 @@ struct __vpiSignal {
|
|||
/* The represented value is here. */
|
||||
vvp_ipoint_t bits;
|
||||
};
|
||||
extern vpiHandle vpip_make_reg(char*name, int msb, int lsb,
|
||||
extern vpiHandle vpip_make_reg(char*name, int msb, int lsb, bool signed_flag,
|
||||
vvp_ipoint_t base);
|
||||
extern vpiHandle vpip_make_net(char*name, int msb, int lsb,
|
||||
extern vpiHandle vpip_make_net(char*name, int msb, int lsb, bool signed_flag,
|
||||
vvp_ipoint_t base);
|
||||
|
||||
/*
|
||||
|
|
@ -193,6 +193,9 @@ vpiHandle vpip_sim_time(void);
|
|||
|
||||
/*
|
||||
* $Log: vpi_priv.h,v $
|
||||
* Revision 1.12 2001/04/05 01:34:26 steve
|
||||
* Add the .var/s and .net/s statements for VPI support.
|
||||
*
|
||||
* Revision 1.11 2001/04/04 17:43:19 steve
|
||||
* support decimal strings from signals.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT)
|
||||
#ident "$Id: vpi_signal.cc,v 1.6 2001/04/04 17:43:19 steve Exp $"
|
||||
#ident "$Id: vpi_signal.cc,v 1.7 2001/04/05 01:34:26 steve Exp $"
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
@ -99,7 +99,7 @@ static void signal_vpiDecStrVal(struct __vpiSignal*rfp, s_vpi_value*vp)
|
|||
unsigned count_x = 0, count_z = 0;
|
||||
|
||||
for (unsigned idx = 0 ; idx < wid ; idx += 1) {
|
||||
vvp_ipoint_t fptr = ipoint_index(rfp->bits, idx);
|
||||
vvp_ipoint_t fptr = ipoint_index(rfp->bits, wid-idx-1);
|
||||
val *= 2;
|
||||
switch (functor_oval(fptr)) {
|
||||
case 0:
|
||||
|
|
@ -230,6 +230,7 @@ static void signal_get_value(vpiHandle ref, s_vpi_value*vp)
|
|||
|
||||
case vpiDecStrVal:
|
||||
signal_vpiDecStrVal(rfp, vp);
|
||||
vp->value.str = buf;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -283,7 +284,8 @@ static const struct __vpirt vpip_net_rt = {
|
|||
* Construct a vpiReg object. Give the object specified dimensions,
|
||||
* and point to the specified functor for the lsb.
|
||||
*/
|
||||
vpiHandle vpip_make_reg(char*name, int msb, int lsb, vvp_ipoint_t base)
|
||||
vpiHandle vpip_make_reg(char*name, int msb, int lsb, bool signed_flag,
|
||||
vvp_ipoint_t base)
|
||||
{
|
||||
struct __vpiSignal*obj = (struct __vpiSignal*)
|
||||
malloc(sizeof(struct __vpiSignal));
|
||||
|
|
@ -291,7 +293,7 @@ vpiHandle vpip_make_reg(char*name, int msb, int lsb, vvp_ipoint_t base)
|
|||
obj->name = name;
|
||||
obj->msb = msb;
|
||||
obj->lsb = lsb;
|
||||
obj->signed_flag = 0;
|
||||
obj->signed_flag = signed_flag? 1 : 0;
|
||||
obj->bits = base;
|
||||
|
||||
obj->scope = vpip_peek_current_scope();
|
||||
|
|
@ -304,7 +306,8 @@ vpiHandle vpip_make_reg(char*name, int msb, int lsb, vvp_ipoint_t base)
|
|||
* Construct a vpiReg object. Give the object specified dimensions,
|
||||
* and point to the specified functor for the lsb.
|
||||
*/
|
||||
vpiHandle vpip_make_net(char*name, int msb, int lsb, vvp_ipoint_t base)
|
||||
vpiHandle vpip_make_net(char*name, int msb, int lsb, bool signed_flag,
|
||||
vvp_ipoint_t base)
|
||||
{
|
||||
struct __vpiSignal*obj = (struct __vpiSignal*)
|
||||
malloc(sizeof(struct __vpiSignal));
|
||||
|
|
@ -312,7 +315,7 @@ vpiHandle vpip_make_net(char*name, int msb, int lsb, vvp_ipoint_t base)
|
|||
obj->name = name;
|
||||
obj->msb = msb;
|
||||
obj->lsb = lsb;
|
||||
obj->signed_flag = 0;
|
||||
obj->signed_flag = signed_flag? 1 : 0;
|
||||
obj->bits = base;
|
||||
|
||||
obj->scope = vpip_peek_current_scope();
|
||||
|
|
@ -323,6 +326,9 @@ vpiHandle vpip_make_net(char*name, int msb, int lsb, vvp_ipoint_t base)
|
|||
|
||||
/*
|
||||
* $Log: vpi_signal.cc,v $
|
||||
* Revision 1.7 2001/04/05 01:34:26 steve
|
||||
* Add the .var/s and .net/s statements for VPI support.
|
||||
*
|
||||
* Revision 1.6 2001/04/04 17:43:19 steve
|
||||
* support decimal strings from signals.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in New Issue