diff options
| author | Tristan Gingold <tgingold@free.fr> | 2022-09-30 20:45:57 +0200 | 
|---|---|---|
| committer | Tristan Gingold <tgingold@free.fr> | 2022-09-30 20:45:57 +0200 | 
| commit | d4dc28659c657f14aecd2e6b04d747f36e540bb2 (patch) | |
| tree | f8ba3ee13c4ded76ad7bfcd9dba06cd47b76896b | |
| parent | a35c1cc1b249a16be478ce87747426315ee02817 (diff) | |
| download | ghdl-d4dc28659c657f14aecd2e6b04d747f36e540bb2.tar.gz ghdl-d4dc28659c657f14aecd2e6b04d747f36e540bb2.tar.bz2 ghdl-d4dc28659c657f14aecd2e6b04d747f36e540bb2.zip | |
synth: handle read for floats
| -rw-r--r-- | src/synth/synth-vhdl_eval.adb | 12 | ||||
| -rw-r--r-- | src/vhdl/vhdl-sem_specs.adb | 20 | 
2 files changed, 24 insertions, 8 deletions
| diff --git a/src/synth/synth-vhdl_eval.adb b/src/synth/synth-vhdl_eval.adb index f64be7158..46387c906 100644 --- a/src/synth/synth-vhdl_eval.adb +++ b/src/synth/synth-vhdl_eval.adb @@ -25,6 +25,7 @@ with Grt.Types; use Grt.Types;  with Grt.Vhdl_Types; use Grt.Vhdl_Types;  with Grt.To_Strings;  with Grt.Arith; +with Grt.Fcvt;  with Vhdl.Utils;  with Vhdl.Evaluation; @@ -2988,6 +2989,17 @@ package body Synth.Vhdl_Eval is              begin                 return Create_Memory_Fp64 (Atan (Read_Fp64 (Param1)), Res_Typ);              end; + +         when Iir_Predefined_Foreign_Textio_Read_Real => +            declare +               Len : constant Natural := Natural (Param1.Typ.Abound.Len); +               Res : Fp64; +               Cs : Ghdl_C_String; +            begin +               Cs := To_Ghdl_C_String (To_Address (Param1.Val.Mem)); +               Res := Fp64 (Grt.Fcvt.From_String (Cs (1 .. Len))); +               return Create_Memory_Fp64 (Res, Res_Typ); +            end;           when others =>              null;        end case; diff --git a/src/vhdl/vhdl-sem_specs.adb b/src/vhdl/vhdl-sem_specs.adb index 87e576e78..dff9e6da2 100644 --- a/src/vhdl/vhdl-sem_specs.adb +++ b/src/vhdl/vhdl-sem_specs.adb @@ -177,9 +177,9 @@ package body Vhdl.Sem_Specs is        return Null_Iir;     end Find_Attribute_Value; -   --  Called for 'Foreign attribute ATTR on procedure DECL. +   --  Called for 'Foreign attribute ATTR on subprogram DECL.     --  Handle intrinsic subprograms. -   procedure Attribute_Foreign_Procedure (Decl : Iir; Attr : Iir) +   procedure Attribute_Foreign_Subprogram (Decl : Iir; Attr : Iir)     is        Expr : constant Iir := Get_Expression (Attr);        Intrinsic_Str : constant String := "GHDL intrinsic"; @@ -218,7 +218,7 @@ package body Vhdl.Sem_Specs is           end case;           Set_Implicit_Definition (Decl, Predefined);        end; -   end Attribute_Foreign_Procedure; +   end Attribute_Foreign_Subprogram;     --  Decorate DECL with attribute ATTR.     --  If CHECK_CLASS is true, class of DECL must be class of ATTR, otherwise @@ -399,11 +399,15 @@ package body Vhdl.Sem_Specs is           --  Use 'standard' convention call for foreign procedures, so as a           --  consequence they cannot be suspended. -         if Get_Kind (Decl) = Iir_Kind_Procedure_Declaration then -            Set_Suspend_Flag (Decl, False); - -            Attribute_Foreign_Procedure (Decl, Attr); -         end if; +         case Get_Kind (Decl) is +            when Iir_Kind_Procedure_Declaration => +               Set_Suspend_Flag (Decl, False); +               Attribute_Foreign_Subprogram (Decl, Attr); +            when Iir_Kind_Function_Declaration => +               Attribute_Foreign_Subprogram (Decl, Attr); +            when others => +               null; +         end case;           declare              use Vhdl.Back_End; | 
