cxxrtl: Round up constant width
authorDavid Shah <dave@ds0.me>
Sat, 25 Apr 2020 09:42:21 +0000 (10:42 +0100)
committerDavid Shah <dave@ds0.me>
Sat, 25 Apr 2020 09:42:21 +0000 (10:42 +0100)
Signed-off-by: David Shah <dave@ds0.me>
backends/cxxrtl/cxxrtl.cc

index e5351a387459dc8103db01c623913f3c13aa81b5..e7711962f20dc1c835eb9e6d2791c1d4c9a18eb6 100644 (file)
@@ -732,7 +732,7 @@ struct CxxrtlWorker {
                        int chunk_width = min(width, CHUNK_SIZE);
                        uint32_t chunk = data.extract(offset, chunk_width).as_int();
                        if (fixed_width)
-                               f << stringf("0x%.*xu", chunk_width / 4, chunk);
+                               f << stringf("0x%.*xu", (3 + chunk_width) / 4, chunk);
                        else
                                f << stringf("%#xu", chunk);
                        if (width > CHUNK_SIZE)