vvp: Moved array_word_change(), array_attach_word(), array_alias_word() to __vpiArray.
This commit is contained in:
parent
7c77097f71
commit
9bc463aac0
73
vvp/array.cc
73
vvp/array.cc
|
|
@ -686,7 +686,7 @@ void __vpiArray::set_word(unsigned address, unsigned part_off, vvp_vector4_t val
|
||||||
} else {
|
} else {
|
||||||
vals4->set_word(address, val);
|
vals4->set_word(address, val);
|
||||||
}
|
}
|
||||||
array_word_change(this, address);
|
word_change(address);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -696,7 +696,7 @@ void __vpiArray::set_word(unsigned address, unsigned part_off, vvp_vector4_t val
|
||||||
assert(part_off==0);
|
assert(part_off==0);
|
||||||
assert(val.size() == vals_width);
|
assert(val.size() == vals_width);
|
||||||
vals->set_word(address, val);
|
vals->set_word(address, val);
|
||||||
array_word_change(this, address);
|
word_change(address);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -708,7 +708,7 @@ void __vpiArray::set_word(unsigned address, unsigned part_off, vvp_vector4_t val
|
||||||
assert(vsig);
|
assert(vsig);
|
||||||
|
|
||||||
vsig->node->send_vec4_pv(val, part_off, val.size(), vpip_size(vsig), 0);
|
vsig->node->send_vec4_pv(val, part_off, val.size(), vpip_size(vsig), 0);
|
||||||
array_word_change(this, address);
|
word_change(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __vpiArray::set_word(unsigned address, double val)
|
void __vpiArray::set_word(unsigned address, double val)
|
||||||
|
|
@ -720,7 +720,7 @@ void __vpiArray::set_word(unsigned address, double val)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
vals->set_word(address, val);
|
vals->set_word(address, val);
|
||||||
array_word_change(this, address);
|
word_change(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __vpiArray::set_word(unsigned address, const string&val)
|
void __vpiArray::set_word(unsigned address, const string&val)
|
||||||
|
|
@ -732,7 +732,7 @@ void __vpiArray::set_word(unsigned address, const string&val)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
vals->set_word(address, val);
|
vals->set_word(address, val);
|
||||||
array_word_change(this, address);
|
word_change(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __vpiArray::set_word(unsigned address, const vvp_object_t&val)
|
void __vpiArray::set_word(unsigned address, const vvp_object_t&val)
|
||||||
|
|
@ -744,7 +744,7 @@ void __vpiArray::set_word(unsigned address, const vvp_object_t&val)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
vals->set_word(address, val);
|
vals->set_word(address, val);
|
||||||
array_word_change(this, address);
|
word_change(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
vvp_vector4_t __vpiArray::get_word(unsigned address)
|
vvp_vector4_t __vpiArray::get_word(unsigned address)
|
||||||
|
|
@ -921,33 +921,32 @@ vpiHandle vpip_make_array(char*label, const char*name,
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
void array_alias_word(vvp_array_t array, unsigned long addr, vpiHandle word,
|
void __vpiArray::alias_word(unsigned long addr, vpiHandle word, int msb_, int lsb_)
|
||||||
int msb, int lsb)
|
|
||||||
{
|
{
|
||||||
assert(array->msb.get_value() == msb);
|
assert(msb.get_value() == msb_);
|
||||||
assert(array->lsb.get_value() == lsb);
|
assert(lsb.get_value() == lsb_);
|
||||||
assert(addr < array->get_size());
|
assert(addr < get_size());
|
||||||
assert(array->nets);
|
assert(nets);
|
||||||
array->nets[addr] = word;
|
nets[addr] = word;
|
||||||
}
|
}
|
||||||
|
|
||||||
void array_attach_word(vvp_array_t array, unsigned addr, vpiHandle word)
|
void __vpiArray::attach_word(unsigned addr, vpiHandle word)
|
||||||
{
|
{
|
||||||
assert(addr < array->get_size());
|
assert(addr < get_size());
|
||||||
assert(array->nets);
|
assert(nets);
|
||||||
array->nets[addr] = word;
|
nets[addr] = word;
|
||||||
|
|
||||||
if (struct __vpiSignal*sig = dynamic_cast<__vpiSignal*>(word)) {
|
if (struct __vpiSignal*sig = dynamic_cast<__vpiSignal*>(word)) {
|
||||||
vvp_net_t*net = sig->node;
|
vvp_net_t*net = sig->node;
|
||||||
assert(net);
|
assert(net);
|
||||||
vvp_vpi_callback*fun = dynamic_cast<vvp_vpi_callback*>(net->fil);
|
vvp_vpi_callback*fun = dynamic_cast<vvp_vpi_callback*>(net->fil);
|
||||||
assert(fun);
|
assert(fun);
|
||||||
fun->attach_as_word(array, addr);
|
fun->attach_as_word(this, addr);
|
||||||
sig->is_netarray = 1;
|
sig->is_netarray = 1;
|
||||||
sig->within.parent = array;
|
sig->within.parent = this;
|
||||||
sig->id.index = new __vpiDecConst(addr + array->first_addr.get_value());
|
sig->id.index = new __vpiDecConst(addr + first_addr.get_value());
|
||||||
// Now we know the data type, update the array signed_flag.
|
// Now we know the data type, update the array signed_flag.
|
||||||
array->signed_flag = sig->signed_flag;
|
signed_flag = sig->signed_flag;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -956,12 +955,12 @@ void array_attach_word(vvp_array_t array, unsigned addr, vpiHandle word)
|
||||||
assert(net);
|
assert(net);
|
||||||
vvp_vpi_callback*fun = dynamic_cast<vvp_vpi_callback*>(net->fil);
|
vvp_vpi_callback*fun = dynamic_cast<vvp_vpi_callback*>(net->fil);
|
||||||
assert(fun);
|
assert(fun);
|
||||||
fun->attach_as_word(array, addr);
|
fun->attach_as_word(this, addr);
|
||||||
sig->is_netarray = 1;
|
sig->is_netarray = 1;
|
||||||
sig->within.parent = array;
|
sig->within.parent = this;
|
||||||
sig->id.index = new __vpiDecConst(addr + array->first_addr.get_value());
|
sig->id.index = new __vpiDecConst(addr + first_addr.get_value());
|
||||||
// Now we know the data type, update the array signed_flag.
|
// Now we know the data type, update the array signed_flag.
|
||||||
array->signed_flag = true;
|
signed_flag = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1116,7 +1115,7 @@ class vvp_fun_arrayport : public vvp_net_fun_t {
|
||||||
unsigned long addr_;
|
unsigned long addr_;
|
||||||
|
|
||||||
friend void array_attach_port(vvp_array_t, vvp_fun_arrayport*);
|
friend void array_attach_port(vvp_array_t, vvp_fun_arrayport*);
|
||||||
friend void array_word_change(vvp_array_t, unsigned long);
|
friend void __vpiArray::word_change(unsigned long);
|
||||||
vvp_fun_arrayport*next_;
|
vvp_fun_arrayport*next_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -1361,13 +1360,13 @@ class array_word_value_callback : public value_callback {
|
||||||
long word_addr;
|
long word_addr;
|
||||||
};
|
};
|
||||||
|
|
||||||
void array_word_change(vvp_array_t array, unsigned long addr)
|
void __vpiArray::word_change(unsigned long addr)
|
||||||
{
|
{
|
||||||
for (vvp_fun_arrayport*cur = array->ports_; cur; cur = cur->next_)
|
for (vvp_fun_arrayport*cur = ports_; cur; cur = cur->next_)
|
||||||
cur->check_word_change(addr);
|
cur->check_word_change(addr);
|
||||||
|
|
||||||
// Run callbacks attached to the array itself.
|
// Run callbacks attached to the array itself.
|
||||||
struct __vpiCallback *next = array->vpi_callbacks;
|
struct __vpiCallback *next = vpi_callbacks;
|
||||||
struct __vpiCallback *prev = 0;
|
struct __vpiCallback *prev = 0;
|
||||||
|
|
||||||
while (next) {
|
while (next) {
|
||||||
|
|
@ -1383,21 +1382,21 @@ void array_word_change(vvp_array_t array, unsigned long addr)
|
||||||
// For whole array callbacks we need to set the index.
|
// For whole array callbacks we need to set the index.
|
||||||
if (cur->word_addr == -1) {
|
if (cur->word_addr == -1) {
|
||||||
cur->cb_data.index = (PLI_INT32) ((int)addr +
|
cur->cb_data.index = (PLI_INT32) ((int)addr +
|
||||||
array->first_addr.get_value());
|
first_addr.get_value());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cur->cb_data.cb_rtn != 0) {
|
if (cur->cb_data.cb_rtn != 0) {
|
||||||
if (cur->test_value_callback_ready()) {
|
if (cur->test_value_callback_ready()) {
|
||||||
if (cur->cb_data.value) {
|
if (cur->cb_data.value) {
|
||||||
if (vpi_array_is_real(array)) {
|
if (vpi_array_is_real(this)) {
|
||||||
double val = 0.0;
|
double val = 0.0;
|
||||||
if (addr < array->vals->get_size())
|
if (addr < vals->get_size())
|
||||||
array->vals->get_word(addr, val);
|
vals->get_word(addr, val);
|
||||||
vpip_real_get_value(val, cur->cb_data.value);
|
vpip_real_get_value(val, cur->cb_data.value);
|
||||||
} else {
|
} else {
|
||||||
vpip_vec4_get_value(array->vals4->get_word(addr),
|
vpip_vec4_get_value(vals4->get_word(addr),
|
||||||
array->vals_width,
|
vals_width,
|
||||||
array->signed_flag,
|
signed_flag,
|
||||||
cur->cb_data.value);
|
cur->cb_data.value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1409,7 +1408,7 @@ void array_word_change(vvp_array_t array, unsigned long addr)
|
||||||
|
|
||||||
} else if (prev == 0) {
|
} else if (prev == 0) {
|
||||||
|
|
||||||
array->vpi_callbacks = next;
|
vpi_callbacks = next;
|
||||||
cur->next = 0;
|
cur->next = 0;
|
||||||
delete cur;
|
delete cur;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,14 +31,7 @@ class value_callback;
|
||||||
*/
|
*/
|
||||||
extern vvp_array_t array_find(const char*label);
|
extern vvp_array_t array_find(const char*label);
|
||||||
|
|
||||||
extern void array_word_change(vvp_array_t array, unsigned long addr);
|
|
||||||
|
|
||||||
extern void array_attach_word(vvp_array_t array, unsigned addr, vpiHandle word);
|
|
||||||
extern void array_alias_word(vvp_array_t array, unsigned long addr,
|
|
||||||
vpiHandle word, int msb, int lsb);
|
|
||||||
|
|
||||||
/* VPI hooks */
|
/* VPI hooks */
|
||||||
|
|
||||||
extern value_callback* vpip_array_word_change(p_cb_data data);
|
extern value_callback* vpip_array_word_change(p_cb_data data);
|
||||||
extern value_callback* vpip_array_change(p_cb_data data);
|
extern value_callback* vpip_array_change(p_cb_data data);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -688,7 +688,7 @@ void vvp_vpi_callback::clear_all_callbacks()
|
||||||
*/
|
*/
|
||||||
void vvp_vpi_callback::run_vpi_callbacks()
|
void vvp_vpi_callback::run_vpi_callbacks()
|
||||||
{
|
{
|
||||||
if (array_) array_word_change(array_, array_word_);
|
if (array_) array_->word_change(array_word_);
|
||||||
|
|
||||||
value_callback *next = vpi_callbacks_;
|
value_callback *next = vpi_callbacks_;
|
||||||
value_callback *prev = 0;
|
value_callback *prev = 0;
|
||||||
|
|
|
||||||
|
|
@ -618,6 +618,10 @@ struct __vpiArray : public __vpiArrayBase, public __vpiHandle {
|
||||||
void get_word_obj(unsigned address, vvp_object_t&val);
|
void get_word_obj(unsigned address, vvp_object_t&val);
|
||||||
std::string get_word_str(unsigned address);
|
std::string get_word_str(unsigned address);
|
||||||
|
|
||||||
|
void alias_word(unsigned long addr, vpiHandle word, int msb, int lsb);
|
||||||
|
void attach_word(unsigned addr, vpiHandle word);
|
||||||
|
void word_change(unsigned long addr);
|
||||||
|
|
||||||
const char*name; /* Permanently allocated string */
|
const char*name; /* Permanently allocated string */
|
||||||
__vpiDecConst first_addr;
|
__vpiDecConst first_addr;
|
||||||
__vpiDecConst last_addr;
|
__vpiDecConst last_addr;
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ static void __compile_var_real(char*label, char*name,
|
||||||
}
|
}
|
||||||
if (array) {
|
if (array) {
|
||||||
assert(!name);
|
assert(!name);
|
||||||
array_attach_word(array, array_addr, obj);
|
array->attach_word(array_addr, obj);
|
||||||
}
|
}
|
||||||
free(label);
|
free(label);
|
||||||
delete[] name;
|
delete[] name;
|
||||||
|
|
@ -365,7 +365,7 @@ static void do_compile_net(vvp_net_t*node, vvp_array_t array,
|
||||||
define_functor_symbol(my_label, node);
|
define_functor_symbol(my_label, node);
|
||||||
|
|
||||||
if (array)
|
if (array)
|
||||||
array_attach_word(array, array_addr, obj);
|
array->attach_word(array_addr, obj);
|
||||||
else if (obj)
|
else if (obj)
|
||||||
vpip_attach_to_scope(scope,obj);
|
vpip_attach_to_scope(scope,obj);
|
||||||
|
|
||||||
|
|
@ -495,7 +495,7 @@ static void __compile_real_net2(vvp_net_t*node, vvp_array_t array,
|
||||||
define_functor_symbol(my_label, node);
|
define_functor_symbol(my_label, node);
|
||||||
|
|
||||||
if (array)
|
if (array)
|
||||||
array_attach_word(array, array_addr, obj);
|
array->attach_word(array_addr, obj);
|
||||||
else if (obj)
|
else if (obj)
|
||||||
vpip_attach_to_scope(scope, obj);
|
vpip_attach_to_scope(scope, obj);
|
||||||
|
|
||||||
|
|
@ -583,7 +583,7 @@ void compile_aliasw(char*label, char*array_label, unsigned long array_addr,
|
||||||
|
|
||||||
vpiHandle obj = vvp_lookup_handle(argv[0].text);
|
vpiHandle obj = vvp_lookup_handle(argv[0].text);
|
||||||
assert(obj);
|
assert(obj);
|
||||||
array_alias_word(array, array_addr, obj, msb, lsb);
|
array->alias_word(array_addr, obj, msb, lsb);
|
||||||
|
|
||||||
free(label);
|
free(label);
|
||||||
free(array_label);
|
free(array_label);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue