aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ghdldrv/ghdlsynth.adb44
-rw-r--r--src/ghdldrv/ghdlsynth.ads14
-rw-r--r--src/synth/ghdlsynth.h7
-rw-r--r--src/synth/libghdlsynth.adb33
-rw-r--r--src/synth/libghdlsynth.ads8
-rw-r--r--src/vhdl/libghdl/libghdl.ads2
6 files changed, 56 insertions, 52 deletions
diff --git a/src/ghdldrv/ghdlsynth.adb b/src/ghdldrv/ghdlsynth.adb
index 1d4624985..87fde5b43 100644
--- a/src/ghdldrv/ghdlsynth.adb
+++ b/src/ghdldrv/ghdlsynth.adb
@@ -16,12 +16,15 @@
-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-- 02111-1307, USA.
+with GNAT.OS_Lib; use GNAT.OS_Lib;
+
with Types; use Types;
with Ghdllocal; use Ghdllocal;
with Ghdlcomp; use Ghdlcomp;
with Ghdlmain; use Ghdlmain;
with Options; use Options;
with Errorout;
+with Errorout.Console;
with Libraries;
with Flags;
@@ -34,7 +37,6 @@ with Vhdl.Configuration;
with Vhdl.Annotations;
with Vhdl.Utils;
-with Netlists; use Netlists;
with Netlists.Dump;
with Netlists.Disp_Vhdl;
@@ -189,17 +191,42 @@ package body Ghdlsynth is
return Config;
end Ghdl_Synth_Configure;
- function Ghdl_Synth (Args : Argument_List) return Module
+ function Ghdl_Synth (Argc : Natural; Argv : C_String_Array_Acc)
+ return Module
is
+ Args : Argument_List (1 .. Argc);
+ Res : Module;
+ Cmd : Command_Acc;
+ First_Arg : Natural;
Config : Node;
begin
- Config := Ghdl_Synth_Configure (Args);
+ -- Create arguments list.
+ for I in 0 .. Argc - 1 loop
+ declare
+ Arg : constant Ghdl_C_String := Argv (I);
+ begin
+ Args (I + 1) := new String'(Arg (1 .. strlen (Arg)));
+ end;
+ end loop;
+
+ -- Find the command. This is a little bit convoluted...
+ Decode_Command_Options ("--synth", Cmd, Args, First_Arg);
+ -- Do the real work!
+ Config := Ghdl_Synth_Configure (Args (First_Arg .. Args'Last));
if Config = Null_Iir then
return No_Module;
end if;
- return Synthesis.Synth_Design (Config);
+ Res := Synthesis.Synth_Design (Config);
+ return Res;
+
+ exception
+ when Option_Error =>
+ return No_Module;
+ when others =>
+ -- Avoid possible issues with exceptions...
+ return No_Module;
end Ghdl_Synth;
procedure Perform_Action (Cmd : Command_Synth;
@@ -225,7 +252,7 @@ package body Ghdlsynth is
Netlists.Dump.Flag_Disp_Inline := Cmd.Disp_Inline;
Netlists.Dump.Disp_Module (Res);
when Format_Vhdl =>
- if True then
+ if Boolean'(True) then
Ent := Vhdl.Utils.Get_Entity_From_Configuration (Config);
Synth.Disp_Vhdl.Disp_Vhdl_Wrapper (Ent, Res);
else
@@ -238,4 +265,11 @@ package body Ghdlsynth is
begin
Ghdlmain.Register_Command (new Command_Synth);
end Register_Commands;
+
+ procedure Init_For_Ghdl_Synth is
+ begin
+ Ghdlsynth.Register_Commands;
+ Options.Initialize;
+ Errorout.Console.Install_Handler;
+ end Init_For_Ghdl_Synth;
end Ghdlsynth;
diff --git a/src/ghdldrv/ghdlsynth.ads b/src/ghdldrv/ghdlsynth.ads
index f9a755c08..b4ad92b86 100644
--- a/src/ghdldrv/ghdlsynth.ads
+++ b/src/ghdldrv/ghdlsynth.ads
@@ -15,11 +15,19 @@
-- along with GCC; see the file COPYING. If not, write to the Free
-- Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-- 02111-1307, USA.
-with Netlists;
-with GNAT.OS_Lib; use GNAT.OS_Lib;
+with Grt.Types; use Grt.Types;
+with Netlists; use Netlists;
package Ghdlsynth is
procedure Register_Commands;
- function Ghdl_Synth (Args : Argument_List) return Netlists.Module;
+ -- When used from a library, this init procedure must be called before
+ -- ghdl_synth.
+ procedure Init_For_Ghdl_Synth;
+
+ type C_String_Array is array (Natural) of Ghdl_C_String;
+ type C_String_Array_Acc is access C_String_Array;
+
+ function Ghdl_Synth (Argc : Natural; Argv : C_String_Array_Acc)
+ return Module;
end Ghdlsynth;
diff --git a/src/synth/ghdlsynth.h b/src/synth/ghdlsynth.h
index 35d123f32..d8b5ec784 100644
--- a/src/synth/ghdlsynth.h
+++ b/src/synth/ghdlsynth.h
@@ -118,10 +118,10 @@ namespace GhdlSynth {
GHDLSYNTH_ADA_WRAPPER_WWD(get_input_net, Net, Instance, Port_Idx);
- extern "C" unsigned int libghdlsynth__synth(int argc, const char **argv);
+ extern "C" unsigned int ghdlsynth__ghdl_synth(int argc, const char **argv);
inline Module ghdl_synth(int argc, const char **argv) {
Module res;
- res.id = libghdlsynth__synth(argc, argv);
+ res.id = ghdlsynth__ghdl_synth(argc, argv);
return res;
}
@@ -129,6 +129,5 @@ namespace GhdlSynth {
extern "C" void ghdlcomp__disp_config (void);
// Initialize and finalize the whole library.
- extern "C" void libghdlsynth_init (void);
- extern "C" void libghdlsynth_final (void);
+ extern "C" void libghdl_init (void);
};
diff --git a/src/synth/libghdlsynth.adb b/src/synth/libghdlsynth.adb
index 0931b48b6..94fd62899 100644
--- a/src/synth/libghdlsynth.adb
+++ b/src/synth/libghdlsynth.adb
@@ -18,44 +18,11 @@
-- Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
-- MA 02110-1301, USA.
-with GNAT.OS_Lib; use GNAT.OS_Lib;
-
-with Ghdlmain; use Ghdlmain;
with Ghdlsynth;
with Options; use Options;
with Errorout.Console;
package body Libghdlsynth is
- function Synth (Argc : Natural; Argv : C_String_Array_Acc) return Module
- is
- Args : Argument_List (1 .. Argc);
- Res : Module;
- Cmd : Command_Acc;
- First_Arg : Natural;
- begin
- -- Create arguments list.
- for I in 0 .. Argc - 1 loop
- declare
- Arg : constant Ghdl_C_String := Argv (I);
- begin
- Args (I + 1) := new String'(Arg (1 .. strlen (Arg)));
- end;
- end loop;
-
- -- Find the command. This is a little bit convoluted...
- Decode_Command_Options ("--synth", Cmd, Args, First_Arg);
-
- -- Do the real work!
- Res := Ghdlsynth.Ghdl_Synth (Args (First_Arg .. Args'Last));
-
- return Res;
- exception
- when Option_Error =>
- return No_Module;
- when others =>
- -- Avoid possible issues with exceptions...
- return No_Module;
- end Synth;
Gnat_Version : constant String := "unknown compiler version" & ASCII.NUL;
pragma Export (C, Gnat_Version, "__gnat_version");
diff --git a/src/synth/libghdlsynth.ads b/src/synth/libghdlsynth.ads
index 0824dea69..97f5c3378 100644
--- a/src/synth/libghdlsynth.ads
+++ b/src/synth/libghdlsynth.ads
@@ -18,12 +18,6 @@
-- Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
-- MA 02110-1301, USA.
-with Grt.Types; use Grt.Types;
-with Netlists; use Netlists;
-
package Libghdlsynth is
- type C_String_Array is array (Natural) of Ghdl_C_String;
- type C_String_Array_Acc is access C_String_Array;
-
- function Synth (Argc : Natural; Argv : C_String_Array_Acc) return Module;
+ pragma Elaborate_Body;
end Libghdlsynth;
diff --git a/src/vhdl/libghdl/libghdl.ads b/src/vhdl/libghdl/libghdl.ads
index 4d1595a10..7d69cde23 100644
--- a/src/vhdl/libghdl/libghdl.ads
+++ b/src/vhdl/libghdl/libghdl.ads
@@ -18,6 +18,8 @@
with Types; use Types;
with Vhdl.Nodes; use Vhdl.Nodes;
+with Ghdlsynth_Maybe;
+pragma Unreferenced (Ghdlsynth_Maybe);
package Libghdl is
-- Perform early initializations, and set hooks.