From 1c90997499bb6bc470e3c49ccf51b3e3b8dbfd0b Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Mon, 13 Oct 2008 20:50:56 -0700 Subject: [PATCH] concatentations that reduce to constants need proper signed-ness It is possible, via the use of the $signed() function, for concatenation expressions to be signed. Make sure the evaluated constant had the proper sign by checking explicitly. --- eval_tree.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/eval_tree.cc b/eval_tree.cc index 0a0dec69c..be195159f 100644 --- a/eval_tree.cc +++ b/eval_tree.cc @@ -1200,6 +1200,11 @@ NetEConst* NetEConcat::eval_tree(int prune_to_width) val = verinum(val.as_string()); } + // Normally, concatenations are unsigned. However, the + // $signed() function works by marking the expression as + // signed, so we really have to check. + val.has_sign( this->has_sign() ); + NetEConst*res = new NetEConst(val); res->set_width(val.len()); return res;