From 6206a3af304d25db1f8e057b9c88e0ad2d15dac4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Povi=C5=A1er?= Date: Tue, 12 Dec 2023 09:51:17 +0100 Subject: [PATCH] cxxrtl: Handle case of `Bits < 4` in formatting of values --- backends/cxxrtl/runtime/cxxrtl/cxxrtl.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/backends/cxxrtl/runtime/cxxrtl/cxxrtl.h b/backends/cxxrtl/runtime/cxxrtl/cxxrtl.h index a1d32fa60..04ed48eb3 100644 --- a/backends/cxxrtl/runtime/cxxrtl/cxxrtl.h +++ b/backends/cxxrtl/runtime/cxxrtl/cxxrtl.h @@ -796,7 +796,10 @@ std::ostream &operator<<(std::ostream &os, const value_formatted &vf) buf += '0'; while (!val.is_zero()) { value quotient, remainder; - std::tie(quotient, remainder) = val.udivmod(value{10u}); + if (Bits >= 4) + std::tie(quotient, remainder) = val.udivmod(value{10u}); + else + std::tie(quotient, remainder) = std::make_pair(value{0u}, val); buf += '0' + remainder.template trunc<(Bits > 4 ? 4 : Bits)>().val().template get(); val = quotient; }