From 9261f29da57957855eefd5b202504b5afc5dbdd3 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Wed, 1 Apr 2020 07:56:42 +0200 Subject: synth: handle low/high type attributes. Fix #1180 --- src/synth/synth-expr.adb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/synth/synth-expr.adb b/src/synth/synth-expr.adb index 1a735cc82..8dcd8d058 100644 --- a/src/synth/synth-expr.adb +++ b/src/synth/synth-expr.adb @@ -1947,6 +1947,24 @@ package body Synth.Expr is return Res; end Synth_String_Literal; + -- Return the left bound if the direction of the range is LEFT_DIR. + function Synth_Low_High_Type_Attribute + (Syn_Inst : Synth_Instance_Acc; Expr : Node; Left_Dir : Iir_Direction) + return Value_Acc + is + Typ : Type_Acc; + R : Int64; + begin + Typ := Get_Value_Type (Syn_Inst, Get_Type (Get_Prefix (Expr))); + pragma Assert (Typ.Kind = Type_Discrete); + if Typ.Drange.Dir = Left_Dir then + R := Typ.Drange.Left; + else + R := Typ.Drange.Right; + end if; + return Create_Value_Discrete (R, Typ); + end Synth_Low_High_Type_Attribute; + subtype And_Or_Module_Id is Module_Id range Id_And .. Id_Or; function Synth_Short_Circuit (Syn_Inst : Synth_Instance_Acc; @@ -2216,6 +2234,10 @@ package body Synth.Expr is -- subtype conversion. return Synth_Subtype_Conversion (V, Dtype, False, Expr); end; + when Iir_Kind_Low_Type_Attribute => + return Synth_Low_High_Type_Attribute (Syn_Inst, Expr, Iir_To); + when Iir_Kind_High_Type_Attribute => + return Synth_Low_High_Type_Attribute (Syn_Inst, Expr, Iir_Downto); when Iir_Kind_Value_Attribute => return Synth_Value_Attribute (Syn_Inst, Expr); when Iir_Kind_Image_Attribute => -- cgit v1.2.3