From e44cd87182452ce6220b028c62caa1bdbb9c55e3 Mon Sep 17 00:00:00 2001 From: tmeissner Date: Fri, 5 Jun 2020 13:47:04 +0200 Subject: Synthesis of PSL stable() function. --- src/synth/synth-expr.adb | 60 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 11 deletions(-) (limited to 'src/synth') diff --git a/src/synth/synth-expr.adb b/src/synth/synth-expr.adb index 677df4454..6f8317831 100644 --- a/src/synth/synth-expr.adb +++ b/src/synth/synth-expr.adb @@ -1849,30 +1849,40 @@ package body Synth.Expr is return Res; end Synth_PSL_Expression; + function Synth_Psl_Function_Clock + (Syn_Inst : Synth_Instance_Acc; Call : Node; Ctxt : Context_Acc) + return Net + is + Clock : Node; + Clk : Valtyp; + Clk_Net : Net; + begin + Clock := Get_Clock_Expression (Call); + if Clock /= Null_Node then + Clk := Synth_Expression (Syn_Inst, Clock); + Clk_Net := Get_Net (Ctxt, Clk); + else + Clock := Get_Default_Clock (Call); + pragma Assert (Clock /= Null_Node); + Clk_Net := Synth_PSL_Expression (Syn_Inst, Get_Psl_Boolean (Clock)); + end if; + return Clk_Net; + end Synth_Psl_Function_Clock; + function Synth_Psl_Prev (Syn_Inst : Synth_Instance_Acc; Call : Node) return Valtyp is Ctxt : constant Context_Acc := Get_Build (Syn_Inst); Count : constant Node := Get_Count_Expression (Call); - Clock : Node; Count_Val : Valtyp; Dff : Net; - Clk : Valtyp; Expr : Valtyp; Clk_Net : Net; Num : Int64; begin Expr := Synth_Expression (Syn_Inst, Get_Expression (Call)); - Clock := Get_Clock_Expression (Call); - if Clock /= Null_Node then - Clk := Synth_Expression (Syn_Inst, Clock); - Clk_Net := Get_Net (Ctxt, Clk); - else - Clock := Get_Default_Clock (Call); - pragma Assert (Clock /= Null_Node); - Clk_Net := Synth_PSL_Expression (Syn_Inst, Get_Psl_Boolean (Clock)); - end if; + Clk_Net := Synth_Psl_Function_Clock(Syn_Inst, Call, Ctxt); if Count /= Null_Node then Count_Val := Synth_Expression (Syn_Inst, Count); @@ -1891,6 +1901,32 @@ package body Synth.Expr is return Create_Value_Net (Dff, Expr.Typ); end Synth_Psl_Prev; + function Synth_Psl_Stable (Syn_Inst : Synth_Instance_Acc; Call : Node) + return Valtyp + is + Ctxt : constant Context_Acc := Get_Build (Syn_Inst); + DffCurr : Net; + Dff : Net; + Expr : Valtyp; + Clk_Net : Net; + Res : Net; + begin + Expr := Synth_Expression (Syn_Inst, Get_Expression (Call)); + + Clk_Net := Synth_Psl_Function_Clock(Syn_Inst, Call, Ctxt); + + DffCurr := Get_Net (Ctxt, Expr); + Set_Location (DffCurr, Call); + Dff := Build_Dff (Ctxt, Clk_Net, DffCurr); + Set_Location (Dff, Call); + + Res := Build_Compare(Ctxt, Id_Eq, DffCurr, Dff); + Set_Location (Res, Call); + + return Create_Value_Net (Res, Boolean_Type); + + end Synth_Psl_Stable; + subtype And_Or_Module_Id is Module_Id range Id_And .. Id_Or; function Synth_Short_Circuit (Syn_Inst : Synth_Instance_Acc; @@ -2231,6 +2267,8 @@ package body Synth.Expr is return No_Valtyp; when Iir_Kind_Psl_Prev => return Synth_Psl_Prev (Syn_Inst, Expr); + when Iir_Kind_Psl_Stable => + return Synth_Psl_Stable (Syn_Inst, Expr); when Iir_Kind_Overflow_Literal => Error_Msg_Synth (+Expr, "out of bound expression"); return No_Valtyp; -- cgit v1.2.3