aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-04-19 16:23:49 +0200
committerTristan Gingold <tgingold@free.fr>2020-04-19 16:23:49 +0200
commit80f764d9114dc6b147f398fed97fb985d0b9f1d4 (patch)
tree9611f1cc95776bc13bbb162f4a9127a26209887d
parenta131ab5138f7a8bea69b4ff9434f287e77ef6f10 (diff)
downloadghdl-80f764d9114dc6b147f398fed97fb985d0b9f1d4.tar.gz
ghdl-80f764d9114dc6b147f398fed97fb985d0b9f1d4.tar.bz2
ghdl-80f764d9114dc6b147f398fed97fb985d0b9f1d4.zip
synth: reject protected types. Fix #1244
-rw-r--r--src/synth/synth-decls.adb22
-rw-r--r--src/synth/synth-expr.adb3
-rw-r--r--src/synth/synth-objtypes.adb20
-rw-r--r--src/synth/synth-objtypes.ads7
-rw-r--r--src/synth/synth-values-debug.adb4
-rw-r--r--src/synth/synth-values.adb3
6 files changed, 51 insertions, 8 deletions
diff --git a/src/synth/synth-decls.adb b/src/synth/synth-decls.adb
index bf84ed41b..d615af910 100644
--- a/src/synth/synth-decls.adb
+++ b/src/synth/synth-decls.adb
@@ -216,6 +216,8 @@ package body Synth.Decls is
when Iir_Kind_Record_Type_Definition =>
Synth_Record_Elements_Definition (Syn_Inst, Def);
Typ := Synth_Record_Type_Definition (Syn_Inst, Def);
+ when Iir_Kind_Protected_Type_Declaration =>
+ Synth_Declarations (Syn_Inst, Get_Declaration_Chain (Def));
when others =>
Vhdl.Errors.Error_Kind ("synth_type_definition", Def);
end case;
@@ -720,14 +722,22 @@ package body Synth.Decls is
procedure Synth_Variable_Declaration
(Syn_Inst : Synth_Instance_Acc; Decl : Node; Is_Subprg : Boolean)
is
- Def : constant Iir := Get_Default_Value (Decl);
- -- Slot : constant Object_Slot_Type := Get_Info (Decl).Slot;
+ Def : constant Node := Get_Default_Value (Decl);
+ Decl_Type : constant Node := Get_Type (Decl);
Init : Valtyp;
Obj_Typ : Type_Acc;
Wid : Wire_Id;
begin
Synth_Declaration_Type (Syn_Inst, Decl);
- Obj_Typ := Get_Subtype_Object (Syn_Inst, Get_Type (Decl));
+ if Get_Kind (Decl_Type) = Iir_Kind_Protected_Type_Declaration then
+ Error_Msg_Synth
+ (+Decl, "protected type variable is not synthesizable");
+ Set_Error (Syn_Inst);
+ Create_Object (Syn_Inst, Decl, No_Valtyp);
+ return;
+ end if;
+
+ Obj_Typ := Get_Subtype_Object (Syn_Inst, Decl_Type);
if not Obj_Typ.Is_Synth
and then not Get_Instance_Const (Syn_Inst)
then
@@ -875,6 +885,8 @@ package body Synth.Decls is
Res := Create_Value_File (Obj_Typ, F);
Create_Object (Syn_Inst, Decl, Res);
end;
+ when Iir_Kind_Protected_Type_Body =>
+ null;
when Iir_Kind_Psl_Default_Clock =>
-- Ignored; directly used by PSL directives.
null;
@@ -964,7 +976,9 @@ package body Synth.Decls is
declare
Vt : constant Valtyp := Get_Value (Syn_Inst, Decl);
begin
- Free_Wire (Vt.Val.W);
+ if Vt /= No_Valtyp then
+ Free_Wire (Vt.Val.W);
+ end if;
end;
end if;
when Iir_Kind_Constant_Declaration =>
diff --git a/src/synth/synth-expr.adb b/src/synth/synth-expr.adb
index 98019b6d7..963532044 100644
--- a/src/synth/synth-expr.adb
+++ b/src/synth/synth-expr.adb
@@ -817,6 +817,9 @@ package body Synth.Expr is
when Type_File =>
pragma Assert (Vtype = Dtype);
return Vt;
+ when Type_Protected =>
+ pragma Assert (Vtype = Dtype);
+ return Vt;
end case;
end Synth_Subtype_Conversion;
diff --git a/src/synth/synth-objtypes.adb b/src/synth/synth-objtypes.adb
index 7fe04b112..cd199d724 100644
--- a/src/synth/synth-objtypes.adb
+++ b/src/synth/synth-objtypes.adb
@@ -54,7 +54,8 @@ package body Synth.Objtypes is
| Type_File =>
return True;
when Type_Unbounded_Array
- | Type_Unbounded_Vector =>
+ | Type_Unbounded_Vector
+ | Type_Protected =>
return False;
end case;
end Is_Bounded_Type;
@@ -112,6 +113,8 @@ package body Synth.Objtypes is
return Are_Types_Equal (L.Acc_Acc, R.Acc_Acc);
when Type_File =>
return Are_Types_Equal (L.File_Typ, R.File_Typ);
+ when Type_Protected =>
+ return False;
end case;
end Are_Types_Equal;
@@ -480,6 +483,18 @@ package body Synth.Objtypes is
File_Typ => File_Type)));
end Create_File_Type;
+ function Create_Protected_Type return Type_Acc
+ is
+ subtype Protected_Type_Type is Type_Type (Type_Protected);
+ function Alloc is new Areapools.Alloc_On_Pool_Addr (Protected_Type_Type);
+ begin
+ return To_Type_Acc (Alloc (Current_Pool, (Kind => Type_Protected,
+ Is_Synth => False,
+ Al => 2,
+ Sz => 4,
+ W => 32)));
+ end Create_Protected_Type;
+
function Vec_Length (Typ : Type_Acc) return Iir_Index32 is
begin
return Iir_Index32 (Typ.Vbound.Len);
@@ -558,7 +573,8 @@ package body Synth.Objtypes is
return True;
when Type_Access =>
return True;
- when Type_File =>
+ when Type_File
+ | Type_Protected =>
raise Internal_Error;
end case;
end Is_Matching_Bounds;
diff --git a/src/synth/synth-objtypes.ads b/src/synth/synth-objtypes.ads
index ad9a740ce..41d23ba8a 100644
--- a/src/synth/synth-objtypes.ads
+++ b/src/synth/synth-objtypes.ads
@@ -80,7 +80,8 @@ package Synth.Objtypes is
Type_Record,
Type_Access,
- Type_File
+ Type_File,
+ Type_Protected
);
subtype Type_Nets is Type_Kind range Type_Bit .. Type_Logic;
@@ -149,6 +150,8 @@ package Synth.Objtypes is
Acc_Acc : Type_Acc;
when Type_File =>
File_Typ : Type_Acc;
+ when Type_Protected =>
+ null;
end case;
end record;
@@ -210,6 +213,8 @@ package Synth.Objtypes is
function Create_File_Type (File_Type : Type_Acc) return Type_Acc;
+ function Create_Protected_Type return Type_Acc;
+
-- Return the bounds of dimension DIM of a vector/array. For a vector,
-- DIM must be 1.
function Get_Array_Bound (Typ : Type_Acc; Dim : Dim_Type)
diff --git a/src/synth/synth-values-debug.adb b/src/synth/synth-values-debug.adb
index f43a71ea2..ca289fbdd 100644
--- a/src/synth/synth-values-debug.adb
+++ b/src/synth/synth-values-debug.adb
@@ -78,6 +78,8 @@ package body Synth.Values.Debug is
Put ("unbounded vector");
when Type_Unbounded_Array =>
Put ("unbounded array");
+ when Type_Protected =>
+ Put ("protected");
end case;
end Debug_Typ1;
@@ -141,6 +143,8 @@ package body Synth.Values.Debug is
Put ("unbounded vector");
when Type_Unbounded_Array =>
Put ("unbounded array");
+ when Type_Protected =>
+ Put ("protected");
end case;
New_Line;
end Debug_Memtyp;
diff --git a/src/synth/synth-values.adb b/src/synth/synth-values.adb
index b72693243..995f41d55 100644
--- a/src/synth/synth-values.adb
+++ b/src/synth/synth-values.adb
@@ -473,7 +473,8 @@ package body Synth.Values is
end loop;
when Type_Access =>
Write_Access (M, Null_Heap_Index);
- when Type_File =>
+ when Type_File
+ | Type_Protected =>
raise Internal_Error;
end case;
end Write_Value_Default;