From bbc80a84a6cf6137133050b5ffd6fe4a8a5bacaf Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Sat, 3 May 2008 18:29:52 -0700 Subject: [PATCH] Rename $log to $log10. Verilog-2005 defines the base-10 log function to be $log10. This makes sense because in C the log() function is the natural log. So add the $log10 function. Since there may be legacy code that uses the $log function, leave it defined, but we should consider at least printing a warning when the $log function is used. --- parse.y | 2 +- vpi/va_math.c | 7 ++++++- vpi/va_math.sft | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/parse.y b/parse.y index 9cce0a80f..b596dfbea 100644 --- a/parse.y +++ b/parse.y @@ -1206,7 +1206,7 @@ expr_primary } | K_log '(' expression ')' - { perm_string tn = perm_string::literal("$log"); + { perm_string tn = perm_string::literal("$log10"); PECallFunction*tmp = make_call_function(tn, $3); FILE_NAME(tmp,@1); $$ = tmp; diff --git a/vpi/va_math.c b/vpi/va_math.c index 602d4a1e7..a5cb115d3 100644 --- a/vpi/va_math.c +++ b/vpi/va_math.c @@ -68,7 +68,12 @@ typedef struct s_single_data { static t_single_data va_single_data[]= { {"$sqrt", sqrt}, {"$ln", log}, - {"$log", log10}, + {"$log", log10}, /* FIXME: The $log function is replaced by the + $log10 function to eliminate confusion with + the natural log. In C, "log" is ln and log10 + is log-base-10. The $log is being left in for + compatibility. */ + {"$log10", log10}, {"$exp", exp}, {"$abs", fabs}, {"$ceil", ceil}, diff --git a/vpi/va_math.sft b/vpi/va_math.sft index 3d85358a8..0c3b78e47 100644 --- a/vpi/va_math.sft +++ b/vpi/va_math.sft @@ -7,6 +7,7 @@ $sqrt vpiSysFuncReal $ln vpiSysFuncReal $log vpiSysFuncReal +$log10 vpiSysFuncReal $exp vpiSysFuncReal $abs vpiSysFuncReal $ceil vpiSysFuncReal