aboutsummaryrefslogtreecommitdiffstats
path: root/frontends/ast/genrtlil.cc
diff options
context:
space:
mode:
authorZachary Snow <zach@zachjs.com>2021-03-04 15:08:16 -0500
committerZachary Snow <zach@zachjs.com>2021-03-04 15:20:52 -0500
commitc18ddbcd822410095d28c4be1c3ac3c6358622d2 (patch)
tree405d9312fc0b723f0af7b730bece916fde66fc1a /frontends/ast/genrtlil.cc
parent7d2097b00538fa366cc433b23c2c307db0e3a4be (diff)
downloadyosys-c18ddbcd822410095d28c4be1c3ac3c6358622d2.tar.gz
yosys-c18ddbcd822410095d28c4be1c3ac3c6358622d2.tar.bz2
yosys-c18ddbcd822410095d28c4be1c3ac3c6358622d2.zip
verilog: impose limit on maximum expression width
Designs with unreasonably wide expressions would previously get stuck allocating memory forever.
Diffstat (limited to 'frontends/ast/genrtlil.cc')
-rw-r--r--frontends/ast/genrtlil.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/frontends/ast/genrtlil.cc b/frontends/ast/genrtlil.cc
index d4299bf69..e0a522430 100644
--- a/frontends/ast/genrtlil.cc
+++ b/frontends/ast/genrtlil.cc
@@ -1000,6 +1000,12 @@ void AstNode::detectSignWidth(int &width_hint, bool &sign_hint, bool *found_real
if (found_real)
*found_real = false;
detectSignWidthWorker(width_hint, sign_hint, found_real);
+
+ constexpr int kWidthLimit = 1 << 24;
+ if (width_hint >= kWidthLimit)
+ log_file_error(filename, location.first_line,
+ "Expression width %d exceeds implementation limit of %d!\n",
+ width_hint, kWidthLimit);
}
static void check_unique_id(RTLIL::Module *module, RTLIL::IdString id,