From 1938ee7b5d0c65c46776ab3574cbb7716dbae2ea Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Sun, 6 Oct 2019 15:41:15 +0200 Subject: synth: handle /= with non-matching length. For #968 --- src/synth/synth-oper.adb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/synth') diff --git a/src/synth/synth-oper.adb b/src/synth/synth-oper.adb index caa5b3742..fbd345be0 100644 --- a/src/synth/synth-oper.adb +++ b/src/synth/synth-oper.adb @@ -412,7 +412,6 @@ package body Synth.Oper is return Synth_Compare (Id_Ult); when Iir_Predefined_Array_Equality => - -- TODO: check size, handle non-vector. if Is_Const (Left) and then Is_Const (Right) then return Create_Value_Discrete (Boolean'Pos (Is_Equal (Left, Right)), Boolean_Type); @@ -425,12 +424,17 @@ package body Synth.Oper is end if; return Synth_Compare (Id_Eq); when Iir_Predefined_Array_Inequality => - -- TODO: check size, handle non-vector. - if Is_Vector_Type (Left_Type) then - return Synth_Compare (Id_Ne); - else - raise Internal_Error; + if Is_Const (Left) and then Is_Const (Right) then + return Create_Value_Discrete + (Boolean'Pos (not Is_Equal (Left, Right)), Boolean_Type); end if; + if not Is_Matching_Bounds (Left.Typ, Right.Typ) then + Warning_Msg_Synth + (+Expr, + "length of '/=' operands doesn't match, result is true"); + return Create_Value_Discrete (1, Boolean_Type); + end if; + return Synth_Compare (Id_Ne); when Iir_Predefined_Array_Greater => -- TODO: check size, non-vector. -- TODO: that's certainly not the correct operator. -- cgit v1.2.3