Add alias nodes.

This commit is contained in:
steve 2005-10-12 17:23:15 +00:00
parent c75f0a930e
commit 560c5a2584
6 changed files with 99 additions and 31 deletions

View File

@ -1,7 +1,7 @@
/*
* Copyright (c) 2001 Stephen Williams (steve@icarus.com)
*
* $Id: README.txt,v 1.71 2005/09/19 21:45:36 steve Exp $
* $Id: README.txt,v 1.72 2005/10/12 17:23:15 steve Exp $
*/
VVP SIMULATION ENGINE
@ -279,9 +279,11 @@ 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>, <symbol>;
<label> .net/s "name", <msb>, <lsb>, <symbol>;
<label> .net "name", <msb>, <lsb>, <symbol>;
<label> .net/s "name", <msb>, <lsb>, <symbol>;
<label> .net/real "name", <msb>, <lsb>, <symbol>;
<label> .alias "name", <msb>, <lsb>, <symbol>;
Like a .var statement, the .net statement creates a VPI object with
the basename and dimensions given as parameters. The symbol is a
@ -304,6 +306,9 @@ references to net and reg objects are done through the .net label
instead of a general functor symbol. The instruction stores the
functor pointer, though.
The .alias statements do not create new nodes, but instead create net
names that are aliases of an existing node. This handles special cases
where a net has different names, possibly in different scopes.
MEMORY STATEMENTS:

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.213 2005/09/20 18:34:01 steve Exp $"
#ident "$Id: compile.cc,v 1.214 2005/10/12 17:23:15 steve Exp $"
#endif
# include "arith.h"
@ -232,7 +232,7 @@ static vvp_net_t*lookup_functor_symbol(const char*label)
return val.net;
}
static vvp_net_t* vvp_net_lookup(const char*label)
vvp_net_t* vvp_net_lookup(const char*label)
{
/* First, look to see if the symbol is a vpi object of some
sort. If it is, then get the vvp_ipoint_t pointer out of
@ -1481,6 +1481,9 @@ void compile_param_string(char*label, char*name, char*str, char*value)
/*
* $Log: compile.cc,v $
* Revision 1.214 2005/10/12 17:23:15 steve
* Add alias nodes.
*
* Revision 1.213 2005/09/20 18:34:01 steve
* Clean up compiler warnings.
*

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.75 2005/07/14 23:34:19 steve Exp $"
#ident "$Id: compile.h,v 1.76 2005/10/12 17:23:15 steve Exp $"
#endif
# include <stdio.h>
@ -60,12 +60,14 @@ extern void input_connect(vvp_net_t*fdx, unsigned port, char*label);
extern void wide_inputs_connect(vvp_wide_fun_core*core,
unsigned argc, struct symb_s*argv);
extern vvp_net_t* vvp_net_lookup(const char*label);
/*
* Add a functor to the symbol table
*/
extern void define_functor_symbol(const char*label, vvp_net_t*ipt);
/*
* This is a count of errors encountered during compilation. If this
* is non-zero, then simulation is not recommended.
@ -325,8 +327,18 @@ extern void compile_net_real(char*label, char*name,
int msb, int lsb,
unsigned argc, struct symb_s*argv);
extern void compile_alias(char*label, char*name,
int msb, int lsb, bool signed_flag,
unsigned argc, struct symb_s*argv);
extern void compile_alias_real(char*label, char*name,
int msb, int lsb,
unsigned argc, struct symb_s*argv);
/*
* $Log: compile.h,v $
* Revision 1.76 2005/10/12 17:23:15 steve
* Add alias nodes.
*
* Revision 1.75 2005/07/14 23:34:19 steve
* gcc4 compile errors.
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: lexor.lex,v 1.55 2005/07/06 04:29:25 steve Exp $"
#ident "$Id: lexor.lex,v 1.56 2005/10/12 17:23:15 steve Exp $"
#endif
# include "parse_misc.h"
@ -83,6 +83,9 @@
/* These are some keywords that are recognized. */
".alias" { return K_ALIAS; }
".alias/real" { return K_ALIAS_R; }
".alias/s" { return K_ALIAS_S; }
".arith/div" { return K_ARITH_DIV; }
".arith/div.r" { return K_ARITH_DIV_R; }
".arith/div.s" { return K_ARITH_DIV_S; }
@ -199,6 +202,9 @@ int yywrap()
/*
* $Log: lexor.lex,v $
* Revision 1.56 2005/10/12 17:23:15 steve
* Add alias nodes.
*
* Revision 1.55 2005/07/06 04:29:25 steve
* Implement real valued signals and arith nodes.
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: parse.y,v 1.77 2005/07/06 04:29:25 steve Exp $"
#ident "$Id: parse.y,v 1.78 2005/10/12 17:23:15 steve Exp $"
#endif
# include "parse_misc.h"
@ -56,7 +56,7 @@ extern FILE*yyin;
vvp_delay_t*cdelay;
};
%token K_ALIAS K_ALIAS_S K_ALIAS_R
%token K_ARITH_DIV K_ARITH_DIV_R K_ARITH_DIV_S K_ARITH_MOD K_ARITH_MULT
%token K_ARITH_SUB K_ARITH_SUB_R K_ARITH_SUM
%token K_CMP_EEQ K_CMP_EQ K_CMP_NEE K_CMP_NE
@ -463,6 +463,18 @@ statement
',' symbols_net ';'
{ compile_net_real($1, $3, $5, $7, $9.cnt, $9.vect); }
| T_LABEL K_ALIAS T_STRING ',' signed_t_number ',' signed_t_number
',' symbols_net ';'
{ compile_alias($1, $3, $5, $7, false, $9.cnt, $9.vect); }
| T_LABEL K_ALIAS_S T_STRING ',' signed_t_number ',' signed_t_number
',' symbols_net ';'
{ compile_alias($1, $3, $5, $7, true, $9.cnt, $9.vect); }
| T_LABEL K_ALIAS_R T_STRING ',' signed_t_number ',' signed_t_number
',' symbols_net ';'
{ compile_alias_real($1, $3, $5, $7, $9.cnt, $9.vect); }
/* Parameter statements come in a few simple forms. The most basic
is the string parameter. */
@ -701,6 +713,9 @@ int compile_design(const char*path)
/*
* $Log: parse.y,v $
* Revision 1.78 2005/10/12 17:23:15 steve
* Add alias nodes.
*
* Revision 1.77 2005/07/06 04:29:25 steve
* Implement real valued signals and arith nodes.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: words.cc,v 1.3 2005/07/06 04:29:25 steve Exp $"
#ident "$Id: words.cc,v 1.4 2005/10/12 17:23:16 steve Exp $"
#endif
# include "compile.h"
@ -25,32 +25,12 @@
# include <stdio.h>
# include <stdlib.h>
# include <string.h>
# include <iostream>
#ifdef HAVE_MALLOC_H
# include <malloc.h>
#endif
# include <assert.h>
#if 0
void compile_word(char*label, char*type, char*name)
{
assert(strcmp(type, "real") == 0);
free(type);
vvp_fun_signal_real*fun = new vvp_fun_signal_real;
vvp_net_t*net = new vvp_net_t;
net->fun = fun;
define_functor_symbol(label, net);
vpiHandle obj = vpip_make_real_var(name, net);
free(name);
compile_vpi_symbol(label, obj);
free(label);
vpip_attach_to_current_scope(obj);
}
#endif
void compile_var_real(char*label, char*name, int msb, int lsb)
{
vvp_fun_signal_real*fun = new vvp_fun_signal_real;
@ -155,8 +135,55 @@ void compile_net_real(char*label, char*name, int msb, int lsb,
free(argv);
}
void compile_alias(char*label, char*name, int msb, int lsb, bool signed_flag,
unsigned argc, struct symb_s*argv)
{
assert(argc == 1);
vvp_net_t*node = vvp_net_lookup(argv[0].text);
/* Add the label into the functor symbol table. */
define_functor_symbol(label, node);
/* Make the vpiHandle for the reg. */
vpiHandle obj = vpip_make_net(name, node);
compile_vpi_symbol(label, obj);
vpip_attach_to_current_scope(obj);
free(label);
free(name);
free(argv[0].text);
free(argv);
}
void compile_alias_real(char*label, char*name, int msb, int lsb,
unsigned argc, struct symb_s*argv)
{
assert(argc == 1);
vvp_net_t*node = vvp_net_lookup(argv[0].text);
/* Add the label into the functor symbol table. */
define_functor_symbol(label, node);
/* Make the vpiHandle for the reg. */
vpiHandle obj = vpip_make_real_var(name, msb, lsb, signed_flag, node);
compile_vpi_symbol(label, obj);
vpip_attach_to_current_scope(obj);
free(label);
free(name);
free(argv[0].text);
free(argv);
}
/*
* $Log: words.cc,v $
* Revision 1.4 2005/10/12 17:23:16 steve
* Add alias nodes.
*
* Revision 1.3 2005/07/06 04:29:25 steve
* Implement real valued signals and arith nodes.
*