From 15fee99abb74bd4cae363068984f65379463a83e Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Sat, 10 Nov 2012 12:54:28 +0000 Subject: [PATCH] Fix for pr3571573. This patchs adds an implementation of recv_vec4_pv() to the vvp_fun_concat class. This was already present in devel, so just needed to be backported to v0.9. --- vvp/concat.cc | 30 ++++++++++++++++++++++++++++++ vvp/vvp_net.h | 5 +++++ 2 files changed, 35 insertions(+) diff --git a/vvp/concat.cc b/vvp/concat.cc index c4457dc4e..f8b63e8d7 100644 --- a/vvp/concat.cc +++ b/vvp/concat.cc @@ -64,6 +64,36 @@ void vvp_fun_concat::recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit, vvp_send_vec4(port.ptr()->out, val_, 0); } +void vvp_fun_concat::recv_vec4_pv(vvp_net_ptr_t port, const vvp_vector4_t&bit, + unsigned base, unsigned wid, unsigned vwid, + vvp_context_t) +{ + assert(bit.size() == wid); + + unsigned pdx = port.port(); + + if (vwid != wid_[pdx]) { + cerr << "internal error: port " << pdx + << " expects wid=" << wid_[pdx] + << ", got wid=" << vwid << endl; + assert(0); + } + + unsigned off = 0; + for (unsigned idx = 0 ; idx < pdx ; idx += 1) + off += wid_[idx]; + + unsigned limit = off + wid_[pdx]; + + off += base; + for (unsigned idx = 0 ; idx < wid ; idx += 1) { + if (off+idx >= limit) break; + val_.set_bit(off+idx, bit.value(idx)); + } + + vvp_send_vec4(port.ptr()->out, val_, 0); +} + void compile_concat(char*label, unsigned w0, unsigned w1, unsigned w2, unsigned w3, unsigned argc, struct symb_s*argv) diff --git a/vvp/vvp_net.h b/vvp/vvp_net.h index 0ef7805fd..b46520158 100644 --- a/vvp/vvp_net.h +++ b/vvp/vvp_net.h @@ -1067,6 +1067,11 @@ class vvp_fun_concat : public vvp_net_fun_t { void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit, vvp_context_t context); + // Part select variants of above + void recv_vec4_pv(vvp_net_ptr_t port, const vvp_vector4_t&bit, + unsigned base, unsigned wid, unsigned vwid, + vvp_context_t); + private: unsigned wid_[4]; vvp_vector4_t val_;