diff --git a/elab_expr.cc b/elab_expr.cc index 7a66620c3..e9579582c 100644 --- a/elab_expr.cc +++ b/elab_expr.cc @@ -2318,7 +2318,7 @@ NetExpr* PECallFunction::elaborate_expr_method_(Design*des, NetScope*scope, if (net->darray_type()) { if (method_name == "size") { - NetESFunc*sys_expr = new NetESFunc("$ivl_darray_method$size", + NetESFunc*sys_expr = new NetESFunc("$size", IVL_VT_BOOL, 32, 1); sys_expr->parm(0, new NetESignal(net)); sys_expr->set_line(*this); @@ -2812,7 +2812,7 @@ unsigned PEIdent::test_width_method_(Design*des, NetScope*scope, width_mode_t&mo return 0; } - if (const netdarray_t*dtype = net->darray_type()) { + if (/*const netdarray_t*dtype =*/ net->darray_type()) { if (member_name == "size") { expr_type_ = IVL_VT_BOOL; expr_width_ = 32; @@ -3246,8 +3246,7 @@ NetExpr* PEIdent::elaborate_expr_method_(Design*des, NetScope*scope, if (const netdarray_t*dtype = net->darray_type()) { if (member_name == "size") { - NetESFunc*fun = new NetESFunc("$ivl_queue_method$size", - expr_type_, expr_width_, 1); + NetESFunc*fun = new NetESFunc("$size", IVL_VT_BOOL, 32, 1); fun->set_line(*this); NetESignal*arg = new NetESignal(net); diff --git a/eval_tree.cc b/eval_tree.cc index 1faa36a43..15bbc96d4 100644 --- a/eval_tree.cc +++ b/eval_tree.cc @@ -2016,6 +2016,7 @@ static bool get_array_info(const NetExpr*arg, long dim, /* A string or dynamic array must be handled by the run time. */ switch (sig->data_type()) { case IVL_VT_DARRAY: + case IVL_VT_QUEUE: case IVL_VT_STRING: defer = true; return true; diff --git a/vpi/sys_darray.c b/vpi/sys_darray.c index b4cd2f54e..7038ab05e 100644 --- a/vpi/sys_darray.c +++ b/vpi/sys_darray.c @@ -83,11 +83,11 @@ void sys_darray_register(void) tf_data.type = vpiSysFunc; tf_data.sysfunctype = vpiIntFunc; - tf_data.tfname = "$ivl_darray_method$size"; + tf_data.tfname = "$size"; tf_data.calltf = size_calltf; tf_data.compiletf = one_darray_arg_compiletf; tf_data.sizetf = 0; - tf_data.user_data = "$ivl_darray_method$size"; + tf_data.user_data = "$size"; res = vpi_register_systf(&tf_data); vpip_make_systf_system_defined(res); } diff --git a/vpi/v2009_array.c b/vpi/v2009_array.c index f362b5b8f..fd760cea6 100644 --- a/vpi/v2009_array.c +++ b/vpi/v2009_array.c @@ -75,9 +75,4 @@ void v2009_array_register(void) tf_data.user_data = "$increment"; res = vpi_register_systf(&tf_data); vpip_make_systf_system_defined(res); - - tf_data.tfname = "$size"; - tf_data.user_data = "$size"; - res = vpi_register_systf(&tf_data); - vpip_make_systf_system_defined(res); } diff --git a/vvp/vpi_darray.cc b/vvp/vpi_darray.cc index dc4e0dbd2..95046ecee 100644 --- a/vvp/vpi_darray.cc +++ b/vvp/vpi_darray.cc @@ -93,7 +93,7 @@ int __vpiQueueVar::vpi_get(int code) vvp_fun_signal_object*fun = dynamic_cast (get_net()->fun); assert(fun); vvp_object_t val = fun->get_object(); - vvp_darray*aval = val.peek(); + vvp_queue*aval = val.peek(); switch (code) { case vpiArrayType: diff --git a/vvp/vthread.cc b/vvp/vthread.cc index a47c1db52..8319df364 100644 --- a/vvp/vthread.cc +++ b/vvp/vthread.cc @@ -4272,7 +4272,8 @@ bool of_NEW_DARRAY(vthread_t thr, vvp_code_t cp) } else if (strcmp(text,"S") == 0) { obj = new vvp_darray_string(size); } else { - obj = new vvp_darray (size); + // XXXX This should not happen. + obj = new vvp_darray_atom (size); } thr->push_object(obj); diff --git a/vvp/vvp_darray.cc b/vvp/vvp_darray.cc index 525f6061e..10be197a1 100644 --- a/vvp/vvp_darray.cc +++ b/vvp/vvp_darray.cc @@ -62,6 +62,11 @@ template vvp_darray_atom::~vvp_darray_atom() { } +template size_t vvp_darray_atom::get_size() const +{ + return array_.size(); +} + template void vvp_darray_atom::set_word(unsigned adr, const vvp_vector4_t&value) { if (adr >= array_.size()) @@ -100,6 +105,11 @@ vvp_darray_real::~vvp_darray_real() { } +size_t vvp_darray_real::get_size() const +{ + return array_.size(); +} + void vvp_darray_real::set_word(unsigned adr, double value) { if (adr >= array_.size()) @@ -121,6 +131,11 @@ vvp_darray_string::~vvp_darray_string() { } +size_t vvp_darray_string::get_size() const +{ + return array_.size(); +} + void vvp_darray_string::set_word(unsigned adr, const string&value) { if (adr >= array_.size()) @@ -176,6 +191,11 @@ vvp_queue_string::~vvp_queue_string() { } +size_t vvp_queue_string::get_size() const +{ + return array_.size(); +} + void vvp_queue_string::push_back(const string&val) { array_.push_back(val); @@ -185,6 +205,11 @@ vvp_queue_vec4::~vvp_queue_vec4() { } +size_t vvp_queue_vec4::get_size() const +{ + return array_.size(); +} + void vvp_queue_vec4::push_back(const vvp_vector4_t&val) { array_.push_back(val); diff --git a/vvp/vvp_darray.h b/vvp/vvp_darray.h index 312145a44..74e18c8df 100644 --- a/vvp/vvp_darray.h +++ b/vvp/vvp_darray.h @@ -29,10 +29,10 @@ class vvp_vector4_t; class vvp_darray : public vvp_object { public: - inline vvp_darray(size_t siz) : size_(siz) { } + inline vvp_darray() { } virtual ~vvp_darray(); - inline size_t get_size(void) const { return size_; } + virtual size_t get_size(void) const =0; virtual void set_word(unsigned adr, const vvp_vector4_t&value); virtual void get_word(unsigned adr, vvp_vector4_t&value); @@ -42,17 +42,15 @@ class vvp_darray : public vvp_object { virtual void set_word(unsigned adr, const std::string&value); virtual void get_word(unsigned adr, std::string&value); - - private: - size_t size_; }; template class vvp_darray_atom : public vvp_darray { public: - inline vvp_darray_atom(size_t siz) : vvp_darray(siz), array_(siz) { } + inline vvp_darray_atom(size_t siz) : array_(siz) { } ~vvp_darray_atom(); + size_t get_size(void) const; void set_word(unsigned adr, const vvp_vector4_t&value); void get_word(unsigned adr, vvp_vector4_t&value); @@ -63,9 +61,10 @@ template class vvp_darray_atom : public vvp_darray { class vvp_darray_real : public vvp_darray { public: - inline vvp_darray_real(size_t siz) : vvp_darray(siz), array_(siz) { } + inline vvp_darray_real(size_t siz) : array_(siz) { } ~vvp_darray_real(); + size_t get_size(void) const; void set_word(unsigned adr, double value); void get_word(unsigned adr, double&value); @@ -76,9 +75,10 @@ class vvp_darray_real : public vvp_darray { class vvp_darray_string : public vvp_darray { public: - inline vvp_darray_string(size_t siz) : vvp_darray(siz), array_(siz) { } + inline vvp_darray_string(size_t siz) : array_(siz) { } ~vvp_darray_string(); + size_t get_size(void) const; void set_word(unsigned adr, const std::string&value); void get_word(unsigned adr, std::string&value); @@ -90,7 +90,7 @@ class vvp_darray_string : public vvp_darray { class vvp_queue : public vvp_darray { public: - inline vvp_queue(void) : vvp_darray(0) { } + inline vvp_queue(void) { } ~vvp_queue(); virtual void push_back(const vvp_vector4_t&value); @@ -108,6 +108,7 @@ class vvp_queue_vec4 : public vvp_queue { public: ~vvp_queue_vec4(); + size_t get_size(void) const; void push_back(const vvp_vector4_t&value); void push_front(const vvp_vector4_t&value); @@ -121,6 +122,7 @@ class vvp_queue_string : public vvp_queue { public: ~vvp_queue_string(); + size_t get_size(void) const; //void set_word(unsigned adr, const std::string&value); //void get_word(unsigned adr, std::string&value); void push_back(const std::string&value);