Skip to content

Commit

Permalink
Add the .var/s and .net/s statements for VPI support.
Browse files Browse the repository at this point in the history
  • Loading branch information
steve committed Apr 5, 2001
1 parent 898639d commit 6a23606
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 26 deletions.
12 changes: 8 additions & 4 deletions vvp/README.txt
@@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
14 changes: 9 additions & 5 deletions vvp/compile.cc
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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.
*
Expand Down
11 changes: 8 additions & 3 deletions vvp/compile.h
Expand Up @@ -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>
Expand Down Expand Up @@ -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);

/*
Expand All @@ -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.
*
Expand Down
7 changes: 6 additions & 1 deletion vvp/lexor.lex
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
*
Expand Down
18 changes: 14 additions & 4 deletions vvp/parse.y
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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. */

Expand Down Expand Up @@ -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.
*
Expand Down
9 changes: 6 additions & 3 deletions vvp/vpi_priv.h
Expand Up @@ -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"
Expand Down Expand Up @@ -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);

/*
Expand Down Expand Up @@ -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.
*
Expand Down
18 changes: 12 additions & 6 deletions vvp/vpi_signal.cc
Expand Up @@ -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

/*
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -283,15 +284,16 @@ 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));
obj->base.vpi_type = &vpip_reg_rt;
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();
Expand All @@ -304,15 +306,16 @@ 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));
obj->base.vpi_type = &vpip_net_rt;
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();
Expand All @@ -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.
*
Expand Down

0 comments on commit 6a23606

Please sign in to comment.