diff options
-rw-r--r-- | src/grt/grt-std_logic_1164.adb | 50 |
1 files changed, 32 insertions, 18 deletions
diff --git a/src/grt/grt-std_logic_1164.adb b/src/grt/grt-std_logic_1164.adb index 5be308b..f34c77f 100644 --- a/src/grt/grt-std_logic_1164.adb +++ b/src/grt/grt-std_logic_1164.adb @@ -43,15 +43,13 @@ package body Grt.Std_Logic_1164 is Line => 58, Col => 3); - procedure Assert_Not_Match (V : Std_Ulogic) + procedure Assert_Not_Match is use Grt.Lib; begin - if V = '-' then - Ghdl_Ieee_Assert_Failed - (To_Std_String_Ptr (Assert_DC_Msg_Str'Address), Error_Severity, - To_Ghdl_Location_Ptr (Loc'Address)); - end if; + Ghdl_Ieee_Assert_Failed + (To_Std_String_Ptr (Assert_DC_Msg_Str'Address), Error_Severity, + To_Ghdl_Location_Ptr (Loc'Address)); end Assert_Not_Match; function Ghdl_Std_Ulogic_Match_Eq (L, R : Ghdl_E8) return Ghdl_E8 @@ -59,8 +57,9 @@ package body Grt.Std_Logic_1164 is Left : constant Std_Ulogic := Std_Ulogic'Val (L); Right : constant Std_Ulogic := Std_Ulogic'Val (R); begin - Assert_Not_Match (Left); - Assert_Not_Match (Right); + if Left = '-' or Right = '-' then + Assert_Not_Match; + end if; return Std_Ulogic'Pos (Match_Eq_Table (Left, Right)); end Ghdl_Std_Ulogic_Match_Eq; @@ -69,8 +68,9 @@ package body Grt.Std_Logic_1164 is Left : constant Std_Ulogic := Std_Ulogic'Val (L); Right : constant Std_Ulogic := Std_Ulogic'Val (R); begin - Assert_Not_Match (Left); - Assert_Not_Match (Right); + if Left = '-' or Right = '-' then + Assert_Not_Match; + end if; return Std_Ulogic'Pos (Not_Table (Match_Eq_Table (Left, Right))); end Ghdl_Std_Ulogic_Match_Ne; @@ -79,8 +79,9 @@ package body Grt.Std_Logic_1164 is Left : constant Std_Ulogic := Std_Ulogic'Val (L); Right : constant Std_Ulogic := Std_Ulogic'Val (R); begin - Assert_Not_Match (Left); - Assert_Not_Match (Right); + if Left = '-' or Right = '-' then + Assert_Not_Match; + end if; return Std_Ulogic'Pos (Match_Lt_Table (Left, Right)); end Ghdl_Std_Ulogic_Match_Lt; @@ -89,8 +90,9 @@ package body Grt.Std_Logic_1164 is Left : constant Std_Ulogic := Std_Ulogic'Val (L); Right : constant Std_Ulogic := Std_Ulogic'Val (R); begin - Assert_Not_Match (Left); - Assert_Not_Match (Right); + if Left = '-' or Right = '-' then + Assert_Not_Match; + end if; return Std_Ulogic'Pos (Or_Table (Match_Lt_Table (Left, Right), Match_Eq_Table (Left, Right))); end Ghdl_Std_Ulogic_Match_Le; @@ -106,7 +108,6 @@ package body Grt.Std_Logic_1164 is (Base => To_Std_String_Basep (Assert_Arr_Msg'Address), Bounds => To_Std_String_Boundp (Assert_Arr_Msg_Bound'Address)); - function Ghdl_Std_Ulogic_Array_Match_Eq (L : Ghdl_Ptr; L_Len : Ghdl_Index_Type; R : Ghdl_Ptr; @@ -119,16 +120,29 @@ package body Grt.Std_Logic_1164 is R_Arr : constant Ghdl_E8_Array_Base_Ptr := To_Ghdl_E8_Array_Base_Ptr (R); Res : Std_Ulogic := '1'; + Has_Match_Err : Boolean; begin if L_Len /= R_Len then Ghdl_Ieee_Assert_Failed (To_Std_String_Ptr (Assert_Arr_Msg_Str'Address), Error_Severity, To_Ghdl_Location_Ptr (Loc'Address)); + return Std_Ulogic'Pos ('0'); end if; + + Has_Match_Err := False; for I in 1 .. L_Len loop - Res := And_Table - (Res, Std_Ulogic'Val (Ghdl_Std_Ulogic_Match_Eq (L_Arr (I - 1), - R_Arr (I - 1)))); + declare + Le : constant Std_Ulogic := Std_Ulogic'Val (L_Arr (I - 1)); + Re : constant Std_Ulogic := Std_Ulogic'Val (R_Arr (I - 1)); + begin + if Le = '-' or Re = '-' then + if not Has_Match_Err then + Assert_Not_Match; + Has_Match_Err := True; + end if; + end if; + Res := And_Table (Res, Match_Eq_Table (Le, Re)); + end; end loop; return Std_Ulogic'Pos (Res); end Ghdl_Std_Ulogic_Array_Match_Eq; |