From a2a70219146db0358f0891e65c58ebd85e0de93c Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Mon, 6 May 2019 18:55:38 -0400 Subject: [PATCH] Reorder VCD codes for better viewer packing. --- include/verilated_vcd_c.h | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/include/verilated_vcd_c.h b/include/verilated_vcd_c.h index 11846e432..eb0177a8a 100644 --- a/include/verilated_vcd_c.h +++ b/include/verilated_vcd_c.h @@ -134,17 +134,24 @@ private: // cppcheck-suppress functionConst void dumpDone(); inline void printCode(vluint32_t code) { - if (code>=(94*94*94)) *m_writep++ = static_cast((code/94/94/94)%94+33); - if (code>=(94*94)) *m_writep++ = static_cast((code/94/94)%94+33); - if (code>=(94)) *m_writep++ = static_cast((code/94)%94+33); - *m_writep++ = static_cast((code)%94+33); + *m_writep++ = static_cast('!' + code % 94); + code /= 94; + while (code) { + code--; + *m_writep++ = static_cast('!' + code % 94); + code /= 94; + } } static std::string stringCode(vluint32_t code) VL_PURE { std::string out; - if (code>=(94*94*94)) out += static_cast((code/94/94/94)%94+33); - if (code>=(94*94)) out += static_cast((code/94/94)%94+33); - if (code>=(94)) out += static_cast((code/94)%94+33); - return out + static_cast((code)%94+33); + out += static_cast('!' + code % 94); + code /= 94; + while (code) { + code--; + out += static_cast('!' + code % 94); + code /= 94; + } + return out; } // CONSTRUCTORS