Skip to content
Permalink
Browse files

Fix for github issue #6.

When creating a constant zero for implementing a unary minus operation
using a binary subtraction operator, the constant needs to be to exactly
the expression width.
  • Loading branch information
martinwhitaker committed Jan 5, 2014
1 parent 336b299 commit d1c9dd554bfd09813a27fec3ab3b3f9fe40f376a
Showing with 2 additions and 2 deletions.
  1. +2 −2 netmisc.cc
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2001-2013 Stephen Williams (steve@icarus.com)
* Copyright (c) 2001-2014 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -48,7 +48,7 @@ NetNet* sub_net_from(Design*des, NetScope*scope, long val, NetNet*sig)

} else {
verinum zero ((int64_t)val);
zero = pad_to_width(zero, sig->vector_width());
zero = cast_to_width(zero, sig->vector_width());
zero.has_sign(sig->get_signed());
NetConst*zero_obj = new NetConst(scope, scope->local_symbol(), zero);
zero_obj->set_line(*sig);

0 comments on commit d1c9dd5

Please sign in to comment.