From bf6c4329b9d8bb04ec3dd1615958b3ff8a488e39 Mon Sep 17 00:00:00 2001 From: Cary R Date: Sun, 19 Jul 2020 19:17:18 -0700 Subject: [PATCH] Add push front for string queues and improve some warning messages --- vvp/vthread.cc | 12 ++++++++++-- vvp/vvp_darray.cc | 33 +++++++++++++++++++++++++-------- vvp/vvp_darray.h | 2 +- 3 files changed, 36 insertions(+), 11 deletions(-) diff --git a/vvp/vthread.cc b/vvp/vthread.cc index 209c81ec1..413352b96 100644 --- a/vvp/vthread.cc +++ b/vvp/vthread.cc @@ -5761,9 +5761,17 @@ bool of_STORE_QF_R(vthread_t, vvp_code_t) /* * %store/qf/str , */ -bool of_STORE_QF_STR(vthread_t, vvp_code_t) +bool of_STORE_QF_STR(vthread_t thr, vvp_code_t cp) { - fprintf(stderr, "XXXX %%store/qf/str NOT IMPLEMENTED\n"); + // 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; } diff --git a/vvp/vvp_darray.cc b/vvp/vvp_darray.cc index c24952454..cdeb247d7 100644 --- a/vvp/vvp_darray.cc +++ b/vvp/vvp_darray.cc @@ -449,12 +449,6 @@ size_t vvp_queue_string::get_size() const return array_.size(); } -void vvp_queue_string::push_back(const string&val, unsigned max_size) -{ - if (!max_size || (array_.size() < max_size)) array_.push_back(val); - else cerr << "Warning: value \"" << val << "\" was not added to queue." << endl; -} - void vvp_queue_string::set_word(unsigned adr, const string&value) { if (adr >= array_.size()) @@ -485,6 +479,25 @@ void vvp_queue_string::get_word(unsigned adr, string&value) value = *cur; } +void vvp_queue_string::push_back(const string&val, unsigned max_size) +{ + if (!max_size || (array_.size() < max_size)) array_.push_back(val); + else cerr << "Warning: value \"" << val + << "\" was not added to the end of already full sized (" + << max_size << ") queue." << endl; +} + +void vvp_queue_string::push_front(const string&val, unsigned max_size) +{ + if (max_size && (array_.size() == max_size)) { + cerr << "Warning: value \"" << array_.back() + << "\" was removed from already full sized (" + << max_size << ") queue." << endl; + array_.pop_back(); + } + array_.push_front(val); +} + void vvp_queue_string::pop_back(void) { array_.pop_back(); @@ -537,13 +550,17 @@ void vvp_queue_vec4::get_word(unsigned adr, vvp_vector4_t&value) void vvp_queue_vec4::push_back(const vvp_vector4_t&val, unsigned max_size) { if (!max_size || (array_.size() < max_size)) array_.push_back(val); - else cerr << "Warning: value " << val << " was not added to queue." << endl; + else cerr << "Warning: value " << val + << " was not added to the end of already full sized (" + << max_size << ") queue." << endl; } void vvp_queue_vec4::push_front(const vvp_vector4_t&val, unsigned max_size) { if (max_size && (array_.size() == max_size)) { - cerr << "Warning: value " << array_.back() << " was removed from queue." << endl; + cerr << "Warning: value " << array_.back() + << " was removed from already full sized (" + << max_size << ") queue." << endl; array_.pop_back(); } array_.push_front(val); diff --git a/vvp/vvp_darray.h b/vvp/vvp_darray.h index a08df704a..584c84894 100644 --- a/vvp/vvp_darray.h +++ b/vvp/vvp_darray.h @@ -194,7 +194,7 @@ class vvp_queue_string : public vvp_queue { void set_word(unsigned adr, const std::string&value); void get_word(unsigned adr, std::string&value); void push_back(const std::string&value, unsigned max_size); - //void push_front(const std::string&value, unsigned max_size); + void push_front(const std::string&value, unsigned max_size); void pop_back(void); void pop_front(void);