diff options
| author | Tristan Gingold <tgingold@free.fr> | 2019-11-29 19:08:41 +0100 | 
|---|---|---|
| committer | Tristan Gingold <tgingold@free.fr> | 2019-11-29 19:08:41 +0100 | 
| commit | 09de5ec9c9e8c66b2690c53b4e89ce81c5d447e5 (patch) | |
| tree | d0fcbd09352c32ee645a4956467aa35a1aec1da0 /src | |
| parent | f19f6a799f1f064dc96a34165e0f528418a1bc9d (diff) | |
| download | ghdl-09de5ec9c9e8c66b2690c53b4e89ce81c5d447e5.tar.gz ghdl-09de5ec9c9e8c66b2690c53b4e89ce81c5d447e5.tar.bz2 ghdl-09de5ec9c9e8c66b2690c53b4e89ce81c5d447e5.zip  | |
synth-static_oper: add support for array array concat.  Fix #1046
Diffstat (limited to 'src')
| -rw-r--r-- | src/synth/synth-oper.adb | 57 | ||||
| -rw-r--r-- | src/synth/synth-oper.ads | 5 | ||||
| -rw-r--r-- | src/synth/synth-static_oper.adb | 26 | 
3 files changed, 47 insertions, 41 deletions
diff --git a/src/synth/synth-oper.adb b/src/synth/synth-oper.adb index f64674512..57b4a294a 100644 --- a/src/synth/synth-oper.adb +++ b/src/synth/synth-oper.adb @@ -685,47 +685,22 @@ package body Synth.Oper is                   (N, Create_Onedimensional_Array_Subtype (Ret_Typ, Bnd));              end;           when Iir_Predefined_Array_Array_Concat => -            if Is_Static (Left) and then Is_Static (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; +            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;           when Iir_Predefined_Integer_Plus =>              return Synth_Int_Dyadic (Id_Add);           when Iir_Predefined_Integer_Minus => diff --git a/src/synth/synth-oper.ads b/src/synth/synth-oper.ads index 3f8e09bee..43ed42d21 100644 --- a/src/synth/synth-oper.ads +++ b/src/synth/synth-oper.ads @@ -36,4 +36,9 @@ package Synth.Oper is                                       Imp : Node;                                       Operand_Expr : Node;                                       Loc : Node) return Value_Acc; + +   function Create_Bounds_From_Length +     (Syn_Inst : Synth_Instance_Acc; Atype : Iir; Len : Iir_Index32) +     return Bound_Type; +  end Synth.Oper; diff --git a/src/synth/synth-static_oper.adb b/src/synth/synth-static_oper.adb index 7e5cb7a84..3fc12174b 100644 --- a/src/synth/synth-static_oper.adb +++ b/src/synth/synth-static_oper.adb @@ -20,9 +20,12 @@  with Types; use Types; +with Vhdl.Utils; use Vhdl.Utils; +  with Synth.Errors; use Synth.Errors;  with Synth.Source; use Synth.Source;  with Synth.Expr; use Synth.Expr; +with Synth.Oper;  with Synth.Ieee.Std_Logic_1164; use Synth.Ieee.Std_Logic_1164;  with Synth.Ieee.Numeric_Std; use Synth.Ieee.Numeric_Std; @@ -267,6 +270,29 @@ package body Synth.Static_Oper is           when Iir_Predefined_Floating_Div =>              return Create_Value_Float (Left.Fp / Right.Fp, Res_Typ); +         when Iir_Predefined_Array_Array_Concat => +            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 := Oper.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; +           when Iir_Predefined_Array_Equality             | Iir_Predefined_Record_Equality =>              return Create_Value_Discrete  | 
