From f3e936f0ca532fb57f2700a46ba1ff84557f7305 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Mon, 5 Apr 2021 09:05:21 +0200 Subject: ghdldrv/: initial support for foreign modules --- src/errorout.adb | 4 ++-- src/errorout.ads | 2 +- src/ghdldrv/ghdlcomp.adb | 6 +++--- src/ghdldrv/ghdlcomp.ads | 9 ++++++++- src/ghdldrv/ghdlsynth.adb | 18 ++++++++++++++---- 5 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/errorout.adb b/src/errorout.adb index 45758167e..f0316197e 100644 --- a/src/errorout.adb +++ b/src/errorout.adb @@ -385,9 +385,9 @@ package body Errorout is Report_Handler.Message_Group.all (False); end Report_End_Group; - procedure Error_Msg_Option (Msg: String) is + procedure Error_Msg_Option (Msg: String; Args : Earg_Arr := No_Eargs) is begin - Report_Msg (Msgid_Error, Option, No_Source_Coord, Msg); + Report_Msg (Msgid_Error, Option, No_Source_Coord, Msg, Args); end Error_Msg_Option; procedure Warning_Msg_Option (Id : Msgid_Warnings; Msg: String) is diff --git a/src/errorout.ads b/src/errorout.ads index 4fa3b3a95..d060003ee 100644 --- a/src/errorout.ads +++ b/src/errorout.ads @@ -209,7 +209,7 @@ package Errorout is -- Disp an error, prepended with program name. -- This is used for errors before initialisation, such as bad option or -- bad filename. - procedure Error_Msg_Option (Msg: String); + procedure Error_Msg_Option (Msg: String; Args : Earg_Arr := No_Eargs); -- Warn about an option. procedure Warning_Msg_Option (Id : Msgid_Warnings; Msg: String); diff --git a/src/ghdldrv/ghdlcomp.adb b/src/ghdldrv/ghdlcomp.adb index 26c4915b3..c62348752 100644 --- a/src/ghdldrv/ghdlcomp.adb +++ b/src/ghdldrv/ghdlcomp.adb @@ -217,7 +217,7 @@ package body Ghdlcomp is end if; end Compile_Analyze_Init; - procedure Compile_Load_File (File : String) + procedure Compile_Load_Vhdl_File (File : String) is Res : Iir_Design_File; Design : Iir; @@ -236,7 +236,7 @@ package body Ghdlcomp is Libraries.Add_Design_Unit_Into_Library (Design); Design := Next_Design; end loop; - end Compile_Load_File; + end Compile_Load_Vhdl_File; function Compile_Analyze_File (File : String) return Iir is @@ -390,7 +390,7 @@ package body Ghdlcomp is end if; Libraries.Load_Work_Library (True); else - Compile_Load_File (Arg); + Compile_Load_Vhdl_File (Arg); end if; end; end loop; diff --git a/src/ghdldrv/ghdlcomp.ads b/src/ghdldrv/ghdlcomp.ads index fa26ee3b8..75d1e9f1d 100644 --- a/src/ghdldrv/ghdlcomp.ads +++ b/src/ghdldrv/ghdlcomp.ads @@ -97,11 +97,18 @@ package Ghdlcomp is -- Load and parse FILE, put library units in the work library (without -- analyzing them). - procedure Compile_Load_File (File : String); + procedure Compile_Load_Vhdl_File (File : String); -- Load, parse and analyze FILE. function Compile_Analyze_File (File : String) return Iir; procedure Compile_Elaborate (Unit_Name : String_Access); procedure Compile_Run; + + -- Load and parse file (without analysis). Put units in the work library. + type Load_File_Acc is access procedure (File : String); + + -- Hook for verilog. + Init_Verilog_Options : Compile_Init_Acc; + Load_Verilog_File : Load_File_Acc; end Ghdlcomp; diff --git a/src/ghdldrv/ghdlsynth.adb b/src/ghdldrv/ghdlsynth.adb index c3101fc16..8a21169bc 100644 --- a/src/ghdldrv/ghdlsynth.adb +++ b/src/ghdldrv/ghdlsynth.adb @@ -277,6 +277,10 @@ package body Ghdlsynth is -- Do not create concurrent signal assignment for inertial -- association. They are handled directly. Vhdl.Canon.Canon_Flag_Inertial_Associations := False; + + if Ghdlcomp.Init_Verilog_Options /= null then + Ghdlcomp.Init_Verilog_Options.all (False); + end if; end if; -- Mark vendor libraries. @@ -315,15 +319,21 @@ package body Ghdlsynth is case Files_Map.Find_Language (Arg) is when Language_Vhdl | Language_Psl => - null; + Ghdlcomp.Compile_Load_Vhdl_File (Arg); + when Language_Verilog => + if Ghdlcomp.Load_Verilog_File = null then + Error_Msg_Option + ("verilog file %i is not supported", + (1 => +Name_Table.Get_Identifier (Arg))); + else + Ghdlcomp.Load_Verilog_File (Arg); + end if; when others => Errorout.Report_Msg (Warnid_Library, Option, No_Source_Coord, - "unexpected extension for vhdl file %i", + "unexpected extension for file %i", (1 => +Name_Table.Get_Identifier (Arg))); end case; - - Ghdlcomp.Compile_Load_File (Arg); end if; end; end loop; -- cgit v1.2.3