aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/synth/synth-context.adb24
-rw-r--r--src/synth/synth-context.ads6
-rw-r--r--src/synth/synth-insts.adb15
-rw-r--r--src/synth/synth-insts.ads6
-rw-r--r--src/synth/synthesis.adb21
-rw-r--r--src/synth/synthesis.ads2
6 files changed, 46 insertions, 28 deletions
diff --git a/src/synth/synth-context.adb b/src/synth/synth-context.adb
index e89a29e11..822eb06e8 100644
--- a/src/synth/synth-context.adb
+++ b/src/synth/synth-context.adb
@@ -23,6 +23,8 @@ with Ada.Unchecked_Deallocation;
with Types; use Types;
with Tables;
with Types_Utils; use Types_Utils;
+with Name_Table; use Name_Table;
+
with Vhdl.Errors; use Vhdl.Errors;
with Netlists.Builders; use Netlists.Builders;
@@ -38,6 +40,24 @@ package body Synth.Context is
Table_Low_Bound => 1,
Table_Initial => 16);
+ function Make_Base_Instance return Synth_Instance_Acc
+ is
+ Global_Module : Module;
+ Res : Synth_Instance_Acc;
+ begin
+ Global_Module :=
+ New_Design (New_Sname_Artificial (Get_Identifier ("top")));
+ Build_Context := Build_Builders (Global_Module);
+ Res := new Synth_Instance_Type'(Max_Objs => Global_Info.Nbr_Objects,
+ M => Global_Module,
+ Name => No_Sname,
+ Block_Scope => Global_Info,
+ Up_Block => null,
+ Elab_Objects => 0,
+ Objects => (others => null));
+ return Res;
+ end Make_Base_Instance;
+
function Make_Instance (Parent : Synth_Instance_Acc;
Info : Sim_Info_Acc;
Name : Sname := No_Sname)
@@ -157,9 +177,7 @@ package body Synth.Context is
is
Info : constant Sim_Info_Acc := Get_Info (Decl);
begin
- if Syn_Inst /= Global_Instance then
- Create_Object (Syn_Inst, Info.Slot, 1);
- end if;
+ Create_Object (Syn_Inst, Info.Slot, 1);
Create_Object_Force (Syn_Inst, Decl, Val);
end Create_Object;
diff --git a/src/synth/synth-context.ads b/src/synth/synth-context.ads
index 3766b57ab..27135011e 100644
--- a/src/synth/synth-context.ads
+++ b/src/synth/synth-context.ads
@@ -33,10 +33,6 @@ package Synth.Context is
type Synth_Instance_Type (<>) is limited private;
type Synth_Instance_Acc is access Synth_Instance_Type;
- -- The instance corresponding to the global_info. It contains the global
- -- packages.
- Global_Instance : Synth_Instance_Acc;
-
-- Global context.
Build_Context : Netlists.Builders.Context_Acc;
@@ -44,6 +40,8 @@ package Synth.Context is
(Syn_Inst: Synth_Instance_Acc; Scope: Sim_Info_Acc)
return Synth_Instance_Acc;
+ function Make_Base_Instance return Synth_Instance_Acc;
+
-- Create and free the corresponding synth instance.
function Make_Instance (Parent : Synth_Instance_Acc;
Info : Sim_Info_Acc;
diff --git a/src/synth/synth-insts.adb b/src/synth/synth-insts.adb
index cc877c929..12ac37add 100644
--- a/src/synth/synth-insts.adb
+++ b/src/synth/synth-insts.adb
@@ -40,6 +40,8 @@ with Synth.Decls; use Synth.Decls;
with Synth.Expr; use Synth.Expr;
package body Synth.Insts is
+ Root_Instance : Synth_Instance_Acc;
+
function Mode_To_Port_Kind (Mode : Iir_Mode) return Port_Kind is
begin
case Mode is
@@ -172,7 +174,7 @@ package body Synth.Insts is
end if;
-- Create the instance.
- Syn_Inst := Make_Instance (Global_Instance, Get_Info (Imp), No_Sname);
+ Syn_Inst := Make_Instance (Root_Instance, Get_Info (Imp), No_Sname);
-- Make the entity reachable.
Set_Block_Scope (Syn_Inst, Get_Info (Decl));
@@ -220,7 +222,8 @@ package body Synth.Insts is
-- Declare module.
Set_Module (Syn_Inst,
New_User_Module
- (Global_Module, New_Sname_User (Get_Identifier (Decl)),
+ (Get_Module (Root_Instance),
+ New_Sname_User (Get_Identifier (Decl)),
Id_User_None, Nbr_Inputs, Nbr_Outputs, 0));
-- Add ports to module.
@@ -594,14 +597,18 @@ package body Synth.Insts is
end;
end Synth_Component_Instantiation_Statement;
- procedure Synth_Top_Entity
- (Arch : Node; Config : Node; Inst : out Synth_Instance_Acc)
+ procedure Synth_Top_Entity (Global_Instance : Synth_Instance_Acc;
+ Arch : Node;
+ Config : Node;
+ Inst : out Synth_Instance_Acc)
is
Entity : constant Node := Get_Entity (Arch);
Syn_Inst : Synth_Instance_Acc;
Inter : Node;
Inst_Obj : Inst_Object;
begin
+ Root_Instance := Global_Instance;
+
Syn_Inst := Make_Instance (Global_Instance, Get_Info (Arch),
New_Sname_User (Get_Identifier (Entity)));
-- Make the entity visible.
diff --git a/src/synth/synth-insts.ads b/src/synth/synth-insts.ads
index fdd66baa2..e4ac187f2 100644
--- a/src/synth/synth-insts.ads
+++ b/src/synth/synth-insts.ads
@@ -26,8 +26,10 @@ package Synth.Insts is
procedure Init;
procedure Synth_All_Instances;
- procedure Synth_Top_Entity
- (Arch : Node; Config : Node; Inst : out Synth_Instance_Acc);
+ procedure Synth_Top_Entity (Global_Instance : Synth_Instance_Acc;
+ Arch : Node;
+ Config : Node;
+ Inst : out Synth_Instance_Acc);
-- Apply block configuration CFG to BLK.
-- Must be done before synthesis of BLK.
diff --git a/src/synth/synthesis.adb b/src/synth/synthesis.adb
index 13371b122..7c51e90c8 100644
--- a/src/synth/synthesis.adb
+++ b/src/synth/synthesis.adb
@@ -18,10 +18,6 @@
-- Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
-- MA 02110-1301, USA.
-with Name_Table; use Name_Table;
-
-with Netlists.Builders; use Netlists.Builders;
-
with Vhdl.Utils; use Vhdl.Utils;
with Vhdl.Annotations; use Vhdl.Annotations;
@@ -60,10 +56,10 @@ package body Synthesis is
begin
Syn_Inst := Make_Instance (Parent_Inst, Info);
Val := Create_Value_Instance (Syn_Inst);
- if Parent_Inst /= Global_Instance then
- Create_Object (Parent_Inst, Pkg, Val);
- else
+ if Get_Kind (Get_Parent (Pkg)) = Iir_Kind_Design_Unit then
Create_Package_Object (Parent_Inst, Pkg, Val);
+ else
+ Create_Object (Parent_Inst, Pkg, Val);
end if;
Synth_Declarations (Syn_Inst, Get_Declaration_Chain (Pkg));
if Pkg = Vhdl.Std_Package.Standard_Package then
@@ -115,6 +111,7 @@ package body Synthesis is
Unit : constant Node := Get_Library_Unit (Design);
Arch : Node;
Config : Node;
+ Global_Instance : Synth_Instance_Acc;
begin
-- Extract architecture from design.
case Get_Kind (Unit) is
@@ -130,11 +127,9 @@ package body Synthesis is
Error_Kind ("synth_design", Unit);
end case;
- Global_Module :=
- New_Design (New_Sname_Artificial (Get_Identifier ("top")));
- Build_Context := Build_Builders (Global_Module);
+ Global_Instance := Make_Base_Instance;
+
Synth.Values.Init;
- Global_Instance := Make_Instance (null, Global_Info);
Synth.Insts.Init;
-- Dependencies first.
@@ -143,12 +138,12 @@ package body Synthesis is
Synth_Dependencies
(Global_Instance, Get_Design_Unit (Arch));
- Synth_Top_Entity (Arch, Config, Inst);
+ Synth_Top_Entity (Global_Instance, Arch, Config, Inst);
Synth_All_Instances;
if Errorout.Nbr_Errors > 0 then
raise Compilation_Error;
end if;
- M := Global_Module;
+ M := Get_Module (Global_Instance);
end Synth_Design;
end Synthesis;
diff --git a/src/synth/synthesis.ads b/src/synth/synthesis.ads
index ac458ff88..abf564ba9 100644
--- a/src/synth/synthesis.ads
+++ b/src/synth/synthesis.ads
@@ -26,7 +26,5 @@ package Synthesis is
procedure Synth_Design
(Design : Iir; M : out Module; Inst : out Synth_Instance_Acc);
- Global_Module : Module;
-
Synth_Error : exception;
end Synthesis;