Skip to content

Commit

Permalink
std_logic_1164: fix number of warnings for matching equality.
Browse files Browse the repository at this point in the history
Fix issue 14.
  • Loading branch information
gingold-adacore authored and tgingold committed Jan 7, 2016
1 parent 45f0ebb commit 12ecf52
Showing 1 changed file with 32 additions and 18 deletions.
50 changes: 32 additions & 18 deletions src/grt/grt-std_logic_1164.adb
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,23 @@ 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
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;

Expand All @@ -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;

Expand All @@ -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;

Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 12ecf52

Please sign in to comment.