aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-10-01 20:03:47 +0200
committerTristan Gingold <tgingold@free.fr>2019-10-01 20:03:47 +0200
commit6324fe8dc6aba1e0a57575a2986407df150f59f3 (patch)
treeb676b303a19b7588e682feafc6aafb4d3e6344fa
parent77a286d0a6c428b41037c3a7a81f7f3b962631f5 (diff)
downloadghdl-6324fe8dc6aba1e0a57575a2986407df150f59f3.tar.gz
ghdl-6324fe8dc6aba1e0a57575a2986407df150f59f3.tar.bz2
ghdl-6324fe8dc6aba1e0a57575a2986407df150f59f3.zip
synth: fix in extract_merge_partial_assigns.
-rw-r--r--src/synth/synth-environment.adb5
-rw-r--r--src/synth/synth-stmts.adb8
2 files changed, 10 insertions, 3 deletions
diff --git a/src/synth/synth-environment.adb b/src/synth/synth-environment.adb
index 8403e1066..2f6043cf9 100644
--- a/src/synth/synth-environment.adb
+++ b/src/synth/synth-environment.adb
@@ -797,8 +797,13 @@ package body Synth.Environment is
begin
if Pa.Offset <= Off then
Off := Uns32'Max (Pa.Offset, Min_Off);
+ -- FIXME: May increase the width.
Wd := Width'Min
(Wd, Get_Width (Pa.Value) - (Off - Pa.Offset));
+ elsif Pa.Offset < Off + Wd then
+ -- Reduce the width when there is an assignment after
+ -- the current offset.
+ Wd := Pa.Offset - Off;
end if;
end;
end if;
diff --git a/src/synth/synth-stmts.adb b/src/synth/synth-stmts.adb
index f64a4b9e4..e63c41d99 100644
--- a/src/synth/synth-stmts.adb
+++ b/src/synth/synth-stmts.adb
@@ -1015,11 +1015,10 @@ package body Synth.Stmts is
Wd : Width;
List : Partial_Assign_List;
begin
- -- Extract the value for each alternative.
+ -- Extract the value for each branch.
for I in Alts'Range loop
-- If there is an assignment to Wi in Alt, it will define the
- -- value. Otherwise, use Last_Val, ie the last assignment
- -- before the case.
+ -- value.
if Get_Wire_Id (Alts (I).Asgns) = Wi then
Pasgns (Int32 (I)) := Get_Assign_Partial (Alts (I).Asgns);
Alts (I).Asgns := Get_Assign_Chain (Alts (I).Asgns);
@@ -1032,10 +1031,13 @@ package body Synth.Stmts is
Min_Off := 0;
loop
Off := Min_Off;
+
+ -- Extract value of partial assignments to NETS.
Extract_Merge_Partial_Assigns
(Build_Context, Pasgns.all, Nets.all, Off, Wd);
exit when Off = Uns32'Last and Wd = Width'Last;
+ -- If a branch has no value, use the value before the case.
Last_Val := No_Net;
for I in Nets'Range loop
if Nets (I) = No_Net then