diff options
author | Tristan Gingold <tgingold@free.fr> | 2019-07-14 07:04:56 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2019-07-14 08:31:58 +0200 |
commit | 1b78b16bd6ffde3cf5ab83f5e3cb65d9dfc09b85 (patch) | |
tree | db2d7a81c84945a532acc09481df9451b885fa53 /src/ghdldrv | |
parent | e837a3899bb7d2bd8dc4d99ae0cb10ae0d4a1a75 (diff) | |
download | ghdl-1b78b16bd6ffde3cf5ab83f5e3cb65d9dfc09b85.tar.gz ghdl-1b78b16bd6ffde3cf5ab83f5e3cb65d9dfc09b85.tar.bz2 ghdl-1b78b16bd6ffde3cf5ab83f5e3cb65d9dfc09b85.zip |
ghdlsynth: check top entity can be a top entity.
Diffstat (limited to 'src/ghdldrv')
-rw-r--r-- | src/ghdldrv/ghdlcomp.adb | 2 | ||||
-rw-r--r-- | src/ghdldrv/ghdlsynth.adb | 52 |
2 files changed, 35 insertions, 19 deletions
diff --git a/src/ghdldrv/ghdlcomp.adb b/src/ghdldrv/ghdlcomp.adb index 452acaa75..a20ff932a 100644 --- a/src/ghdldrv/ghdlcomp.adb +++ b/src/ghdldrv/ghdlcomp.adb @@ -338,7 +338,7 @@ package body Ghdlcomp is (Get_Block_Specification (Get_Block_Configuration (Conf_Unit))); Entity : constant Iir := Vhdl.Utils.Get_Entity (Arch); begin - Vhdl.Configuration.Check_Entity_Declaration_Top (Entity); + Vhdl.Configuration.Check_Entity_Declaration_Top (Entity, True); if Nbr_Errors > 0 then raise Compilation_Error; end if; diff --git a/src/ghdldrv/ghdlsynth.adb b/src/ghdldrv/ghdlsynth.adb index cf9b2dc24..429d1ab55 100644 --- a/src/ghdldrv/ghdlsynth.adb +++ b/src/ghdldrv/ghdlsynth.adb @@ -31,6 +31,7 @@ with Vhdl.Std_Package; with Vhdl.Canon; with Vhdl.Configuration; with Vhdl.Annotations; +with Vhdl.Utils; with Synthesis; with Netlists; use Netlists; @@ -97,6 +98,9 @@ package body Ghdlsynth is E_Opt : Integer; Opt_Arg : Natural; Config : Iir; + Top : Iir; + Prim_Id : Name_Id; + Sec_Id : Name_Id; begin -- If the '-e' switch is present, there is a list of files. E_Opt := Args'First - 1; @@ -128,27 +132,39 @@ package body Ghdlsynth is -- Elaborate if E_Opt = Args'Last then -- No unit. - declare - Top : Node; - begin - Top := Vhdl.Configuration.Find_Top_Entity (Libraries.Work_Library); - if Top = Null_Node then - Ghdlmain.Error ("no top unit found"); - return No_Module; - end if; - Errorout.Report_Msg (Msgid_Note, Option, No_Source_Coord, - "top entity is %i", (1 => +Top)); - Config := Vhdl.Configuration.Configure - (Get_Identifier (Top), Null_Identifier); - end; + Top := Vhdl.Configuration.Find_Top_Entity (Libraries.Work_Library); + if Top = Null_Node then + Ghdlmain.Error ("no top unit found"); + return No_Module; + end if; + Errorout.Report_Msg (Msgid_Note, Option, No_Source_Coord, + "top entity is %i", (1 => +Top)); + Prim_Id := Get_Identifier (Top); + Sec_Id := Null_Identifier; else - Common_Compile_Elab - ("--synth", Args (E_Opt + 1 .. Args'Last), Opt_Arg, Config); + Extract_Elab_Unit ("--synth", Args (E_Opt + 1 .. Args'Last), Opt_Arg, + Prim_Id, Sec_Id); + if Opt_Arg <= Args'Last then + Ghdlmain.Error ("extra options ignored"); + return No_Module; + end if; end if; - if Opt_Arg <= Args'Last then - Ghdlmain.Error ("extra options ignored"); - end if; + Config := Vhdl.Configuration.Configure (Prim_Id, Sec_Id); + + -- Check (and possibly abandon) if entity can be at the top of the + -- hierarchy. + declare + Conf_Unit : constant Iir := Get_Library_Unit (Config); + Arch : constant Iir := Get_Named_Entity + (Get_Block_Specification (Get_Block_Configuration (Conf_Unit))); + Entity : constant Iir := Vhdl.Utils.Get_Entity (Arch); + begin + Vhdl.Configuration.Check_Entity_Declaration_Top (Entity, False); + if Nbr_Errors > 0 then + raise Compilation_Error; + end if; + end; -- Annotate all units. Vhdl.Annotations.Annotate (Vhdl.Std_Package.Std_Standard_Unit); |