diff options
author | tgingold <tgingold@users.noreply.github.com> | 2019-08-30 20:41:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-30 20:41:32 +0200 |
commit | 88942b924c92f2f90418706718b1bec3d38af007 (patch) | |
tree | bf8403a8f1c5639a97f999da31873316d2aad4e0 /src | |
parent | 3c81c6f8fb41058e505c61db0f7d566ffebe2357 (diff) | |
parent | 5e1ef953f38c0347c760417cf7bddf554dc199a5 (diff) | |
download | ghdl-88942b924c92f2f90418706718b1bec3d38af007.tar.gz ghdl-88942b924c92f2f90418706718b1bec3d38af007.tar.bz2 ghdl-88942b924c92f2f90418706718b1bec3d38af007.zip |
synth: add physical division (#904)
* synth: added division of physical type
* testsuite/synth: added test for the physical division
Diffstat (limited to 'src')
-rw-r--r-- | src/synth/synth-expr.adb | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/synth/synth-expr.adb b/src/synth/synth-expr.adb index 26318bcf8..4d443d999 100644 --- a/src/synth/synth-expr.adb +++ b/src/synth/synth-expr.adb @@ -1330,6 +1330,15 @@ package body Synth.Expr is else return Synth_Compare (Id_Ne); end if; + when Iir_Predefined_Physical_Physical_Div => + if Is_Const (Left) and then Is_Const (Right) then + return Create_Value_Discrete + (Left.Scal / Right.Scal, + Get_Value_Type (Syn_Inst, Get_Type (Expr))); + else + Error_Msg_Synth (+Expr, "non-constant division not supported"); + return null; + end if; when others => Error_Msg_Synth (+Expr, "synth_dyadic_operation: unhandled " @@ -2278,7 +2287,8 @@ package body Synth.Expr is when Iir_Kind_Floating_Point_Literal => return Create_Value_Float (Get_Fp_Value (Expr), Get_Value_Type (Syn_Inst, Expr_Type)); - when Iir_Kind_Physical_Int_Literal => + when Iir_Kind_Physical_Int_Literal + | Iir_Kind_Physical_Fp_Literal => return Create_Value_Discrete (Get_Physical_Value (Expr), Get_Value_Type (Syn_Inst, Expr_Type)); |