From: Gabe Black Date: Fri, 31 Aug 2018 00:41:05 +0000 (-0700) Subject: systemc: Implement sc_fifo::dump and improve sc_fifo::print. X-Git-Tag: v19.0.0.0~1676 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3c40f3c0c420dc4215c97a646359f7cda5de829e;p=gem5.git systemc: Implement sc_fifo::dump and improve sc_fifo::print. The print function is supposed to print both pending and committed writes, apparently. Accellera's implementation of sc_fifo uses a ring buffer to store the entries and manages a head and tail pointer to keep track of what's full, etc. Their dump function prints that whole buffer using the indexes. When not using a ring buffer, there's no easy way to determine what those indexes should be. Fortunately the test that uses dump never moves away from the base of the ring buffer, so I can get the same effect (which also makes sense on its own) by printing the index into the fifo instead. Change-Id: I50fe049461f6a5e8a55b54eeb2f134d20f0812c6 Reviewed-on: https://gem5-review.googlesource.com/c/12455 Reviewed-by: Gabe Black Maintainer: Gabe Black --- diff --git a/src/systemc/ext/channel/sc_fifo.hh b/src/systemc/ext/channel/sc_fifo.hh index 4fe704613..7bf9efce0 100644 --- a/src/systemc/ext/channel/sc_fifo.hh +++ b/src/systemc/ext/channel/sc_fifo.hh @@ -142,15 +142,28 @@ class sc_fifo : public sc_fifo_in_if, virtual void print(std::ostream &os=std::cout) const { + for (typename ::std::list::iterator pos = _pending.begin(); + pos != _pending.end(); pos++) { + os << *pos << ::std::endl; + } for (typename ::std::list::iterator pos = _entries.begin(); pos != _entries.end(); pos++) { os << *pos << ::std::endl; } } virtual void - dump(std::ostream & =std::cout) const + dump(std::ostream &os=std::cout) const { - sc_channel_warn_unimpl(__PRETTY_FUNCTION__); + os << "name = " << name() << std::endl; + int idx = 0; + for (typename ::std::list::iterator pos = _pending.begin(); + pos != _pending.end(); pos++) { + os << "value[" << idx++ << "] = " << *pos << ::std::endl; + } + for (typename ::std::list::iterator pos = _entries.begin(); + pos != _entries.end(); pos++) { + os << "value[" << idx++ << "] = " << *pos << ::std::endl; + } } virtual const char *kind() const { return "sc_fifo"; } @@ -187,9 +200,9 @@ class sc_fifo : public sc_fifo_in_if, template inline std::ostream & -operator << (std::ostream &os, const sc_fifo &) +operator << (std::ostream &os, const sc_fifo &f) { - sc_channel_warn_unimpl(__PRETTY_FUNCTION__); + f.print(os); return os; }