aboutsummaryrefslogtreecommitdiffstats
path: root/src/synth
diff options
context:
space:
mode:
authortmeissner <programming@goodcleanfun.de>2020-06-05 13:47:04 +0200
committertgingold <tgingold@users.noreply.github.com>2020-06-06 07:51:38 +0200
commite44cd87182452ce6220b028c62caa1bdbb9c55e3 (patch)
tree5b321c4f3df1ac98254c806617dcad5880a669c7 /src/synth
parent2b31399a2db58e5480fcd51569f6353609b4219a (diff)
downloadghdl-e44cd87182452ce6220b028c62caa1bdbb9c55e3.tar.gz
ghdl-e44cd87182452ce6220b028c62caa1bdbb9c55e3.tar.bz2
ghdl-e44cd87182452ce6220b028c62caa1bdbb9c55e3.zip
Synthesis of PSL stable() function.
Diffstat (limited to 'src/synth')
-rw-r--r--src/synth/synth-expr.adb60
1 files changed, 49 insertions, 11 deletions
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;