diff options
-rw-r--r-- | src/synth/netlists-builders.adb | 2 | ||||
-rw-r--r-- | src/synth/synth-expr.adb | 3 | ||||
-rw-r--r-- | src/vhdl/vhdl-ieee-numeric.adb | 24 | ||||
-rw-r--r-- | src/vhdl/vhdl-nodes.ads | 6 |
4 files changed, 34 insertions, 1 deletions
diff --git a/src/synth/netlists-builders.adb b/src/synth/netlists-builders.adb index 8b239573f..51b09fdfd 100644 --- a/src/synth/netlists-builders.adb +++ b/src/synth/netlists-builders.adb @@ -303,6 +303,8 @@ package body Netlists.Builders is Get_Identifier ("mul"), Id_Mul); Create_Monadic_Module (Design, Res.M_Monadic (Id_Not), Name_Not, Id_Not); + Create_Monadic_Module (Design, Res.M_Monadic (Id_Neg), + Get_Identifier ("neg"), Id_Neg); Create_Compare_Module (Design, Res.M_Compare (Id_Eq), Get_Identifier ("eq"), Id_Eq); diff --git a/src/synth/synth-expr.adb b/src/synth/synth-expr.adb index d8645eeaf..71e1469c1 100644 --- a/src/synth/synth-expr.adb +++ b/src/synth/synth-expr.adb @@ -552,6 +552,9 @@ package body Synth.Expr is return Synth_Bit_Monadic (Id_Not); when Iir_Predefined_Ieee_1164_Vector_Not => return Synth_Vec_Monadic (Id_Not); + when Iir_Predefined_Ieee_Numeric_Std_Neg_Uns + | Iir_Predefined_Ieee_Numeric_Std_Neg_Sgn => + return Synth_Vec_Monadic (Id_Neg); when others => Error_Msg_Synth (+Loc, diff --git a/src/vhdl/vhdl-ieee-numeric.adb b/src/vhdl/vhdl-ieee-numeric.adb index 0c76ff533..773a41770 100644 --- a/src/vhdl/vhdl-ieee-numeric.adb +++ b/src/vhdl/vhdl-ieee-numeric.adb @@ -34,6 +34,9 @@ package body Vhdl.Ieee.Numeric is type Binary_Pattern_Type is array (Pkg_Kind, Sign_Num_Kind, Args_Kind) of Iir_Predefined_Functions; + type Unary_Pattern_Type is array (Pkg_Kind, Sign_Num_Kind) + of Iir_Predefined_Functions; + Add_Patterns : constant Binary_Pattern_Type := (Pkg_Std => (Type_Unsigned => @@ -88,6 +91,13 @@ package body Vhdl.Ieee.Numeric is (others => (others => Iir_Predefined_None))); + Neg_Patterns : constant Unary_Pattern_Type := + (Pkg_Std => + (Type_Unsigned => Iir_Predefined_Ieee_Numeric_Std_Neg_Uns, + Type_Signed => Iir_Predefined_Ieee_Numeric_Std_Neg_Sgn), + Pkg_Bit => + (others => Iir_Predefined_None)); + Error : exception; procedure Extract_Declarations (Pkg_Decl : Iir_Package_Declaration; @@ -168,6 +178,11 @@ package body Vhdl.Ieee.Numeric is Set_Implicit_Definition (Decl, Pats (Pkg, Sign, Kind)); end Handle_Binary; + procedure Handle_Unary (Pats : Unary_Pattern_Type) is + begin + Set_Implicit_Definition (Decl, Pats (Pkg, Arg1_Sign)); + end Handle_Unary; + begin Decl := Get_Declaration_Chain (Pkg_Decl); @@ -234,6 +249,7 @@ package body Vhdl.Ieee.Numeric is Classify_Arg (Arg1, Arg1_Sign, Arg1_Kind); Arg2 := Get_Chain (Arg1); if Is_Valid (Arg2) then + -- Dyadic function. Classify_Arg (Arg2, Arg2_Sign, Arg2_Kind); case Get_Identifier (Decl) is @@ -250,6 +266,14 @@ package body Vhdl.Ieee.Numeric is when others => null; end case; + else + -- Monadic function. + case Get_Identifier (Decl) is + when Name_Op_Minus => + Handle_Unary (Neg_Patterns); + when others => + null; + end case; end if; when Iir_Kind_Non_Object_Alias_Declaration diff --git a/src/vhdl/vhdl-nodes.ads b/src/vhdl/vhdl-nodes.ads index 3f4213ca7..940b616c4 100644 --- a/src/vhdl/vhdl-nodes.ads +++ b/src/vhdl/vhdl-nodes.ads @@ -4827,7 +4827,11 @@ package Vhdl.Nodes is Iir_Predefined_Ieee_Numeric_Std_Eq_Nat_Uns, Iir_Predefined_Ieee_Numeric_Std_Eq_Sgn_Sgn, Iir_Predefined_Ieee_Numeric_Std_Eq_Sgn_Int, - Iir_Predefined_Ieee_Numeric_Std_Eq_Int_Sgn + Iir_Predefined_Ieee_Numeric_Std_Eq_Int_Sgn, + + -- Unary functions for numeric_std + Iir_Predefined_Ieee_Numeric_Std_Neg_Uns, + Iir_Predefined_Ieee_Numeric_Std_Neg_Sgn ); -- Return TRUE iff FUNC is a short-cut predefined function. |