aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-07-25 19:09:17 +0200
committerTristan Gingold <tgingold@free.fr>2020-07-25 19:09:17 +0200
commit9f2f749c32d6ca8500f3f96977a4ee3801dc13a2 (patch)
tree37f3ac6c4674514e5713c4a430fc04c102d7adcd
parent3972f6c78055902116e6c9227da45e1bfe5e2c27 (diff)
downloadghdl-9f2f749c32d6ca8500f3f96977a4ee3801dc13a2.tar.gz
ghdl-9f2f749c32d6ca8500f3f96977a4ee3801dc13a2.tar.bz2
ghdl-9f2f749c32d6ca8500f3f96977a4ee3801dc13a2.zip
synth-aggr: handle strings in aggregates. Fix #1406
-rw-r--r--src/synth/synth-aggr.adb25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/synth/synth-aggr.adb b/src/synth/synth-aggr.adb
index 7732744a1..19d622195 100644
--- a/src/synth/synth-aggr.adb
+++ b/src/synth/synth-aggr.adb
@@ -19,6 +19,7 @@
-- MA 02110-1301, USA.
with Types; use Types;
+with Str_Table;
with Netlists; use Netlists;
with Netlists.Utils; use Netlists.Utils;
@@ -174,6 +175,30 @@ package body Synth.Aggr is
Const_P := True;
Err_P := False;
+ if Get_Kind (Aggr) = Iir_Kind_String_Literal8 then
+ declare
+ Str_Id : constant String8_Id := Get_String8_Id (Aggr);
+ Str_Len : constant Int32 := Get_String_Length (Aggr);
+ E : Valtyp;
+ V : Nat8;
+ begin
+ pragma Assert (Stride = 1);
+ if Bound.Len /= Width (Str_Len) then
+ Error_Msg_Synth
+ (+Aggr, "string length doesn't match bound length");
+ Err_P := True;
+ end if;
+ for I in 1 .. Pos32'Min (Pos32 (Str_Len), Pos32 (Bound.Len)) loop
+ E := Create_Value_Memory (El_Typ);
+ V := Str_Table.Element_String8 (Str_Id, I);
+ Write_U8 (E.Val.Mem, Nat8'Pos (V));
+ Res (Pos) := E;
+ Pos := Pos + 1;
+ end loop;
+ return;
+ end;
+ end if;
+
Assoc := Get_Association_Choices_Chain (Aggr);
while Is_Valid (Assoc) loop
Value := Get_Associated_Expr (Assoc);