Add functionality to alias an individual word of an array.
This patch adds the functionality to alias an individual word of an array.
This commit is contained in:
parent
04e8623ed6
commit
bb14ac1fe0
|
|
@ -1120,19 +1120,31 @@ static void draw_net_in_scope(ivl_signal_t sig)
|
|||
discover that the entire array can be collapsed,
|
||||
so the word count for the signal and the alias
|
||||
*must* match. */
|
||||
assert(word_count == ivl_signal_array_count(nex_data->net));
|
||||
|
||||
if (iword == 0) {
|
||||
fprintf(vvp_out, "v%p .array \"%s\", v%p; Alias to %s\n",
|
||||
sig, vvp_mangle_name(ivl_signal_basename(sig)),
|
||||
nex_data->net, ivl_signal_basename(nex_data->net));
|
||||
if (word_count == ivl_signal_array_count(nex_data->net)) {
|
||||
if (iword == 0) {
|
||||
fprintf(vvp_out, "v%p .array \"%s\", v%p; Alias to %s\n",
|
||||
sig, vvp_mangle_name(ivl_signal_basename(sig)),
|
||||
nex_data->net,
|
||||
ivl_signal_basename(nex_data->net));
|
||||
}
|
||||
/* An alias for an individual word. */
|
||||
} else {
|
||||
if (iword == 0) {
|
||||
int first = ivl_signal_array_base(sig);
|
||||
int last = first + word_count-1;
|
||||
fprintf(vvp_out, "v%p .array \"%s\", %d %d;\n",
|
||||
sig,
|
||||
vvp_mangle_name(ivl_signal_basename(sig)),
|
||||
last, first);
|
||||
}
|
||||
|
||||
fprintf(vvp_out, "v%p_%u .alias%s v%p %u, %d %d, "
|
||||
"v%p_%u; Alias to %s\n", sig, iword,
|
||||
datatype_flag, sig, iword, msb, lsb,
|
||||
nex_data->net, nex_data->net_word,
|
||||
ivl_signal_basename(nex_data->net));
|
||||
}
|
||||
/* An alias for the individual words? */
|
||||
#if 0
|
||||
fprintf(vvp_out, "v%p_%u .alias%s v%p, %d %d, v%p_%u;\n",
|
||||
sig, iword, datatype_flag, sig,
|
||||
msb, lsb, nex_data->net, nex_data->net_word);
|
||||
#endif
|
||||
} else {
|
||||
/* Finally, we may have an alias that is a word
|
||||
connected to another word. Again, this is a
|
||||
|
|
|
|||
12
vvp/array.cc
12
vvp/array.cc
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2007 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 2007-2008 Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
* This source code is free software; you can redistribute it
|
||||
* and/or modify it in source code form under the terms of the GNU
|
||||
|
|
@ -16,9 +16,6 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ifdef HAVE_CVS_IDENT
|
||||
#ident "$Id: array.cc,v 1.2 2007/04/10 01:26:16 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "array.h"
|
||||
#include "symbols.h"
|
||||
|
|
@ -345,6 +342,12 @@ static vpiHandle vpip_make_array(char*label, const char*name,
|
|||
return &(obj->base);
|
||||
}
|
||||
|
||||
void array_alias_word(vvp_array_t array, unsigned long addr, vpiHandle word)
|
||||
{
|
||||
assert(addr < array->array_count);
|
||||
array->words[addr] = word;
|
||||
}
|
||||
|
||||
void array_attach_word(vvp_array_t array, unsigned long addr, vpiHandle word)
|
||||
{
|
||||
assert(addr < array->array_count);
|
||||
|
|
@ -546,4 +549,3 @@ void compile_array_alias(char*label, char*name, char*src)
|
|||
free(name);
|
||||
free(src);
|
||||
}
|
||||
|
||||
|
|
|
|||
10
vvp/array.h
10
vvp/array.h
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef __array_H // -*- c++ -*-
|
||||
#define __array_H
|
||||
/*
|
||||
* Copyright (c) 2007 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 2007-2008 Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
* This source code is free software; you can redistribute it
|
||||
* and/or modify it in source code form under the terms of the GNU
|
||||
|
|
@ -18,9 +18,6 @@
|
|||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#ifdef HAVE_CVS_IDENT
|
||||
#ident "$Id: array.h,v 1.2 2007/04/10 01:26:16 steve Exp $"
|
||||
#endif
|
||||
|
||||
#include "vvp_net.h"
|
||||
#include "vpi_user.h"
|
||||
|
|
@ -36,7 +33,10 @@ extern vpiHandle array_index_iterate(int code, vpiHandle ref);
|
|||
|
||||
extern void array_word_change(vvp_array_t array, unsigned long addr);
|
||||
|
||||
extern void array_attach_word(vvp_array_t array, unsigned long addr, vpiHandle word);
|
||||
extern void array_attach_word(vvp_array_t array, unsigned long addr,
|
||||
vpiHandle word);
|
||||
extern void array_alias_word(vvp_array_t array, unsigned long addr,
|
||||
vpiHandle word);
|
||||
|
||||
extern void array_set_word(vvp_array_t arr,
|
||||
unsigned idx,
|
||||
|
|
|
|||
|
|
@ -247,6 +247,13 @@ static vvp_net_t*lookup_functor_symbol(const char*label)
|
|||
return val.net;
|
||||
}
|
||||
|
||||
vpiHandle vvp_lookup_handle(const char*label)
|
||||
{
|
||||
symbol_value_t val = sym_get_value(sym_vpi, label);
|
||||
if (val.ptr) return (vpiHandle) val.ptr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
vvp_net_t* vvp_net_lookup(const char*label)
|
||||
{
|
||||
/* First, look to see if the symbol is a vpi object of some
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ 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);
|
||||
extern vpiHandle vvp_lookup_handle(const char*label);
|
||||
|
||||
/*
|
||||
* Add a functor to the symbol table
|
||||
|
|
@ -408,5 +409,8 @@ extern void compile_alias(char*label, char*name,
|
|||
extern void compile_alias_real(char*label, char*name,
|
||||
int msb, int lsb,
|
||||
unsigned argc, struct symb_s*argv);
|
||||
extern void compile_aliasw(char*label, char*array_symbol,
|
||||
unsigned long array_addr, int msb, int lsb,
|
||||
unsigned argc, struct symb_s*argv);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
12
vvp/parse.y
12
vvp/parse.y
|
|
@ -642,6 +642,18 @@ statement
|
|||
symbols_net ';'
|
||||
{ compile_netw($1, $3, $4, $6, $7, true, true, $9.cnt, $9.vect); }
|
||||
|
||||
/* Array word versions of alias directives. */
|
||||
|
||||
| T_LABEL K_ALIAS T_SYMBOL T_NUMBER ','
|
||||
signed_t_number signed_t_number ','
|
||||
symbols_net ';'
|
||||
{ compile_aliasw($1, $3, $4, $6, $7, $9.cnt, $9.vect); }
|
||||
|
||||
| T_LABEL K_ALIAS_R T_SYMBOL T_NUMBER ','
|
||||
signed_t_number signed_t_number ','
|
||||
symbols_net ';'
|
||||
{ compile_aliasw($1, $3, $4, $6, $7, $9.cnt, $9.vect); }
|
||||
|
||||
/* Parameter statements come in a few simple forms. The most basic
|
||||
is the string parameter. */
|
||||
|
||||
|
|
|
|||
25
vvp/words.cc
25
vvp/words.cc
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003-2007 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 2003-2008 Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
* This source code is free software; you can redistribute it
|
||||
* and/or modify it in source code form under the terms of the GNU
|
||||
|
|
@ -234,6 +234,28 @@ void compile_net_real(char*label, char*name, int msb, int lsb, bool local_flag,
|
|||
free(argv);
|
||||
}
|
||||
|
||||
void compile_aliasw(char*label, char*array_label, unsigned long array_addr,
|
||||
int msb, int lsb, unsigned argc, struct symb_s*argv)
|
||||
{
|
||||
vvp_array_t array = array_find(array_label);
|
||||
assert(array);
|
||||
|
||||
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);
|
||||
|
||||
vpiHandle obj = vvp_lookup_handle(argv[0].text);
|
||||
assert(obj);
|
||||
array_alias_word(array, array_addr, obj);
|
||||
|
||||
free(label);
|
||||
free(array_label);
|
||||
free(argv[0].text);
|
||||
free(argv);
|
||||
}
|
||||
|
||||
void compile_alias(char*label, char*name, int msb, int lsb, bool signed_flag,
|
||||
unsigned argc, struct symb_s*argv)
|
||||
{
|
||||
|
|
@ -277,4 +299,3 @@ void compile_alias_real(char*label, char*name, int msb, int lsb,
|
|||
free(argv[0].text);
|
||||
free(argv);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue