aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2022-05-12 18:19:40 +0200
committerTristan Gingold <tgingold@free.fr>2022-05-12 18:19:40 +0200
commitea2327b6840eb675801eda0c4ff0770a15d2b6e0 (patch)
tree72c5d92937abea49a271667e7bba060c631acfd6 /src
parented91bc80635cb78acb4728f7781ea7e37c748a48 (diff)
downloadghdl-ea2327b6840eb675801eda0c4ff0770a15d2b6e0.tar.gz
ghdl-ea2327b6840eb675801eda0c4ff0770a15d2b6e0.tar.bz2
ghdl-ea2327b6840eb675801eda0c4ff0770a15d2b6e0.zip
synth-vhdl_expr: add an hook to get the value of a signal
Diffstat (limited to 'src')
-rw-r--r--src/synth/synth-vhdl_expr.adb3
-rw-r--r--src/synth/synth-vhdl_expr.ads6
2 files changed, 9 insertions, 0 deletions
diff --git a/src/synth/synth-vhdl_expr.adb b/src/synth/synth-vhdl_expr.adb
index 6036d6394..1f28e3fb2 100644
--- a/src/synth/synth-vhdl_expr.adb
+++ b/src/synth/synth-vhdl_expr.adb
@@ -2183,6 +2183,9 @@ package body Synth.Vhdl_Expr is
if Res.Val /= null
and then Res.Val.Kind = Value_Signal
then
+ if Hook_Signal_Expr /= null then
+ return Hook_Signal_Expr (Res);
+ end if;
Error_Msg_Synth
(+Expr, "cannot use signal value during elaboration");
return No_Valtyp;
diff --git a/src/synth/synth-vhdl_expr.ads b/src/synth/synth-vhdl_expr.ads
index 5591234bb..0aacd8cbf 100644
--- a/src/synth/synth-vhdl_expr.ads
+++ b/src/synth/synth-vhdl_expr.ads
@@ -72,6 +72,12 @@ package Synth.Vhdl_Expr is
procedure Concat_Array
(Ctxt : Context_Acc; Arr : in out Net_Array; N : out Net);
+ -- Hook to convert a signal to a value.
+ -- If not defined, the signal are not allowed (like in expressions during
+ -- elaboration).
+ type Hook_Signal_Expr_Acc is access function (Val : Valtyp) return Valtyp;
+ Hook_Signal_Expr : Hook_Signal_Expr_Acc;
+
-- Synthesize EXPR. The expression must be self-constrained.
-- If EN is not No_Net, the execution is controlled by EN. This is used
-- for assertions and checks.