aboutsummaryrefslogtreecommitdiffstats
path: root/src/synth/elab-vhdl_files.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2022-09-17 11:52:42 +0200
committerTristan Gingold <tgingold@free.fr>2022-09-17 11:52:42 +0200
commit5d95674685a4a5c557757cc51c61b0fb6ec8fd18 (patch)
tree724d6bd8bb0f5a7e119cea4d1f93658499283ed6 /src/synth/elab-vhdl_files.adb
parent7548e438616dfc9fcfd05d1df8d6b4d88796e279 (diff)
downloadghdl-5d95674685a4a5c557757cc51c61b0fb6ec8fd18.tar.gz
ghdl-5d95674685a4a5c557757cc51c61b0fb6ec8fd18.tar.bz2
ghdl-5d95674685a4a5c557757cc51c61b0fb6ec8fd18.zip
synth: improve file handling (skip extra data, errors)
Diffstat (limited to 'src/synth/elab-vhdl_files.adb')
-rw-r--r--src/synth/elab-vhdl_files.adb49
1 files changed, 46 insertions, 3 deletions
diff --git a/src/synth/elab-vhdl_files.adb b/src/synth/elab-vhdl_files.adb
index be00296af..d5a92a966 100644
--- a/src/synth/elab-vhdl_files.adb
+++ b/src/synth/elab-vhdl_files.adb
@@ -492,6 +492,49 @@ package body Elab.Vhdl_Files is
end case;
end File_Read_Value;
+ procedure File_Skip_Value (File : File_Index; Typ : Type_Acc; Loc : Node)
+ is
+ Status : Op_Status;
+ begin
+ case Typ.Kind is
+ when Type_Discrete
+ | Type_Bit
+ | Type_Logic
+ | Type_Float =>
+ declare
+ Mem : Memory_Array (0 .. 7);
+ pragma Assert (Typ.Sz <= 8);
+ begin
+ Ghdl_Read_Scalar (File, Ghdl_Ptr (Mem'Address),
+ Ghdl_Index_Type (Typ.Sz), Status);
+ if Status /= Op_Ok then
+ File_Error (Loc, Status);
+ end if;
+ end;
+ when Type_Vector
+ | Type_Array =>
+ declare
+ El_Typ : constant Type_Acc := Get_Array_Element (Typ);
+ begin
+ for I in 1 .. Get_Bound_Length (Typ) loop
+ File_Skip_Value (File, El_Typ, Loc);
+ end loop;
+ end;
+ when Type_Record =>
+ for I in Typ.Rec.E'Range loop
+ File_Skip_Value (File, Typ.Rec.E (I).Typ, Loc);
+ end loop;
+ when Type_Unbounded_Record
+ | Type_Unbounded_Array
+ | Type_Unbounded_Vector
+ | Type_Protected
+ | Type_Slice
+ | Type_File
+ | Type_Access =>
+ raise Internal_Error;
+ end case;
+ end File_Skip_Value;
+
procedure Synth_File_Read
(Syn_Inst : Synth_Instance_Acc; Imp : Node; Loc : Node)
is
@@ -552,9 +595,9 @@ package body Elab.Vhdl_Files is
File_Read_Value (File, (El_Typ, Value.Val.Mem + Off), Loc);
Off := Off + El_Typ.Sz;
else
- -- FIXME: for empty arrays ??
- -- Lose_Binary (File, Value.Val_Array (0));
- raise Internal_Error;
+ -- Loose extra data.
+ File_Skip_Value (File, El_Typ, Loc);
+ Len := Len - 1;
end if;
end loop;
Write_Discrete (Length, Int64 (Len));