aboutsummaryrefslogtreecommitdiffstats
path: root/src/synth/netlists-utils.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-12-31 18:55:44 +0100
committerTristan Gingold <tgingold@free.fr>2019-12-31 18:57:44 +0100
commit3485a2054df425a54796ce69f28d19b6eea2b868 (patch)
tree58293caff9f2426c061cd621432cc56fa9ecabd4 /src/synth/netlists-utils.adb
parent03e71f74ace9dbd543435b5f94df87b83bb7d54f (diff)
downloadghdl-3485a2054df425a54796ce69f28d19b6eea2b868.tar.gz
ghdl-3485a2054df425a54796ce69f28d19b6eea2b868.tar.bz2
ghdl-3485a2054df425a54796ce69f28d19b6eea2b868.zip
synth-environment: also optimize mux merge for sub-nets.
Diffstat (limited to 'src/synth/netlists-utils.adb')
-rw-r--r--src/synth/netlists-utils.adb28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/synth/netlists-utils.adb b/src/synth/netlists-utils.adb
index 4a189b39e..59eb086d5 100644
--- a/src/synth/netlists-utils.adb
+++ b/src/synth/netlists-utils.adb
@@ -230,6 +230,34 @@ package body Netlists.Utils is
Free_Instance (Inst);
end Disconnect_And_Free;
+ function Same_Net (L, R : Net) return Boolean
+ is
+ Linst : Instance;
+ Rinst : Instance;
+ begin
+ if L = R then
+ -- Obvious case.
+ return True;
+ end if;
+
+ if Get_Width (L) /= Get_Width (R) then
+ -- Must have the same width.
+ return False;
+ end if;
+
+ -- Handle extract.
+ Linst := Get_Net_Parent (L);
+ if Get_Id (Linst) /= Id_Extract then
+ return False;
+ end if;
+ Rinst := Get_Net_Parent (R);
+ if Get_Id (Rinst) /= Id_Extract then
+ return False;
+ end if;
+ return Get_Input_Net (Linst, 0) = Get_Input_Net (Rinst, 0)
+ and then Get_Param_Uns32 (Linst, 0) = Get_Param_Uns32 (Rinst, 0);
+ end Same_Net;
+
function Clog2 (W : Width) return Width is
begin
return Uns32 (Mutils.Clog2 (Uns64 (W)));