From 6324fe8dc6aba1e0a57575a2986407df150f59f3 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Tue, 1 Oct 2019 20:03:47 +0200 Subject: synth: fix in extract_merge_partial_assigns. --- src/synth/synth-environment.adb | 5 +++++ src/synth/synth-stmts.adb | 8 +++++--- 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'src') 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 -- cgit v1.2.3