aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-03-19 08:54:16 +0100
committerTristan Gingold <tgingold@free.fr>2020-03-19 08:54:16 +0100
commit3f84b2b046a375520a0d83b8b58ae42991915112 (patch)
treeca5c265b26d8f8726f4e40331ae09d752bf352b5 /src
parent2d50c68e91dcaafabb52d02afd43e001955b6b03 (diff)
downloadghdl-3f84b2b046a375520a0d83b8b58ae42991915112.tar.gz
ghdl-3f84b2b046a375520a0d83b8b58ae42991915112.tar.bz2
ghdl-3f84b2b046a375520a0d83b8b58ae42991915112.zip
synth-expr: handle vectors in aggregates. For #1161
Diffstat (limited to 'src')
-rw-r--r--src/synth/synth-expr.adb37
1 files changed, 28 insertions, 9 deletions
diff --git a/src/synth/synth-expr.adb b/src/synth/synth-expr.adb
index 1b730efa8..51d01f11e 100644
--- a/src/synth/synth-expr.adb
+++ b/src/synth/synth-expr.adb
@@ -416,7 +416,7 @@ package body Synth.Expr is
E : Value_Acc;
begin
for I in 1 .. Len loop
- E := Val.Arr.V (Len - I);
+ E := Val.Arr.V (I);
Res.V (Pos + I - 1) := E;
end loop;
Const_P := Const_P and then Val.Kind = Value_Const_Array;
@@ -450,14 +450,32 @@ package body Synth.Expr is
loop
case Get_Kind (Assoc) is
when Iir_Kind_Choice_By_None =>
- if not Get_Element_Type_Flag (Assoc) then
- raise Internal_Error;
- end if;
- if Pos >= First_Pos + Stride * Iir_Index32 (Bound.Len) then
- Error_Msg_Synth (+Assoc, "element out of array bound");
+ if Get_Element_Type_Flag (Assoc) then
+ if Pos >= First_Pos + Stride * Iir_Index32 (Bound.Len)
+ then
+ Error_Msg_Synth (+Assoc, "element out of array bound");
+ else
+ Set_Elem (Pos);
+ Pos := Pos + Stride;
+ end if;
else
- Set_Elem (Pos);
- Pos := Pos + Stride;
+ declare
+ Val : Value_Acc;
+ Val_Len : Uns32;
+ begin
+ Val := Synth_Expression_With_Basetype
+ (Syn_Inst, Value);
+ Val_Len := Get_Bound_Length (Val.Typ, 1);
+ pragma Assert (Stride = 1);
+ if Pos - First_Pos > Iir_Index32 (Bound.Len - Val_Len)
+ then
+ Error_Msg_Synth
+ (+Assoc, "element out of array bound");
+ else
+ Set_Vector (Pos, Iir_Index32 (Val_Len), Val);
+ Pos := Pos + Iir_Index32 (Val_Len);
+ end if;
+ end;
end if;
when Iir_Kind_Choice_By_Others =>
pragma Assert (Get_Element_Type_Flag (Assoc));
@@ -515,7 +533,8 @@ package body Synth.Expr is
& "direction of array");
end if;
-- FIXME: can the expression be unbounded ?
- Val := Synth_Expression (Syn_Inst, Value);
+ Val := Synth_Expression_With_Basetype
+ (Syn_Inst, Value);
-- The length must match the range.
Rng_Len := Get_Range_Length (Rng);
if Get_Bound_Length (Val.Typ, 1) /= Rng_Len then