variable arrays generated without writing a record for each word.

This commit is contained in:
steve 2007-04-10 01:26:15 +00:00
parent d3588b4e23
commit 5047a3add3
7 changed files with 169 additions and 72 deletions

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: vvp_scope.c,v 1.157 2007/04/02 01:12:34 steve Exp $"
#ident "$Id: vvp_scope.c,v 1.158 2007/04/10 01:26:15 steve Exp $"
#endif
# include "vvp_priv.h"
@ -987,18 +987,12 @@ static void draw_reg_in_scope(ivl_signal_t sig)
write out the .array record to declare the array indices. */
if (ivl_signal_dimensions(sig) > 0) {
unsigned word_count = ivl_signal_array_count(sig);
unsigned iword;
int last = ivl_signal_array_base(sig)+ivl_signal_array_count(sig)-1;
int last = ivl_signal_array_base(sig)+word_count-1;
int first = ivl_signal_array_base(sig);
fprintf(vvp_out, "v%p .array \"%s\", %d %d;\n",
sig, vvp_mangle_name(ivl_signal_basename(sig)),
last, first);
/* Scan the words of the array... */
for (iword = 0 ; iword < word_count ; iword += 1) {
fprintf(vvp_out, "v%p_%u .var%s v%p, %d %d;\n",
sig, iword, datatype_flag, sig, msb, lsb);
}
fprintf(vvp_out, "v%p .array%s \"%s\", %d %d, %d %d;\n",
sig, datatype_flag,
vvp_mangle_name(ivl_signal_basename(sig)),
last, first, msb, lsb);
} else {
@ -1066,10 +1060,10 @@ static void draw_net_in_scope(ivl_signal_t sig)
if (dimensions > 0) {
/* If this is a word of an array, then use an
array reference in place of the net name. */
fprintf(vvp_out, "v%p_%u .net%s%s v%p, %d %d, %s;"
fprintf(vvp_out, "v%p_%u .net%s%s v%p %u, %d %d, %s;"
" %u drivers%s\n",
sig, iword, vec8, datatype_flag, sig,
msb, lsb, driver,
iword, msb, lsb, driver,
nex_data->drivers_count,
strength_aware_flag?", strength-aware":"");
} else {
@ -2370,6 +2364,9 @@ int draw_scope(ivl_scope_t net, ivl_scope_t parent)
/*
* $Log: vvp_scope.c,v $
* Revision 1.158 2007/04/10 01:26:15 steve
* variable arrays generated without writing a record for each word.
*
* Revision 1.157 2007/04/02 01:12:34 steve
* Seperate arrayness from word count
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: array.cc,v 1.1 2007/01/18 00:24:10 steve Exp $"
#ident "$Id: array.cc,v 1.2 2007/04/10 01:26:16 steve Exp $"
#endif
# include "array.h"
@ -301,28 +301,21 @@ static vpiHandle vpip_make_array(char*label, const char*name,
return &(obj->base);
}
void array_attach_word(vvp_array_t array, vpiHandle word)
void array_attach_word(vvp_array_t array, unsigned long addr, vpiHandle word)
{
unsigned idx;
for (idx = 0 ; idx < array->array_count ; idx += 1) {
if (array->words[idx] == 0) {
array->words[idx] = word;
break;
}
}
assert(idx < array->array_count);
assert(addr < array->array_count);
array->words[addr] = word;
if (struct __vpiSignal*sig = vpip_signal_from_handle(word)) {
vvp_net_t*net = sig->node;
assert(net);
vvp_fun_signal_base*fun = dynamic_cast<vvp_fun_signal_base*>(net->fun);
assert(fun);
fun->attach_as_word(array, idx);
fun->attach_as_word(array, addr);
}
}
void compile_array(char*label, char*name, int last, int first)
static vpiHandle common_array_build(char*label, char*name, int last, int first)
{
vpiHandle obj = vpip_make_array(label, name, first, last);
/* Add this into the table of VPI objects. This is used for
@ -332,6 +325,51 @@ void compile_array(char*label, char*name, int last, int first)
/* Blindly attach to the scope as an object. */
vpip_attach_to_current_scope(obj);
return obj;
}
void compile_var_array(char*label, char*name, int last, int first,
int msb, int lsb, char signed_flag)
{
vpiHandle obj = common_array_build(label, name, last, first);
struct __vpiArray*arr = ARRAY_HANDLE(obj);
vvp_array_t array = array_find(label);
/* Make the words. */
for (unsigned idx = 0 ; idx < arr->array_count ; idx += 1) {
char buf[64];
snprintf(buf, sizeof buf, "%s_%u", label, idx);
compile_variablew(strdup(buf), array, idx, msb, lsb, signed_flag);
}
free(label);
free(name);
}
void compile_real_array(char*label, char*name, int last, int first,
int msb, int lsb)
{
vpiHandle obj = common_array_build(label, name, last, first);
struct __vpiArray*arr = ARRAY_HANDLE(obj);
vvp_array_t array = array_find(label);
/* Make the words. */
for (unsigned idx = 0 ; idx < arr->array_count ; idx += 1) {
char buf[64];
snprintf(buf, sizeof buf, "%s_%u", label, idx);
compile_varw_real(strdup(buf), array, idx, msb, lsb);
}
free(label);
free(name);
}
void compile_net_array(char*label, char*name, int last, int first)
{
vpiHandle obj = common_array_build(label, name, last, first);
free(label);
free(name);
}
@ -429,6 +467,9 @@ void compile_array_port(char*label, char*array, char*addr)
/*
* $Log: array.cc,v $
* Revision 1.2 2007/04/10 01:26:16 steve
* variable arrays generated without writing a record for each word.
*
* Revision 1.1 2007/01/18 00:24:10 steve
* Add missing array source files to CVS.
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: array.h,v 1.1 2007/01/18 00:24:10 steve Exp $"
#ident "$Id: array.h,v 1.2 2007/04/10 01:26:16 steve Exp $"
#endif
#include "vvp_net.h"
@ -35,7 +35,7 @@ extern vvp_array_t array_find(char*label);
extern void array_word_change(vvp_array_t array, unsigned long addr);
extern void array_attach_word(vvp_array_t array, vpiHandle word);
extern void array_attach_word(vvp_array_t array, unsigned long addr, vpiHandle word);
extern void array_set_word(vvp_array_t arr,
unsigned idx,
@ -44,8 +44,18 @@ extern void array_set_word(vvp_array_t arr,
extern vvp_vector4_t array_get_word(vvp_array_t array, unsigned adddress);
extern void compile_variablew(char*label, vvp_array_t array,
unsigned long array_addr,
int msb, int lsb, char signed_flag);
extern void compile_varw_real(char*label, vvp_array_t array,
unsigned long array_addr,
int msb, int lsb);
/*
* $Log: array.h,v $
* Revision 1.2 2007/04/10 01:26:16 steve
* variable arrays generated without writing a record for each word.
*
* Revision 1.1 2007/01/18 00:24:10 steve
* Add missing array source files to CVS.
*

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.87 2007/03/02 06:13:22 steve Exp $"
#ident "$Id: compile.h,v 1.88 2007/04/10 01:26:16 steve Exp $"
#endif
# include <stdio.h>
@ -243,7 +243,14 @@ extern char **compile_udp_table(char **table, char *row);
* Memory Instances, Ports, and Initialization
*/
extern void compile_array(char*label, char*name, int last, int first);
extern void compile_var_array(char*label, char*name,
int last, int first,
int msb, int lsb, char signed_flag);
extern void compile_real_array(char*label, char*name,
int last, int first,
int msb, int lsb);
extern void compile_net_array(char*label, char*name,
int last, int first);
extern void compile_array_port(char*label, char*name, char*addr);
@ -338,10 +345,6 @@ extern void compile_variable(char*label, char*name,
int msb, int lsb, char signed_flag);
extern void compile_var_real(char*label, char*name,
int msb, int lsb);
extern void compile_variablew(char*label, char*array_symbol,
int msb, int lsb, char signed_flag);
extern void compile_varw_real(char*label, char*array_symbol,
int msb, int lsb);
extern void compile_net(char*label, char*name,
int msb, int lsb, bool signed_flag,
@ -352,6 +355,7 @@ extern void compile_net_real(char*label, char*name,
unsigned argc, struct symb_s*argv);
extern void compile_netw(char*label, char*array_symbol,
unsigned long array_addr,
int msb, int lsb, bool signed_flag,
bool net8_flag,
unsigned argc, struct symb_s*argv);
@ -368,6 +372,9 @@ extern void compile_alias_real(char*label, char*name,
/*
* $Log: compile.h,v $
* Revision 1.88 2007/04/10 01:26:16 steve
* variable arrays generated without writing a record for each word.
*
* Revision 1.87 2007/03/02 06:13:22 steve
* Add support for edge sensitive spec paths.
*

View File

@ -21,7 +21,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: lexor.lex,v 1.65 2007/01/16 05:44:16 steve Exp $"
#ident "$Id: lexor.lex,v 1.66 2007/04/10 01:26:16 steve Exp $"
#endif
# include "parse_misc.h"
@ -97,6 +97,9 @@
".arith/sub.r" { return K_ARITH_SUB_R; }
".arith/sum" { return K_ARITH_SUM; }
".array" { return K_ARRAY; }
".array/i" { return K_ARRAY_I; }
".array/real" { return K_ARRAY_R; }
".array/s" { return K_ARRAY_S; }
".array/port" { return K_ARRAY_PORT; }
".cmp/eeq" { return K_CMP_EEQ; }
".cmp/eq" { return K_CMP_EQ; }
@ -214,6 +217,9 @@ int yywrap()
/*
* $Log: lexor.lex,v $
* Revision 1.66 2007/04/10 01:26:16 steve
* variable arrays generated without writing a record for each word.
*
* Revision 1.65 2007/01/16 05:44:16 steve
* Major rework of array handling. Memories are replaced with the
* more general concept of arrays. The NetMemory and NetEMemory

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.89 2007/03/02 06:13:22 steve Exp $"
#ident "$Id: parse.y,v 1.90 2007/04/10 01:26:16 steve Exp $"
#endif
# include "parse_misc.h"
@ -67,7 +67,8 @@ static vvp_fun_modpath*modpath_dst = 0;
%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 K_ARRAY K_ARRAY_PORT
%token K_ARITH_SUB K_ARITH_SUB_R K_ARITH_SUM K_ARRAY K_ARRAY_I K_ARRAY_R
%token K_ARRAY_S K_ARRAY_PORT
%token K_CMP_EEQ K_CMP_EQ K_CMP_NEE K_CMP_NE
%token K_CMP_GE K_CMP_GE_S K_CMP_GT K_CMP_GT_S
%token K_CONCAT K_DEBUG K_DELAY K_DFF
@ -177,8 +178,20 @@ statement
| mem_init_stmt
| T_LABEL K_ARRAY T_STRING ',' signed_t_number signed_t_number ',' signed_t_number signed_t_number ';'
{ compile_var_array($1, $3, $5, $6, $8, $9, 0); }
| T_LABEL K_ARRAY_I T_STRING ',' signed_t_number signed_t_number ',' signed_t_number signed_t_number ';'
{ compile_var_array($1, $3, $5, $6, $8, $9, 2); }
| T_LABEL K_ARRAY_R T_STRING ',' signed_t_number signed_t_number ',' signed_t_number signed_t_number ';'
{ compile_real_array($1, $3, $5, $6, $8, $9); }
| T_LABEL K_ARRAY_S T_STRING ',' signed_t_number signed_t_number ',' signed_t_number signed_t_number ';'
{ compile_var_array($1, $3, $5, $6, $8, $9, 1); }
| T_LABEL K_ARRAY T_STRING ',' signed_t_number signed_t_number ';'
{ compile_array($1, $3, $5, $6); }
{ compile_net_array($1, $3, $5, $6); }
| T_LABEL K_ARRAY_PORT T_SYMBOL ',' T_SYMBOL ';'
{ compile_array_port($1, $3, $5); }
@ -493,17 +506,6 @@ statement
| T_LABEL K_VAR_R T_STRING ',' signed_t_number signed_t_number ';'
{ compile_var_real($1, $3, $5, $6); }
/* Arrayed versions of variable directives. */
| T_LABEL K_VAR T_SYMBOL ',' signed_t_number signed_t_number ';'
{ compile_variablew($1, $3, $5, $6, 0 /* unsigned */ ); }
| T_LABEL K_VAR_S T_SYMBOL ',' signed_t_number signed_t_number ';'
{ compile_variablew($1, $3, $5, $6, 1 /* signed */ ); }
| T_LABEL K_VAR_I T_SYMBOL ',' T_NUMBER T_NUMBER ';'
{ compile_variablew($1, $3, $5, $6, 2 /* integer */); }
/* Net statements are similar to .var statements, except that they
declare nets, and they have an input list. */
@ -541,9 +543,10 @@ statement
/* Arrayed versions of net directives. */
| T_LABEL K_NET T_SYMBOL ',' signed_t_number signed_t_number
',' symbols_net ';'
{ compile_netw($1, $3, $5, $6, false, false, $8.cnt, $8.vect); }
| T_LABEL K_NET T_SYMBOL T_NUMBER ','
signed_t_number signed_t_number ','
symbols_net ';'
{ compile_netw($1, $3, $4, $6, $7, false, false, $9.cnt, $9.vect); }
/* Parameter statements come in a few simple forms. The most basic
is the string parameter. */
@ -813,6 +816,9 @@ int compile_design(const char*path)
/*
* $Log: parse.y,v $
* Revision 1.90 2007/04/10 01:26:16 steve
* variable arrays generated without writing a record for each word.
*
* Revision 1.89 2007/03/02 06:13:22 steve
* Add support for edge sensitive spec paths.
*

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.8 2007/01/16 05:44:17 steve Exp $"
#ident "$Id: words.cc,v 1.9 2007/04/10 01:26:16 steve Exp $"
#endif
# include "compile.h"
@ -32,7 +32,9 @@
#endif
# include <assert.h>
void compile_var_real(char*label, char*name, int msb, int lsb)
static void __compile_var_real(char*label, char*name,
vvp_array_t array, unsigned long array_addr,
int msb, int lsb)
{
vvp_fun_signal_real*fun = new vvp_fun_signal_real;
vvp_net_t*net = new vvp_net_t;
@ -40,19 +42,39 @@ void compile_var_real(char*label, char*name, int msb, int lsb)
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);
if (name) {
assert(!array);
vpip_attach_to_current_scope(obj);
}
if (array) {
assert(!name);
array_attach_word(array, array_addr, obj);
}
free(label);
if (name) free(name);
}
void compile_var_real(char*label, char*name, int msb, int lsb)
{
__compile_var_real(label, name, 0, 0, msb, lsb);
}
void compile_varw_real(char*label, vvp_array_t array,
unsigned long addr,
int msb, int lsb)
{
__compile_var_real(label, 0, array, addr, msb, lsb);
}
/*
* A variable is a special functor, so we allocate that functor and
* write the label into the symbol table.
*/
static void __compile_var(char*label, char*name, char*array_label,
static void __compile_var(char*label, char*name,
vvp_array_t array, unsigned long array_addr,
int msb, int lsb, char signed_flag)
{
unsigned wid = ((msb > lsb)? msb-lsb : lsb-msb) + 1;
@ -60,9 +82,6 @@ static void __compile_var(char*label, char*name, char*array_label,
vvp_fun_signal*vsig = new vvp_fun_signal(wid);
vvp_net_t*node = new vvp_net_t;
vvp_array_t array = array_label? array_find(array_label) : 0;
assert(array_label? array!=0 : true);
node->fun = vsig;
define_functor_symbol(label, node);
@ -81,23 +100,30 @@ static void __compile_var(char*label, char*name, char*array_label,
// it is attached to the addressed array.
if (array) {
assert(!name);
array_attach_word(array, obj);
array_attach_word(array, array_addr, obj);
}
free(label);
if (name) free(name);
if (array_label) free(array_label);
}
void compile_variable(char*label, char*name,
int msb, int lsb, char signed_flag)
{
__compile_var(label, name, 0, msb, lsb, signed_flag);
__compile_var(label, name, 0, 0, msb, lsb, signed_flag);
}
void compile_variablew(char*label, char*array_label,
/*
* In this case, the variable it intended to be attached to the array
* as a word. The array_addr is the *canonical* address of the word in
* the array.
*
* This function is actually used by the compile_array function,
* instead of directly by the parser.
*/
void compile_variablew(char*label, vvp_array_t array, unsigned long array_addr,
int msb, int lsb, char signed_flag)
{
__compile_var(label, 0, array_label, msb, lsb, signed_flag);
__compile_var(label, 0, array, array_addr, msb, lsb, signed_flag);
}
/*
@ -111,7 +137,8 @@ void compile_variablew(char*label, char*array_label,
* Create a VPI handle to represent it, and fill that handle in with
* references into the net.
*/
static void __compile_net(char*label, char*name, char*array_label,
static void __compile_net(char*label, char*name,
char*array_label, unsigned long array_addr,
int msb, int lsb,
bool signed_flag, bool net8_flag,
unsigned argc, struct symb_s*argv)
@ -141,7 +168,7 @@ static void __compile_net(char*label, char*name, char*array_label,
compile_vpi_symbol(label, obj);
vpip_attach_to_current_scope(obj);
if (array)
array_attach_word(array, obj);
array_attach_word(array, array_addr, obj);
free(label);
if (name) free(name);
@ -154,17 +181,17 @@ void compile_net(char*label, char*name,
bool signed_flag, bool net8_flag,
unsigned argc, struct symb_s*argv)
{
__compile_net(label, name, 0,
__compile_net(label, name, 0, 0,
msb, lsb, signed_flag, net8_flag,
argc, argv);
}
void compile_netw(char*label, char*array_label,
void compile_netw(char*label, char*array_label, unsigned long array_addr,
int msb, int lsb,
bool signed_flag, bool net8_flag,
unsigned argc, struct symb_s*argv)
{
__compile_net(label, 0, array_label,
__compile_net(label, 0, array_label, array_addr,
msb, lsb, signed_flag, net8_flag,
argc, argv);
}
@ -241,6 +268,9 @@ void compile_alias_real(char*label, char*name, int msb, int lsb,
/*
* $Log: words.cc,v $
* Revision 1.9 2007/04/10 01:26:16 steve
* variable arrays generated without writing a record for each word.
*
* Revision 1.8 2007/01/16 05:44:17 steve
* Major rework of array handling. Memories are replaced with the
* more general concept of arrays. The NetMemory and NetEMemory