aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2019-11-03 21:14:08 +0100
committerTristan Gingold <tgingold@free.fr>2019-11-03 21:15:09 +0100
commitd9399f72340009974a8bf6d8ea4db86f2067eed5 (patch)
tree7f9f5ea7ade13d8ea78ad10e659a9bc8aaf8de4d
parent916c0a1e8e765a77863ca984bef1d7c0be77edc0 (diff)
downloadghdl-d9399f72340009974a8bf6d8ea4db86f2067eed5.tar.gz
ghdl-d9399f72340009974a8bf6d8ea4db86f2067eed5.tar.bz2
ghdl-d9399f72340009974a8bf6d8ea4db86f2067eed5.zip
netlists-utils: add clog2
-rw-r--r--src/synth/netlists-utils.adb6
-rw-r--r--src/synth/netlists-utils.ads2
2 files changed, 8 insertions, 0 deletions
diff --git a/src/synth/netlists-utils.adb b/src/synth/netlists-utils.adb
index d5a1f2edd..7d9d71f5b 100644
--- a/src/synth/netlists-utils.adb
+++ b/src/synth/netlists-utils.adb
@@ -19,6 +19,7 @@
-- MA 02110-1301, USA.
with Netlists.Gates; use Netlists.Gates;
+with Mutils;
package body Netlists.Utils is
function Get_Nbr_Inputs (Inst : Instance) return Port_Nbr
@@ -175,4 +176,9 @@ package body Netlists.Utils is
-- Free Inst
Free_Instance (Inst);
end Disconnect_And_Free;
+
+ function Clog2 (W : Width) return Width is
+ begin
+ return Uns32 (Mutils.Clog2 (Uns64 (W)));
+ end Clog2;
end Netlists.Utils;
diff --git a/src/synth/netlists-utils.ads b/src/synth/netlists-utils.ads
index 1026bedc2..e8565c823 100644
--- a/src/synth/netlists-utils.ads
+++ b/src/synth/netlists-utils.ads
@@ -55,4 +55,6 @@ package Netlists.Utils is
-- Disconnect input I. If the driver of I has no output(s) connected,
-- disconnect and free it.
procedure Disconnect_And_Free (I : Input);
+
+ function Clog2 (W : Width) return Width;
end Netlists.Utils;