aboutsummaryrefslogtreecommitdiffstats
path: root/src/synth/synth-oper.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-11-26 19:36:04 +0100
committerTristan Gingold <tgingold@free.fr>2019-11-26 19:36:04 +0100
commit6302237e7c3e0f067b4cf6be7cb44f319a825cc0 (patch)
treefe0b087195316554fc4a49925937956443cddc16 /src/synth/synth-oper.adb
parent43ee1ba79a5d7753701b20b294f9f379e45c1b96 (diff)
downloadghdl-6302237e7c3e0f067b4cf6be7cb44f319a825cc0.tar.gz
ghdl-6302237e7c3e0f067b4cf6be7cb44f319a825cc0.tar.bz2
ghdl-6302237e7c3e0f067b4cf6be7cb44f319a825cc0.zip
synth: handle static calls to sin and cos. Fix #1033
Diffstat (limited to 'src/synth/synth-oper.adb')
-rw-r--r--src/synth/synth-oper.adb34
1 files changed, 30 insertions, 4 deletions
diff --git a/src/synth/synth-oper.adb b/src/synth/synth-oper.adb
index 255df2e3f..f64674512 100644
--- a/src/synth/synth-oper.adb
+++ b/src/synth/synth-oper.adb
@@ -1180,8 +1180,7 @@ package body Synth.Oper is
pragma Import (C, Log2);
begin
if V.Typ.Kind /= Type_Float then
- Error_Msg_Synth
- (+Expr, "argument must be a float value");
+ Error_Msg_Synth (+Expr, "argument must be a float value");
return null;
end if;
return Create_Value_Float
@@ -1195,13 +1194,40 @@ package body Synth.Oper is
pragma Import (C, Ceil);
begin
if V.Typ.Kind /= Type_Float then
- Error_Msg_Synth
- (+Expr, "argument must be a float value");
+ Error_Msg_Synth(+Expr, "argument must be a float value");
return null;
end if;
return Create_Value_Float
(Ceil (V.Fp), Get_Value_Type (Syn_Inst, Get_Type (Imp)));
end;
+ when Iir_Predefined_Ieee_Math_Real_Sin =>
+ declare
+ V : constant Value_Acc := Get_Value (Subprg_Inst, Param1);
+
+ function Sin (Arg : Fp64) return Fp64;
+ pragma Import (C, Sin);
+ begin
+ if V.Typ.Kind /= Type_Float then
+ Error_Msg_Synth (+Expr, "argument must be a float value");
+ return null;
+ end if;
+ return Create_Value_Float
+ (Sin (V.Fp), Get_Value_Type (Syn_Inst, Get_Type (Imp)));
+ end;
+ when Iir_Predefined_Ieee_Math_Real_Cos =>
+ declare
+ V : constant Value_Acc := Get_Value (Subprg_Inst, Param1);
+
+ function Cos (Arg : Fp64) return Fp64;
+ pragma Import (C, Cos);
+ begin
+ if V.Typ.Kind /= Type_Float then
+ Error_Msg_Synth (+Expr, "argument must be a float value");
+ return null;
+ end if;
+ return Create_Value_Float
+ (Cos (V.Fp), Get_Value_Type (Syn_Inst, Get_Type (Imp)));
+ end;
when others =>
Error_Msg_Synth
(+Expr,