aboutsummaryrefslogtreecommitdiffstats
path: root/src/synth/synth-environment.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-05-03 17:25:39 +0200
committerTristan Gingold <tgingold@free.fr>2020-05-04 19:04:09 +0200
commit683fbcde25efed81aac4d659d89bc4a8421a7b26 (patch)
treeb5720b6e9ae24f0d90e4d85474bcce4811022b84 /src/synth/synth-environment.adb
parentd3670fb86dc7ccd39d2e6738d90d268da3308713 (diff)
downloadghdl-683fbcde25efed81aac4d659d89bc4a8421a7b26.tar.gz
ghdl-683fbcde25efed81aac4d659d89bc4a8421a7b26.tar.bz2
ghdl-683fbcde25efed81aac4d659d89bc4a8421a7b26.zip
synth: minor refactoring for clean-up.
Diffstat (limited to 'src/synth/synth-environment.adb')
-rw-r--r--src/synth/synth-environment.adb69
1 files changed, 45 insertions, 24 deletions
diff --git a/src/synth/synth-environment.adb b/src/synth/synth-environment.adb
index 5270c3c0e..d6bb29883 100644
--- a/src/synth/synth-environment.adb
+++ b/src/synth/synth-environment.adb
@@ -1239,6 +1239,51 @@ package body Synth.Environment is
end loop;
end Extract_Merge_Partial_Assigns;
+ function Is_Assign_Value_Array_Static
+ (Wid : Wire_Id; Arr : Seq_Assign_Value_Array) return Memtyp
+ is
+ Res : Memtyp;
+ Prev_Val : Memtyp;
+ begin
+ Prev_Val := Null_Memtyp;
+ for I in Arr'Range loop
+ case Arr (I).Is_Static is
+ when False =>
+ -- A value is not static.
+ return Null_Memtyp;
+ when Unknown =>
+ if Prev_Val = Null_Memtyp then
+ -- First use of previous value.
+ if not Is_Static_Wire (Wid) then
+ -- The previous value is not static.
+ return Null_Memtyp;
+ end if;
+ Prev_Val := Get_Static_Wire (Wid);
+ if Res /= Null_Memtyp then
+ -- There is already a result.
+ if not Is_Equal (Res, Prev_Val) then
+ -- The previous value is different from the result.
+ return Null_Memtyp;
+ else
+ Res := Prev_Val;
+ end if;
+ end if;
+ end if;
+ when True =>
+ if Res = Null_Memtyp then
+ -- First value. Keep it.
+ Res := Arr (I).Val;
+ else
+ if not Is_Equal (Res, Arr (I).Val) then
+ -- Value is different.
+ return Null_Memtyp;
+ end if;
+ end if;
+ end case;
+ end loop;
+ return Res;
+ end Is_Assign_Value_Array_Static;
+
procedure Partial_Assign_Init (List : out Partial_Assign_List) is
begin
List := (First | Last => No_Partial_Assign);
@@ -1365,30 +1410,6 @@ package body Synth.Environment is
Merge_Partial_Assigns (Ctxt, W, List);
end Merge_Assigns;
- -- Force the value of a Seq_Assign to be a net if needed, return it.
- function Get_Assign_Value_Force (Val : Seq_Assign_Value)
- return Partial_Assign
- is
- N : Net;
- begin
- case Val.Is_Static is
- when Unknown =>
- return No_Partial_Assign;
- when True =>
- N := Synth.Context.Get_Memtyp_Net (Val.Val);
- return New_Partial_Assign (N, 0);
- when False =>
- return Val.Asgns;
- end case;
- end Get_Assign_Value_Force;
-
- -- Force the value of a Seq_Assign to be a net if needed, return it.
- function Get_Assign_Partial_Force (Asgn : Seq_Assign)
- return Partial_Assign is
- begin
- return Get_Assign_Value_Force (Get_Seq_Assign_Value (Asgn));
- end Get_Assign_Partial_Force;
-
function Merge_Static_Assigns (Wid : Wire_Id; Tv, Fv : Seq_Assign_Value)
return Boolean
is