aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwhitequark <whitequark@whitequark.org>2020-04-24 05:50:10 +0000
committerwhitequark <whitequark@whitequark.org>2020-04-24 05:50:36 +0000
commitf88378ae616b331d43ccc99797e239785bab7644 (patch)
treebecc91c96ea8aa58b24f3cc156a5d52b939109b2
parent3738391bddc60a4c228ed732ec86df893cf4ed11 (diff)
downloadyosys-f88378ae616b331d43ccc99797e239785bab7644.tar.gz
yosys-f88378ae616b331d43ccc99797e239785bab7644.tar.bz2
yosys-f88378ae616b331d43ccc99797e239785bab7644.zip
cxxrtl: improve printing of narrow memories.
-rw-r--r--backends/cxxrtl/cxxrtl.cc7
1 files changed, 4 insertions, 3 deletions
diff --git a/backends/cxxrtl/cxxrtl.cc b/backends/cxxrtl/cxxrtl.cc
index 89e58622c..74e2a2891 100644
--- a/backends/cxxrtl/cxxrtl.cc
+++ b/backends/cxxrtl/cxxrtl.cc
@@ -726,12 +726,13 @@ struct CxxrtlWorker {
void dump_const_init(const RTLIL::Const &data, int width, int offset = 0, bool fixed_width = false)
{
+ const int CHUNK_SIZE = 32;
f << "{";
while (width > 0) {
- const int CHUNK_SIZE = 32;
- uint32_t chunk = data.extract(offset, width > CHUNK_SIZE ? CHUNK_SIZE : width).as_int();
+ int chunk_width = min(width, CHUNK_SIZE);
+ uint32_t chunk = data.extract(offset, chunk_width).as_int();
if (fixed_width)
- f << stringf("0x%08xu", chunk);
+ f << stringf("0x%.*xu", chunk_width / 4, chunk);
else
f << stringf("%#xu", chunk);
if (width > CHUNK_SIZE)