diff options
author | Tristan Gingold <tgingold@free.fr> | 2019-09-25 20:47:07 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2019-09-25 20:47:07 +0200 |
commit | ecd791d210198c82a88ee238d43ca02b2a36a1c1 (patch) | |
tree | b22342e56b7df7eae06edbdf6acb7cd1be846f44 | |
parent | 6e9336d11dfc4f53dba234e1f02a2b0172461e0c (diff) | |
download | ghdl-ecd791d210198c82a88ee238d43ca02b2a36a1c1.tar.gz ghdl-ecd791d210198c82a88ee238d43ca02b2a36a1c1.tar.bz2 ghdl-ecd791d210198c82a88ee238d43ca02b2a36a1c1.zip |
synth: handle array equality (for constances).
-rw-r--r-- | src/synth/synth-expr.adb | 9 | ||||
-rw-r--r-- | src/synth/synth-oper.adb | 4 | ||||
-rw-r--r-- | src/synth/synth-values.adb | 10 |
3 files changed, 22 insertions, 1 deletions
diff --git a/src/synth/synth-expr.adb b/src/synth/synth-expr.adb index 451a04951..5ee1ad90c 100644 --- a/src/synth/synth-expr.adb +++ b/src/synth/synth-expr.adb @@ -1417,6 +1417,7 @@ package body Synth.Expr is Str_Type : constant Node := Get_Type (Str); El_Type : Type_Acc; Bounds : Bound_Type; + Bnds : Bound_Array_Acc; Res_Type : Type_Acc; Res : Value_Acc; Arr : Value_Array_Acc; @@ -1424,7 +1425,13 @@ package body Synth.Expr is begin Bounds := Synth_Array_Bounds (Syn_Inst, Str_Type, 0); El_Type := Get_Value_Type (Syn_Inst, Get_Element_Subtype (Str_Type)); - Res_Type := Create_Vector_Type (Bounds, El_Type); + if El_Type.Kind = Type_Bit then + Res_Type := Create_Vector_Type (Bounds, El_Type); + else + Bnds := Create_Bound_Array (1); + Bnds.D (1) := Bounds; + Res_Type := Create_Array_Type (Bnds, El_Type); + end if; Arr := Create_Value_Array (Iir_Index32 (Bounds.Len)); for I in Arr.V'Range loop diff --git a/src/synth/synth-oper.adb b/src/synth/synth-oper.adb index d0b7a7f5d..ea72933ef 100644 --- a/src/synth/synth-oper.adb +++ b/src/synth/synth-oper.adb @@ -418,6 +418,10 @@ package body Synth.Oper is 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); + end if; if Is_Vector_Type (Left_Type) then return Synth_Compare (Id_Eq); else diff --git a/src/synth/synth-values.adb b/src/synth/synth-values.adb index 4cffaeedf..ed59d6af5 100644 --- a/src/synth/synth-values.adb +++ b/src/synth/synth-values.adb @@ -112,6 +112,16 @@ package body Synth.Values is case L.Kind is when Value_Discrete => return L.Scal = R.Scal; + when Value_Const_Array => + if L.Arr.Len /= R.Arr.Len then + return False; + end if; + for I in L.Arr.V'Range loop + if not Is_Equal (L.Arr.V (I), R.Arr.V (I)) then + return False; + end if; + end loop; + return True; when others => -- TODO. raise Internal_Error; |