From 942bf6281dd3e78688790e0f7196867ef5bda15d Mon Sep 17 00:00:00 2001 From: Martin Doerfelt Date: Wed, 28 Aug 2019 22:46:17 +0200 Subject: synth: added division of physical type --- src/synth/synth-expr.adb | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/synth/synth-expr.adb b/src/synth/synth-expr.adb index 7bdad0672..6fdd413a5 100644 --- a/src/synth/synth-expr.adb +++ b/src/synth/synth-expr.adb @@ -1323,6 +1323,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 " @@ -2269,7 +2278,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)); -- cgit v1.2.3 From 5e1ef953f38c0347c760417cf7bddf554dc199a5 Mon Sep 17 00:00:00 2001 From: Martin Doerfelt Date: Wed, 28 Aug 2019 22:52:08 +0200 Subject: testsuite/synth: added test for the physical division --- testsuite/synth/physical01/physical_division.vhdl | 14 ++++++++++++++ testsuite/synth/physical01/testsuite.sh | 11 +++++++++++ 2 files changed, 25 insertions(+) create mode 100644 testsuite/synth/physical01/physical_division.vhdl create mode 100755 testsuite/synth/physical01/testsuite.sh diff --git a/testsuite/synth/physical01/physical_division.vhdl b/testsuite/synth/physical01/physical_division.vhdl new file mode 100644 index 000000000..c632cd7de --- /dev/null +++ b/testsuite/synth/physical01/physical_division.vhdl @@ -0,0 +1,14 @@ +library ieee; + use ieee.std_logic_1164.all; + +entity physical_division is + port ( + clk_cycles : out integer + ); +end physical_division; + +architecture rtl of physical_division is + constant CLK_PERIOD : time := 83.333 ns; +begin + clk_cycles <= 100 ms / CLK_PERIOD; +end rtl; diff --git a/testsuite/synth/physical01/testsuite.sh b/testsuite/synth/physical01/testsuite.sh new file mode 100755 index 000000000..594edb174 --- /dev/null +++ b/testsuite/synth/physical01/testsuite.sh @@ -0,0 +1,11 @@ +#! /bin/sh + +. ../../testenv.sh + +for t in physical_division; do + synth $t.vhdl -e $t > syn_$t.vhdl + analyze syn_$t.vhdl + clean +done + +echo "Test successful" -- cgit v1.2.3