aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-09-25 20:47:07 +0200
committerTristan Gingold <tgingold@free.fr>2019-09-25 20:47:07 +0200
commitecd791d210198c82a88ee238d43ca02b2a36a1c1 (patch)
treeb22342e56b7df7eae06edbdf6acb7cd1be846f44
parent6e9336d11dfc4f53dba234e1f02a2b0172461e0c (diff)
downloadghdl-ecd791d210198c82a88ee238d43ca02b2a36a1c1.tar.gz
ghdl-ecd791d210198c82a88ee238d43ca02b2a36a1c1.tar.bz2
ghdl-ecd791d210198c82a88ee238d43ca02b2a36a1c1.zip
synth: handle array equality (for constances).
-rw-r--r--src/synth/synth-expr.adb9
-rw-r--r--src/synth/synth-oper.adb4
-rw-r--r--src/synth/synth-values.adb10
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;