Propagate sign for constant numbers inside $signed()/$unsigned().
The sign information from $signed() or $unsigned() was not being propagated correctly for constant numbers.
This commit is contained in:
parent
e97bdf8b21
commit
7bba276a79
155
set_width.cc
155
set_width.cc
|
|
@ -250,6 +250,11 @@ bool NetEConcat::set_width(unsigned w, bool)
|
|||
|
||||
bool NetEConst::set_width(unsigned w, bool last_chance)
|
||||
{
|
||||
/* Make the value signed if the NetEConst is signed.
|
||||
* This happens when $signed() is called, so this
|
||||
* sign information needs to be propagated. */
|
||||
value_.has_sign(has_sign());
|
||||
|
||||
if (w == value_.len()) {
|
||||
expr_width(w);
|
||||
return true;
|
||||
|
|
@ -438,153 +443,3 @@ bool NetEUReduce::set_width(unsigned w, bool)
|
|||
return w == 1;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* $Log: set_width.cc,v $
|
||||
* Revision 1.42 2007/01/16 05:44:15 steve
|
||||
* Major rework of array handling. Memories are replaced with the
|
||||
* more general concept of arrays. The NetMemory and NetEMemory
|
||||
* classes are removed from the ivl core program, and the IVL_LPM_RAM
|
||||
* lpm type is removed from the ivl_target API.
|
||||
*
|
||||
* Revision 1.41 2006/11/04 06:19:25 steve
|
||||
* Remove last bits of relax_width methods, and use test_width
|
||||
* to calculate the width of an r-value expression that may
|
||||
* contain unsized numbers.
|
||||
*
|
||||
* Revision 1.40 2006/10/30 05:44:49 steve
|
||||
* Expression widths with unsized literals are pseudo-infinite width.
|
||||
*
|
||||
* Revision 1.39 2006/07/31 03:50:17 steve
|
||||
* Add support for power in constant expressions.
|
||||
*
|
||||
* Revision 1.38 2006/05/02 04:29:42 steve
|
||||
* Be more stubborn about widths.
|
||||
*
|
||||
* Revision 1.37 2005/11/26 00:35:44 steve
|
||||
* More precise about r-value width of constants.
|
||||
*
|
||||
* Revision 1.36 2005/05/17 20:56:55 steve
|
||||
* Parameters cannot have their width changed.
|
||||
*
|
||||
* Revision 1.35 2005/01/24 05:28:31 steve
|
||||
* Remove the NetEBitSel and combine all bit/part select
|
||||
* behavior into the NetESelect node and IVL_EX_SELECT
|
||||
* ivl_target expression type.
|
||||
*
|
||||
* Revision 1.34 2003/08/28 04:11:19 steve
|
||||
* Spelling patch.
|
||||
*
|
||||
* Revision 1.33 2003/07/26 03:34:42 steve
|
||||
* Start handling pad of expressions in code generators.
|
||||
*
|
||||
* Revision 1.32 2003/06/21 01:21:43 steve
|
||||
* Harmless fixup of warnings.
|
||||
*
|
||||
* Revision 1.31 2003/06/18 03:55:19 steve
|
||||
* Add arithmetic shift operators.
|
||||
*
|
||||
* Revision 1.30 2003/05/20 15:05:33 steve
|
||||
* Do not try to set constants to width 0.
|
||||
*
|
||||
* Revision 1.29 2003/05/04 20:04:09 steve
|
||||
* Fix truncation of signed constant in constant addition.
|
||||
*
|
||||
* Revision 1.28 2003/04/02 04:25:26 steve
|
||||
* Fix xz extension of constants.
|
||||
*
|
||||
* Revision 1.27 2003/02/06 17:50:23 steve
|
||||
* Real constants have no defined vector width
|
||||
*
|
||||
* Revision 1.26 2003/01/26 21:02:21 steve
|
||||
* Remember to save signedness of number.
|
||||
*
|
||||
* Revision 1.25 2002/11/13 03:03:08 steve
|
||||
* Do not truncate high bits of right shift.
|
||||
*
|
||||
* Revision 1.24 2002/11/06 02:25:13 steve
|
||||
* No need to keep excess width from an
|
||||
* unsigned constant value, if it can
|
||||
* be trimmed safely.
|
||||
*
|
||||
* Revision 1.23 2002/08/12 01:35:00 steve
|
||||
* conditional ident string using autoconfig.
|
||||
*
|
||||
* Revision 1.22 2002/05/05 21:11:50 steve
|
||||
* Put off evaluation of concatenation repeat expresions
|
||||
* until after parameters are defined. This allows parms
|
||||
* to be used in repeat expresions.
|
||||
*
|
||||
* Add the builtin $signed system function.
|
||||
*
|
||||
* Revision 1.21 2002/04/27 04:49:27 steve
|
||||
* If the verinum is already right, no need to reset it.
|
||||
*
|
||||
* Revision 1.20 2001/11/19 04:26:46 steve
|
||||
* Unary reduction operators are all 1-bit results.
|
||||
*
|
||||
* Revision 1.19 2001/07/27 04:51:44 steve
|
||||
* Handle part select expressions as variants of
|
||||
* NetESignal/IVL_EX_SIGNAL objects, instead of
|
||||
* creating new and useless temporary signals.
|
||||
*
|
||||
* Revision 1.18 2001/07/25 03:10:49 steve
|
||||
* Create a config.h.in file to hold all the config
|
||||
* junk, and support gcc 3.0. (Stephan Boettcher)
|
||||
*
|
||||
* Revision 1.17 2001/02/08 01:10:30 steve
|
||||
* Remove dead code.
|
||||
*
|
||||
* Revision 1.16 2001/02/07 21:47:13 steve
|
||||
* Fix expression widths for rvalues and parameters (PR#131,132)
|
||||
*
|
||||
* Revision 1.15 2001/01/27 05:41:48 steve
|
||||
* Fix sign extension of evaluated constants. (PR#91)
|
||||
*
|
||||
* Revision 1.14 2000/06/18 03:29:52 steve
|
||||
* Handle width expansion of shift operators.
|
||||
*
|
||||
* Revision 1.13 2000/05/04 03:37:59 steve
|
||||
* Add infrastructure for system functions, move
|
||||
* $time to that structure and add $random.
|
||||
*
|
||||
* Revision 1.12 2000/04/28 18:43:23 steve
|
||||
* integer division in expressions properly get width.
|
||||
*
|
||||
* Revision 1.11 2000/04/26 03:33:32 steve
|
||||
* Do not set width too small to hold significant bits.
|
||||
*
|
||||
* Revision 1.10 2000/04/21 02:46:42 steve
|
||||
* Many Unary operators have known widths.
|
||||
*
|
||||
* Revision 1.9 2000/02/23 02:56:55 steve
|
||||
* Macintosh compilers do not support ident.
|
||||
*
|
||||
* Revision 1.8 2000/01/13 03:35:35 steve
|
||||
* Multiplication all the way to simulation.
|
||||
*
|
||||
* Revision 1.7 2000/01/01 19:56:51 steve
|
||||
* Properly expand/shrink constants in expressions.
|
||||
*
|
||||
* Revision 1.6 1999/10/05 06:19:46 steve
|
||||
* Add support for reduction NOR.
|
||||
*
|
||||
* Revision 1.5 1999/10/05 04:02:10 steve
|
||||
* Relaxed width handling for <= assignment.
|
||||
*
|
||||
* Revision 1.4 1999/09/29 00:42:51 steve
|
||||
* Allow expanding of additive operators.
|
||||
*
|
||||
* Revision 1.3 1999/09/23 03:56:57 steve
|
||||
* Support shift operators.
|
||||
*
|
||||
* Revision 1.2 1999/09/23 02:27:50 steve
|
||||
* comparison parameter width is self determined.
|
||||
*
|
||||
* Revision 1.1 1999/09/23 00:21:55 steve
|
||||
* Move set_width methods into a single file,
|
||||
* Add the NetEBLogic class for logic expressions,
|
||||
* Fix error setting with of && in if statements.
|
||||
*
|
||||
*/
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue