aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl/vhdl-ieee-std_logic_arith.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-04-11 07:30:58 +0200
committerTristan Gingold <tgingold@free.fr>2020-04-11 07:30:58 +0200
commit2ef80b56c5eda04e0ef6a0276321f72ff437868e (patch)
treea3b4eaba7828d88351b4acdefd98cafaa19b19dc /src/vhdl/vhdl-ieee-std_logic_arith.adb
parent64288b21f18de4b833cfcb15070024fb664faadb (diff)
downloadghdl-2ef80b56c5eda04e0ef6a0276321f72ff437868e.tar.gz
ghdl-2ef80b56c5eda04e0ef6a0276321f72ff437868e.tar.bz2
ghdl-2ef80b56c5eda04e0ef6a0276321f72ff437868e.zip
vhdl: recognize comparaison of std_logic_arith.
Diffstat (limited to 'src/vhdl/vhdl-ieee-std_logic_arith.adb')
-rw-r--r--src/vhdl/vhdl-ieee-std_logic_arith.adb107
1 files changed, 107 insertions, 0 deletions
diff --git a/src/vhdl/vhdl-ieee-std_logic_arith.adb b/src/vhdl/vhdl-ieee-std_logic_arith.adb
index a4183d9b4..4c2b517ec 100644
--- a/src/vhdl/vhdl-ieee-std_logic_arith.adb
+++ b/src/vhdl/vhdl-ieee-std_logic_arith.adb
@@ -39,6 +39,11 @@ package body Vhdl.Ieee.Std_Logic_Arith is
array (Res_Arg_Kind, Conv_Arg_Kind, Conv_Arg_Kind)
of Iir_Predefined_Functions;
+ subtype Cmp_Arg_Kind is Arg_Kind range Type_Signed .. Type_Int;
+
+ type Cmp_Pattern_Type is array (Cmp_Arg_Kind, Cmp_Arg_Kind)
+ of Iir_Predefined_Functions;
+
Conv_Uns_Patterns : constant Conv_Pattern_Type :=
(Iir_Predefined_Ieee_Std_Logic_Arith_Conv_Unsigned_Sgn,
Iir_Predefined_Ieee_Std_Logic_Arith_Conv_Unsigned_Uns,
@@ -168,6 +173,90 @@ package body Vhdl.Ieee.Std_Logic_Arith is
others =>
(others => Iir_Predefined_None)));
+ Lt_Patterns : constant Cmp_Pattern_Type :=
+ (Type_Unsigned =>
+ (Type_Unsigned => Iir_Predefined_Ieee_Std_Logic_Arith_Lt_Uns_Uns,
+ Type_Signed => Iir_Predefined_Ieee_Std_Logic_Arith_Lt_Uns_Sgn,
+ Type_Int => Iir_Predefined_Ieee_Std_Logic_Arith_Lt_Uns_Int),
+ Type_Signed =>
+ (Type_Unsigned => Iir_Predefined_Ieee_Std_Logic_Arith_Lt_Sgn_Uns,
+ Type_Signed => Iir_Predefined_Ieee_Std_Logic_Arith_Lt_Sgn_Sgn,
+ Type_Int => Iir_Predefined_Ieee_Std_Logic_Arith_Lt_Sgn_Int),
+ Type_Int =>
+ (Type_Unsigned => Iir_Predefined_Ieee_Std_Logic_Arith_Lt_Int_Uns,
+ Type_Signed => Iir_Predefined_Ieee_Std_Logic_Arith_Lt_Int_Sgn,
+ others => Iir_Predefined_None));
+
+ Le_Patterns : constant Cmp_Pattern_Type :=
+ (Type_Unsigned =>
+ (Type_Unsigned => Iir_Predefined_Ieee_Std_Logic_Arith_Le_Uns_Uns,
+ Type_Signed => Iir_Predefined_Ieee_Std_Logic_Arith_Le_Uns_Sgn,
+ Type_Int => Iir_Predefined_Ieee_Std_Logic_Arith_Le_Uns_Int),
+ Type_Signed =>
+ (Type_Unsigned => Iir_Predefined_Ieee_Std_Logic_Arith_Le_Sgn_Uns,
+ Type_Signed => Iir_Predefined_Ieee_Std_Logic_Arith_Le_Sgn_Sgn,
+ Type_Int => Iir_Predefined_Ieee_Std_Logic_Arith_Le_Sgn_Int),
+ Type_Int =>
+ (Type_Unsigned => Iir_Predefined_Ieee_Std_Logic_Arith_Le_Int_Uns,
+ Type_Signed => Iir_Predefined_Ieee_Std_Logic_Arith_Le_Int_Sgn,
+ others => Iir_Predefined_None));
+
+ Gt_Patterns : constant Cmp_Pattern_Type :=
+ (Type_Unsigned =>
+ (Type_Unsigned => Iir_Predefined_Ieee_Std_Logic_Arith_Gt_Uns_Uns,
+ Type_Signed => Iir_Predefined_Ieee_Std_Logic_Arith_Gt_Uns_Sgn,
+ Type_Int => Iir_Predefined_Ieee_Std_Logic_Arith_Gt_Uns_Int),
+ Type_Signed =>
+ (Type_Unsigned => Iir_Predefined_Ieee_Std_Logic_Arith_Gt_Sgn_Uns,
+ Type_Signed => Iir_Predefined_Ieee_Std_Logic_Arith_Gt_Sgn_Sgn,
+ Type_Int => Iir_Predefined_Ieee_Std_Logic_Arith_Gt_Sgn_Int),
+ Type_Int =>
+ (Type_Unsigned => Iir_Predefined_Ieee_Std_Logic_Arith_Gt_Int_Uns,
+ Type_Signed => Iir_Predefined_Ieee_Std_Logic_Arith_Gt_Int_Sgn,
+ others => Iir_Predefined_None));
+
+ Ge_Patterns : constant Cmp_Pattern_Type :=
+ (Type_Unsigned =>
+ (Type_Unsigned => Iir_Predefined_Ieee_Std_Logic_Arith_Ge_Uns_Uns,
+ Type_Signed => Iir_Predefined_Ieee_Std_Logic_Arith_Ge_Uns_Sgn,
+ Type_Int => Iir_Predefined_Ieee_Std_Logic_Arith_Ge_Uns_Int),
+ Type_Signed =>
+ (Type_Unsigned => Iir_Predefined_Ieee_Std_Logic_Arith_Ge_Sgn_Uns,
+ Type_Signed => Iir_Predefined_Ieee_Std_Logic_Arith_Ge_Sgn_Sgn,
+ Type_Int => Iir_Predefined_Ieee_Std_Logic_Arith_Ge_Sgn_Int),
+ Type_Int =>
+ (Type_Unsigned => Iir_Predefined_Ieee_Std_Logic_Arith_Ge_Int_Uns,
+ Type_Signed => Iir_Predefined_Ieee_Std_Logic_Arith_Ge_Int_Sgn,
+ others => Iir_Predefined_None));
+
+ Eq_Patterns : constant Cmp_Pattern_Type :=
+ (Type_Unsigned =>
+ (Type_Unsigned => Iir_Predefined_Ieee_Std_Logic_Arith_Eq_Uns_Uns,
+ Type_Signed => Iir_Predefined_Ieee_Std_Logic_Arith_Eq_Uns_Sgn,
+ Type_Int => Iir_Predefined_Ieee_Std_Logic_Arith_Eq_Uns_Int),
+ Type_Signed =>
+ (Type_Unsigned => Iir_Predefined_Ieee_Std_Logic_Arith_Eq_Sgn_Uns,
+ Type_Signed => Iir_Predefined_Ieee_Std_Logic_Arith_Eq_Sgn_Sgn,
+ Type_Int => Iir_Predefined_Ieee_Std_Logic_Arith_Eq_Sgn_Int),
+ Type_Int =>
+ (Type_Unsigned => Iir_Predefined_Ieee_Std_Logic_Arith_Eq_Int_Uns,
+ Type_Signed => Iir_Predefined_Ieee_Std_Logic_Arith_Eq_Int_Sgn,
+ others => Iir_Predefined_None));
+
+ Ne_Patterns : constant Cmp_Pattern_Type :=
+ (Type_Unsigned =>
+ (Type_Unsigned => Iir_Predefined_Ieee_Std_Logic_Arith_Ne_Uns_Uns,
+ Type_Signed => Iir_Predefined_Ieee_Std_Logic_Arith_Ne_Uns_Sgn,
+ Type_Int => Iir_Predefined_Ieee_Std_Logic_Arith_Ne_Uns_Int),
+ Type_Signed =>
+ (Type_Unsigned => Iir_Predefined_Ieee_Std_Logic_Arith_Ne_Sgn_Uns,
+ Type_Signed => Iir_Predefined_Ieee_Std_Logic_Arith_Ne_Sgn_Sgn,
+ Type_Int => Iir_Predefined_Ieee_Std_Logic_Arith_Ne_Sgn_Int),
+ Type_Int =>
+ (Type_Unsigned => Iir_Predefined_Ieee_Std_Logic_Arith_Ne_Int_Uns,
+ Type_Signed => Iir_Predefined_Ieee_Std_Logic_Arith_Ne_Int_Sgn,
+ others => Iir_Predefined_None));
+
Error : exception;
procedure Extract_Declarations (Pkg : Iir_Package_Declaration)
@@ -213,6 +302,12 @@ package body Vhdl.Ieee.Std_Logic_Arith is
return Pats (Res_Kind, Arg1_Kind, Arg2_Kind);
end Handle_Bin;
+ function Handle_Cmp (Pats : Cmp_Pattern_Type)
+ return Iir_Predefined_Functions is
+ begin
+ return Pats (Arg1_Kind, Arg2_Kind);
+ end Handle_Cmp;
+
Def : Iir_Predefined_Functions;
begin
Decl := Get_Declaration_Chain (Pkg);
@@ -290,6 +385,18 @@ package body Vhdl.Ieee.Std_Logic_Arith is
Def := Handle_Conv (Conv_Uns_Patterns);
when Name_Conv_Std_Logic_Vector =>
Def := Handle_Conv (Conv_Vec_Patterns);
+ when Name_Op_Less =>
+ Def := Handle_Cmp (Lt_Patterns);
+ when Name_Op_Less_Equal =>
+ Def := Handle_Cmp (Le_Patterns);
+ when Name_Op_Greater =>
+ Def := Handle_Cmp (Gt_Patterns);
+ when Name_Op_Greater_Equal =>
+ Def := Handle_Cmp (Ge_Patterns);
+ when Name_Op_Equality =>
+ Def := Handle_Cmp (Eq_Patterns);
+ when Name_Op_Inequality =>
+ Def := Handle_Cmp (Ne_Patterns);
when others =>
null;
end case;