aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-01-01 12:58:03 +0100
committerTristan Gingold <tgingold@free.fr>2020-01-01 12:58:03 +0100
commitc7a4c4e17bd3eb6d948e34965be837471a7e0360 (patch)
tree805fe6a132fcf49dc0598f34e27b52d29f7c080e
parentf7ce513f49ea7215128e90a8419fdad7cb1a6cc4 (diff)
downloadghdl-c7a4c4e17bd3eb6d948e34965be837471a7e0360.tar.gz
ghdl-c7a4c4e17bd3eb6d948e34965be837471a7e0360.tar.bz2
ghdl-c7a4c4e17bd3eb6d948e34965be837471a7e0360.zip
vhdl: evaluate std_logic matching equality. Fix #1063
-rw-r--r--src/errorout.ads5
-rw-r--r--src/vhdl/vhdl-evaluation.adb57
2 files changed, 54 insertions, 8 deletions
diff --git a/src/errorout.ads b/src/errorout.ads
index e67cba0c9..0ec341514 100644
--- a/src/errorout.ads
+++ b/src/errorout.ads
@@ -105,6 +105,9 @@ package Errorout is
-- Violation of pure rules.
Warnid_Pure,
+ -- Assertion during analysis.
+ Warnid_Analyze_Assert,
+
-- Violation of staticness rules
Warnid_Static,
@@ -295,7 +298,7 @@ private
Default_Warnings : constant Warnings_Setting :=
(Warnid_Library | Warnid_Binding | Warnid_Port | Warnid_Shared
| Warnid_Runtime_Error | Warnid_Pure | Warnid_Specs | Warnid_Hide
- | Warnid_Pragma
+ | Warnid_Pragma | Warnid_Analyze_Assert
| Msgid_Warning => (Enabled => True, Error => False),
others => (Enabled => False, Error => False));
diff --git a/src/vhdl/vhdl-evaluation.adb b/src/vhdl/vhdl-evaluation.adb
index 5a4f2dde0..b20c64b52 100644
--- a/src/vhdl/vhdl-evaluation.adb
+++ b/src/vhdl/vhdl-evaluation.adb
@@ -15,18 +15,21 @@
-- along with GHDL; see the file COPYING. If not, write to the Free
-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-- 02111-1307, USA.
+
with Ada.Unchecked_Deallocation;
+with Ada.Characters.Handling;
with Interfaces;
-with Vhdl.Scanner;
-with Errorout; use Errorout;
+
with Name_Table; use Name_Table;
with Str_Table;
+with Flags; use Flags;
+with Std_Names;
+with Errorout; use Errorout;
+with Vhdl.Scanner;
with Vhdl.Errors; use Vhdl.Errors;
with Vhdl.Utils; use Vhdl.Utils;
with Vhdl.Std_Package; use Vhdl.Std_Package;
-with Flags; use Flags;
-with Std_Names;
-with Ada.Characters.Handling;
+with Vhdl.Ieee.Std_Logic_1164;
with Grt.Fcvt;
package body Vhdl.Evaluation is
@@ -1372,6 +1375,42 @@ package body Vhdl.Evaluation is
end if;
end Eval_Array_Compare;
+ function Eval_Logic_Match_Equality (L, R : Iir_Int32; Loc : Iir)
+ return Iir_Index32
+ is
+ use Vhdl.Ieee.Std_Logic_1164;
+ Lb, Rb : Boolean;
+ begin
+ if L = Std_Logic_D_Pos or R = Std_Logic_D_Pos then
+ Warning_Msg_Sem
+ (Warnid_Analyze_Assert, +Loc,
+ "STD_LOGIC_1164: '-' operand for matching ordering operator");
+ return Std_Logic_1_Pos;
+ end if;
+ if L = Std_Logic_U_Pos or R = Std_Logic_U_Pos then
+ return Std_Logic_U_Pos;
+ end if;
+ if L = Std_Logic_X_Pos
+ or L = Std_Logic_Z_Pos
+ or L = Std_Logic_W_Pos
+ then
+ return Std_Logic_X_Pos;
+ end if;
+ if R = Std_Logic_X_Pos
+ or R = Std_Logic_Z_Pos
+ or R = Std_Logic_W_Pos
+ then
+ return Std_Logic_X_Pos;
+ end if;
+ Lb := L = Std_Logic_1_Pos or L = Std_Logic_H_Pos;
+ Rb := R = Std_Logic_1_Pos or R = Std_Logic_H_Pos;
+ if Lb = Rb then
+ return Std_Logic_1_Pos;
+ else
+ return Std_Logic_0_Pos;
+ end if;
+ end Eval_Logic_Match_Equality;
+
-- ORIG is either a dyadic operator or a function call.
function Eval_Dyadic_Operator (Orig : Iir; Imp : Iir; Left, Right : Iir)
return Iir
@@ -1752,8 +1791,12 @@ package body Vhdl.Evaluation is
| Iir_Predefined_Vector_Maximum =>
raise Internal_Error;
- when Iir_Predefined_Std_Ulogic_Match_Equality
- | Iir_Predefined_Std_Ulogic_Match_Inequality
+ when Iir_Predefined_Std_Ulogic_Match_Equality =>
+ return Build_Enumeration
+ (Eval_Logic_Match_Equality (Get_Enum_Pos (Left),
+ Get_Enum_Pos (Right), Orig),
+ Orig);
+ when Iir_Predefined_Std_Ulogic_Match_Inequality
| Iir_Predefined_Std_Ulogic_Match_Less
| Iir_Predefined_Std_Ulogic_Match_Less_Equal
| Iir_Predefined_Std_Ulogic_Match_Greater