From 22ddb26389b602799c5a1b78baa134ef68ddac0a Mon Sep 17 00:00:00 2001 From: Cary R Date: Mon, 27 Oct 2008 17:54:50 -0700 Subject: [PATCH] Add support for arrays of real nets. This patch adds support for arrays of real values nets (wire real). --- vvp/compile.h | 11 ++++++----- vvp/parse.y | 5 +++++ vvp/vpi_real.cc | 2 +- vvp/words.cc | 43 +++++++++++++++++++++++++++++++++++-------- 4 files changed, 47 insertions(+), 14 deletions(-) diff --git a/vvp/compile.h b/vvp/compile.h index 05d568115..1d2da755d 100644 --- a/vvp/compile.h +++ b/vvp/compile.h @@ -443,12 +443,13 @@ extern void compile_net_real(char*label, char*name, 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); + int msb, int lsb, bool signed_flag, + bool net8_flag, + unsigned argc, struct symb_s*argv); extern void compile_netw_real(char*label, char*array_symbol, - int msb, int lsb, - unsigned argc, struct symb_s*argv); + unsigned long array_addr, + 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, diff --git a/vvp/parse.y b/vvp/parse.y index ce75da3c1..3502dd2d9 100644 --- a/vvp/parse.y +++ b/vvp/parse.y @@ -668,6 +668,11 @@ statement symbols_net ';' { compile_netw($1, $3, $4, $6, $7, true, true, $9.cnt, $9.vect); } + | T_LABEL K_NET_R T_SYMBOL T_NUMBER ',' + signed_t_number signed_t_number ',' + symbols_net ';' + { compile_netw_real($1, $3, $4, $6, $7, $9.cnt, $9.vect); } + /* Array word versions of alias directives. */ | T_LABEL K_ALIAS T_SYMBOL T_NUMBER ',' diff --git a/vvp/vpi_real.cc b/vvp/vpi_real.cc index a6d5f54c6..4c4dc5f98 100644 --- a/vvp/vpi_real.cc +++ b/vvp/vpi_real.cc @@ -186,7 +186,7 @@ vpiHandle vpip_make_real_var(const char*name, vvp_net_t*net) obj->base.vpi_type = &vpip_real_var_rt; obj->parent = 0; - obj->id.name = vpip_name_string(name); + obj->id.name = name ? vpip_name_string(name) : 0; obj->net = net; obj->scope = vpip_peek_current_scope(); diff --git a/vvp/words.cc b/vvp/words.cc index fb048d697..8e61931ef 100644 --- a/vvp/words.cc +++ b/vvp/words.cc @@ -154,8 +154,8 @@ static void __compile_net(char*label, char*name, 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); + vvp_array_t array = array_label ? array_find(array_label) : 0; + assert(array_label ? array!=0 : true); vvp_fun_signal_base*vsig = net8_flag ? dynamic_cast(new vvp_fun_signal8(wid)) @@ -210,11 +210,16 @@ void compile_netw(char*label, char*array_label, unsigned long array_addr, argc, argv); } -void compile_net_real(char*label, char*name, int msb, int lsb, bool local_flag, - unsigned argc, struct symb_s*argv) +static void __compile_real(char*label, char*name, + char*array_label, unsigned long array_addr, + int msb, int lsb, bool local_flag, + unsigned argc, struct symb_s*argv) { vvp_net_t*net = new vvp_net_t; + vvp_array_t array = array_label ? array_find(array_label) : 0; + assert(array_label ? array!=0 : true); + vvp_fun_signal_real*fun = new vvp_fun_signal_real; net->fun = fun; @@ -226,18 +231,40 @@ void compile_net_real(char*label, char*name, int msb, int lsb, bool local_flag, /* Connect the source to my input. */ inputs_connect(net, 1, argv); + vpiHandle obj = 0; if (! local_flag) { /* Make the vpiHandle for the reg. */ - vpiHandle obj = vpip_make_real_var(name, net); + obj = vpip_make_real_var(name, net); + /* This attaches the label to the vpiHandle */ compile_vpi_symbol(label, obj); - vpip_attach_to_current_scope(obj); } - + /* If this is an array word, then attach it to the + array. Otherwise, attach it to the current scope. */ + if (array) + array_attach_word(array, array_addr, obj); + else if (obj) + vpip_attach_to_current_scope(obj); free(label); - free(name); + if (name) free(name); + if (array_label) free(array_label); free(argv); } +void compile_net_real(char*label, char*name, int msb, int lsb, bool local_flag, + unsigned argc, struct symb_s*argv) +{ + __compile_real(label, name, 0, 0, + msb, lsb, local_flag, argc, argv); +} + +void compile_netw_real(char*label, char*array_label, unsigned long array_addr, + int msb, int lsb, + unsigned argc, struct symb_s*argv) +{ + __compile_real(label, 0, array_label, array_addr, + msb, lsb, false, argc, argv); +} + void compile_aliasw(char*label, char*array_label, unsigned long array_addr, int msb, int lsb, unsigned argc, struct symb_s*argv) {