diff options
author | Tristan Gingold <tgingold@free.fr> | 2019-11-30 10:24:58 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2019-11-30 10:24:58 +0100 |
commit | 5b2d875da8d2c71f1dc5ab88c3fb4d6193afdb9f (patch) | |
tree | 37a23db836b33db4d9d3fdecee55754a6ed82734 /src/synth/synth-oper.adb | |
parent | 3bd9a185da8178e878e8034e04aab2238bab50ff (diff) | |
download | ghdl-5b2d875da8d2c71f1dc5ab88c3fb4d6193afdb9f.tar.gz ghdl-5b2d875da8d2c71f1dc5ab88c3fb4d6193afdb9f.tar.bz2 ghdl-5b2d875da8d2c71f1dc5ab88c3fb4d6193afdb9f.zip |
synth: add synth_static_monadic_predefined
Diffstat (limited to 'src/synth/synth-oper.adb')
-rw-r--r-- | src/synth/synth-oper.adb | 46 |
1 files changed, 14 insertions, 32 deletions
diff --git a/src/synth/synth-oper.adb b/src/synth/synth-oper.adb index 57b4a294a..dd02da330 100644 --- a/src/synth/synth-oper.adb +++ b/src/synth/synth-oper.adb @@ -791,6 +791,11 @@ package body Synth.Oper is Operand := Synth_Subtype_Conversion (Operand, Oper_Typ, False, Loc); Strip_Const (Operand); + if Is_Static_Val (Operand) then + return Synth_Static_Monadic_Predefined + (Syn_Inst, Imp, Operand, Loc); + end if; + case Def is when Iir_Predefined_Error => return null; @@ -798,11 +803,7 @@ package body Synth.Oper is return Synth_Bit_Monadic (Id_Not); when Iir_Predefined_Boolean_Not | Iir_Predefined_Bit_Not => - if Is_Static (Operand) then - return Create_Value_Discrete (1 - Operand.Scal, Oper_Typ); - else - return Synth_Bit_Monadic (Id_Not); - end if; + return Synth_Bit_Monadic (Id_Not); when Iir_Predefined_Ieee_1164_Vector_Not | Iir_Predefined_Ieee_Numeric_Std_Not_Uns | Iir_Predefined_Ieee_Numeric_Std_Not_Sgn => @@ -815,34 +816,15 @@ package body Synth.Oper is when Iir_Predefined_Ieee_1164_Vector_Or_Reduce => return Synth_Vec_Reduce_Monadic(Id_Red_Or); when Iir_Predefined_Ieee_1164_Condition_Operator => - if Operand.Typ.Kind = Type_Logic - and then Operand.Kind = Value_Discrete - then - -- Constant std_logic: need to convert. - declare - Val : Uns32; - Zx : Uns32; - begin - From_Std_Logic (Operand.Scal, Val, Zx); - return Create_Value_Discrete - (Boolean'Pos (Val = 1 and Zx = 0), Boolean_Type); - end; - else - return Operand; - end if; + return Operand; when Iir_Predefined_Integer_Negation => - if Is_Static (Operand) then - return Create_Value_Discrete (-Operand.Scal, Operand.Typ); - else - declare - N : Net; - begin - N := Build_Monadic - (Build_Context, Id_Neg, Get_Net (Operand)); - Set_Location (N, Loc); - return Create_Value_Net (N, Operand.Typ); - end; - end if; + declare + N : Net; + begin + N := Build_Monadic (Build_Context, Id_Neg, Get_Net (Operand)); + Set_Location (N, Loc); + return Create_Value_Net (N, Operand.Typ); + end; when others => Error_Msg_Synth (+Loc, |