From 538a03ba8e2c7753bd4a4ba6e9d437056f2f6baa Mon Sep 17 00:00:00 2001 From: Cary R Date: Tue, 4 Aug 2020 22:06:00 -0700 Subject: [PATCH] Add templates for queue push --- vvp/vthread.cc | 98 ++++++++++++++++++-------------------------------- 1 file changed, 34 insertions(+), 64 deletions(-) diff --git a/vvp/vthread.cc b/vvp/vthread.cc index cbf5ede85..043d996fc 100644 --- a/vvp/vthread.cc +++ b/vvp/vthread.cc @@ -5967,21 +5967,26 @@ bool of_STORE_PROP_V(vthread_t thr, vvp_code_t cp) return true; } +template +static bool store_qb(vthread_t thr, vvp_code_t cp, unsigned wid=0) +{ + ELEM value; + vvp_net_t*net = cp->net; + unsigned max_size = thr->words[cp->bit_idx[0]].w_int; + pop_value(value, thr, wid); // Pop the value to store. + + vvp_queue*queue = get_queue_object(thr, net); + assert(queue); + queue->push_back(value, max_size); + return true; +} + /* * %store/qb/r , */ bool of_STORE_QB_R(vthread_t thr, vvp_code_t cp) { - // Pop the double to be stored... - double value = thr->pop_real(); - - vvp_net_t*net = cp->net; - unsigned max_size = thr->words[cp->bit_idx[0]].w_int; - - vvp_queue*queue = get_queue_object(thr, net); - assert(queue); - queue->push_back(value, max_size); - return true; + return store_qb(thr, cp); } /* @@ -5989,16 +5994,7 @@ bool of_STORE_QB_R(vthread_t thr, vvp_code_t cp) */ bool of_STORE_QB_STR(vthread_t thr, vvp_code_t cp) { - // Pop the string to be stored... - string value = thr->pop_str(); - - vvp_net_t*net = cp->net; - unsigned max_size = thr->words[cp->bit_idx[0]].w_int; - - vvp_queue*queue = get_queue_object(thr, net); - assert(queue); - queue->push_back(value, max_size); - return true; + return store_qb(thr, cp); } /* @@ -6006,18 +6002,7 @@ bool of_STORE_QB_STR(vthread_t thr, vvp_code_t cp) */ bool of_STORE_QB_V(vthread_t thr, vvp_code_t cp) { - // Pop the vec4 value to be stored... - vvp_vector4_t value = thr->pop_vec4(); - - vvp_net_t*net = cp->net; - unsigned max_size = thr->words[cp->bit_idx[0]].w_int; - unsigned wid = cp->bit_idx[1]; - - assert(value.size() == wid); - vvp_queue*queue = get_queue_object(thr, net); - assert(queue); - queue->push_back(value, max_size); - return true; + return store_qb(thr, cp, cp->bit_idx[1]); } template @@ -6072,21 +6057,26 @@ bool of_STORE_QDAR_VEC4(vthread_t thr, vvp_code_t cp) return store_qdar(thr, cp, cp->bit_idx[1]); } + +template +static bool store_qf(vthread_t thr, vvp_code_t cp, unsigned wid=0) +{ + ELEM value; + vvp_net_t*net = cp->net; + unsigned max_size = thr->words[cp->bit_idx[0]].w_int; + pop_value(value, thr, wid); // Pop the value to store. + + vvp_queue*queue = get_queue_object(thr, net); + assert(queue); + queue->push_front(value, max_size); + return true; +} /* * %store/qf/r , */ bool of_STORE_QF_R(vthread_t thr, vvp_code_t cp) { - // Pop the double to be stored... - double value = thr->pop_real(); - - vvp_net_t*net = cp->net; - unsigned max_size = thr->words[cp->bit_idx[0]].w_int; - - vvp_queue*dqueue = get_queue_object(thr, net); - assert(dqueue); - dqueue->push_front(value, max_size); - return true; + return store_qf(thr, cp); } /* @@ -6094,16 +6084,7 @@ bool of_STORE_QF_R(vthread_t thr, vvp_code_t cp) */ bool of_STORE_QF_STR(vthread_t thr, vvp_code_t cp) { - // Pop the string to be stored... - string value = thr->pop_str(); - - vvp_net_t*net = cp->net; - unsigned max_size = thr->words[cp->bit_idx[0]].w_int; - - vvp_queue*dqueue = get_queue_object(thr, net); - assert(dqueue); - dqueue->push_front(value, max_size); - return true; + return store_qf(thr, cp); } /* @@ -6111,18 +6092,7 @@ bool of_STORE_QF_STR(vthread_t thr, vvp_code_t cp) */ bool of_STORE_QF_V(vthread_t thr, vvp_code_t cp) { - // Pop the vec4 value to be stored... - vvp_vector4_t value = thr->pop_vec4(); - - vvp_net_t*net = cp->net; - unsigned max_size = thr->words[cp->bit_idx[0]].w_int; - unsigned wid = cp->bit_idx[1]; - - assert(value.size() == wid); - vvp_queue*dqueue = get_queue_object(thr, net); - assert(dqueue); - dqueue->push_front(value, max_size); - return true; + return store_qf(thr, cp, cp->bit_idx[1]); } bool of_STORE_REAL(vthread_t thr, vvp_code_t cp)