aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-10-13 18:51:53 +0200
committerTristan Gingold <tgingold@free.fr>2019-10-13 18:54:25 +0200
commit6b4f4c01a59a4d7f5bd8081022b68a6f69c81aa8 (patch)
tree7d2ea3bd08371105eccce480003313dea266ee04 /src
parent0b9c75143e41f389b6f437c45746fbd6afc431b5 (diff)
downloadghdl-6b4f4c01a59a4d7f5bd8081022b68a6f69c81aa8.tar.gz
ghdl-6b4f4c01a59a4d7f5bd8081022b68a6f69c81aa8.tar.bz2
ghdl-6b4f4c01a59a4d7f5bd8081022b68a6f69c81aa8.zip
synth-oper: handle const array array concat.
Diffstat (limited to 'src')
-rw-r--r--src/synth/synth-oper.adb57
1 files changed, 41 insertions, 16 deletions
diff --git a/src/synth/synth-oper.adb b/src/synth/synth-oper.adb
index b79754c5a..b36511adf 100644
--- a/src/synth/synth-oper.adb
+++ b/src/synth/synth-oper.adb
@@ -723,22 +723,47 @@ package body Synth.Oper is
(N, Create_Onedimensional_Array_Subtype (Ret_Typ, Bnd));
end;
when Iir_Predefined_Array_Array_Concat =>
- declare
- L : constant Net := Get_Net (Left);
- R : constant Net := Get_Net (Right);
- Bnd : Bound_Type;
- N : Net;
- begin
- N := Build_Concat2 (Build_Context, L, R);
- Set_Location (N, Expr);
- Bnd := Create_Bounds_From_Length
- (Syn_Inst,
- Get_Index_Type (Get_Type (Expr), 0),
- Iir_Index32 (Get_Width (L) + Get_Width (R)));
-
- return Create_Value_Net
- (N, Create_Vector_Type (Bnd, Get_Array_Element (Left.Typ)));
- end;
+ if Is_Const (Left) and then Is_Const (Right) then
+ declare
+ Ret_Typ : constant Type_Acc :=
+ Get_Value_Type (Syn_Inst, Get_Return_Type (Imp));
+ Bnd : Bound_Type;
+ Res_Typ : Type_Acc;
+ Arr : Value_Array_Acc;
+ begin
+ Bnd := Create_Bounds_From_Length
+ (Syn_Inst, Get_Index_Type (Get_Type (Expr), 0),
+ Left.Arr.Len + Right.Arr.Len);
+ Res_Typ := Create_Onedimensional_Array_Subtype
+ (Ret_Typ, Bnd);
+ Arr := Create_Value_Array (Left.Arr.Len + Right.Arr.Len);
+ for I in Left.Arr.V'Range loop
+ Arr.V (I) := Left.Arr.V (I);
+ end loop;
+ for I in Right.Arr.V'Range loop
+ Arr.V (Left.Arr.Len + I) := Right.Arr.V (I);
+ end loop;
+ return Create_Value_Const_Array (Res_Typ, Arr);
+ end;
+ else
+ declare
+ L : constant Net := Get_Net (Left);
+ R : constant Net := Get_Net (Right);
+ Bnd : Bound_Type;
+ N : Net;
+ begin
+ N := Build_Concat2 (Build_Context, L, R);
+ Set_Location (N, Expr);
+ Bnd := Create_Bounds_From_Length
+ (Syn_Inst,
+ Get_Index_Type (Get_Type (Expr), 0),
+ Iir_Index32 (Get_Width (L) + Get_Width (R)));
+
+ return Create_Value_Net
+ (N,
+ Create_Vector_Type (Bnd, Get_Array_Element (Left.Typ)));
+ end;
+ end if;
when Iir_Predefined_Integer_Plus =>
if Is_Const_Val (Left) and then Is_Const_Val (Right) then
return Create_Value_Discrete