aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2023-03-02 07:45:44 +0100
committerTristan Gingold <tgingold@free.fr>2023-03-02 07:46:41 +0100
commita4c35e81f9981ae14ba358269335266b1ec620bf (patch)
tree9ad1278b284fe674a9de06ef395f0206a4d6cef9 /src
parentc16a0000f9fafd78f0c32a7ed7f28ee537d81d94 (diff)
downloadghdl-a4c35e81f9981ae14ba358269335266b1ec620bf.tar.gz
ghdl-a4c35e81f9981ae14ba358269335266b1ec620bf.tar.bz2
ghdl-a4c35e81f9981ae14ba358269335266b1ec620bf.zip
synth-vhdl_stmts: handle unaffected in conditional variable assignments
Fix #2369
Diffstat (limited to 'src')
-rw-r--r--src/synth/synth-vhdl_stmts.adb14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/synth/synth-vhdl_stmts.adb b/src/synth/synth-vhdl_stmts.adb
index 5cfa48c31..4fae9b5a8 100644
--- a/src/synth/synth-vhdl_stmts.adb
+++ b/src/synth/synth-vhdl_stmts.adb
@@ -857,7 +857,7 @@ package body Synth.Vhdl_Stmts is
Marker : Mark_Type;
Targ : Target_Info;
Cond : Node;
- Cwf : Node;
+ Cwf, Wf : Node;
Inp : Input;
Val, Cond_Val : Valtyp;
Cond_Net : Net;
@@ -870,8 +870,13 @@ package body Synth.Vhdl_Stmts is
Cwf := Get_Conditional_Waveform_Chain (Stmt);
Cond := Null_Node;
while Cwf /= Null_Node loop
- Val := Synth_Waveform
- (Syn_Inst, Get_Waveform_Chain (Cwf), Targ.Targ_Type);
+ Wf := Get_Waveform_Chain (Cwf);
+ if Get_Kind (Wf) = Iir_Kind_Unaffected_Waveform then
+ -- For unaffected, read the current value.
+ Val := Synth_Read (Syn_Inst, Targ, Stmt);
+ else
+ Val := Synth_Waveform (Syn_Inst, Wf, Targ.Targ_Type);
+ end if;
if Val = No_Valtyp then
-- Mark the error, but try to continue.
Set_Error (Syn_Inst);
@@ -879,6 +884,7 @@ package body Synth.Vhdl_Stmts is
V := Get_Net (Ctxt, Val);
Cond := Get_Condition (Cwf);
if Cond /= Null_Node then
+ -- Add a mux to make it conditional.
Cond_Val := Synth_Expression (Syn_Inst, Cond);
if Cond_Val = No_Valtyp then
Cond_Net := Build_Const_UB32 (Ctxt, 0, 1);
@@ -890,6 +896,7 @@ package body Synth.Vhdl_Stmts is
Set_Location (V, Cwf);
end if;
+ -- Append
if Last /= No_Net then
Inp := Get_Input (Get_Net_Parent (Last), 1);
Connect (Inp, V);
@@ -901,6 +908,7 @@ package body Synth.Vhdl_Stmts is
Cwf := Get_Chain (Cwf);
end loop;
if Cond /= Null_Node then
+ -- If the last waveform has a condition, set the else branch.
pragma Assert (Last /= No_Net);
Inp := Get_Input (Get_Net_Parent (Last), 1);
if Get_Driver (Inp) = No_Net then