Utils.pm log helper function returns NaN for newer versions of Perl.
Caustic opened this issue · 1 comments
Caustic commented
I'm using Perl 5.14 and when I first used the register gen script, I noticed a lot of registers were valued NaN
. I did some digging and figured out that the log function was returning NaN
when a Math::BigInt
was passed into it.
I know you primarily support specific versions of software for NetFPGA development, but I thought maybe it would be of some use to someone if I posted it here.
Here's how I fixed it:
diff --git a/lib/Perl5/NF/Utils.pm b/lib/Perl5/NF/Utils.pm
index 8a77a7c..c19fcaf 100644
--- a/lib/Perl5/NF/Utils.pm
+++ b/lib/Perl5/NF/Utils.pm
@@ -30,7 +30,11 @@ sub log2 {
my $n = shift;
my $ret;
- eval { $ret = log($n) / log(2); };
+ if (ref($n) eq 'Math::BigInt') {
+ eval { $ret = $n->blog(2, 100); };
+ } else {
+ eval { $ret = log($n) / log(2); };
+ }
if ($@ ne '') {
my $err = $@;
chomp($err);
manihatn commented
Sure thanks.