From 48b186576eab101cd6a2e6f8c04525d36d738627 Mon Sep 17 00:00:00 2001 From: Cary R Date: Wed, 6 Feb 2013 12:36:54 -0800 Subject: [PATCH] Report in SV that Icarus cannot currently call a function like a task. SystemVerilog allows a function to be called without an assignment for the return value. This patch adds a warning that Icarus does not currently support this and provides a place to add this functionality later. --- Statement.h | 3 ++- elaborate.cc | 28 +++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/Statement.h b/Statement.h index 87b747222..0a260dda0 100644 --- a/Statement.h +++ b/Statement.h @@ -1,7 +1,7 @@ #ifndef __Statement_H #define __Statement_H /* - * Copyright (c) 1998-2008,2012 Stephen Williams (steve@icarus.com) + * Copyright (c) 1998-2013 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -212,6 +212,7 @@ class PCallTask : public Statement { NetProc* elaborate_usr(Design*des, NetScope*scope) const; NetProc*elaborate_method_(Design*des, NetScope*scope) const; + NetProc*elaborate_function_(Design*des, NetScope*scope) const; pform_name_t path_; vector parms_; diff --git a/elaborate.cc b/elaborate.cc index b2336664d..7968e9b47 100644 --- a/elaborate.cc +++ b/elaborate.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998-2012 Stephen Williams (steve@icarus.com) + * Copyright (c) 1998-2013 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -3059,9 +3059,14 @@ NetProc* PCallTask::elaborate_usr(Design*des, NetScope*scope) const NetScope*task = des->find_task(scope, path_); if (task == 0) { - // Maybe this is a method attached to a signal? + // For SystemVerilog this may be a few other things. if (gn_system_verilog()) { - NetProc*tmp = elaborate_method_(des, scope); + NetProc *tmp; + // This could be a method attached to a signal? + tmp = elaborate_method_(des, scope); + if (tmp) return tmp; + // Or it could be a function call ignoring the return? + tmp = elaborate_function_(des, scope); if (tmp) return tmp; } @@ -3258,6 +3263,9 @@ NetProc* PCallTask::elaborate_method_(Design*des, NetScope*scope) const NetEvent *eve; const NetExpr *ex1, *ex2; + // There is no signal to search for so this cannot be a method. + if (use_path.empty()) return 0; + symbol_search(this, des, scope, use_path, net, par, eve, ex1, ex2); @@ -3280,6 +3288,20 @@ NetProc* PCallTask::elaborate_method_(Design*des, NetScope*scope) const return 0; } +NetProc* PCallTask::elaborate_function_(Design*des, NetScope*scope) const +{ + NetFuncDef*func = des->find_function(scope, path_); + // This is not a function, so this task call cannot be a function + // call with a missing return assignment. + if (! func) return 0; + +// HERE: Should this be an assign to a dummy variable or something else? + cerr << get_fileline() << ": sorry: Icarus cannot currently call " + "functions like a tasks." << endl; + des->errors += 1; + return 0; +} + /* * Elaborate a procedural continuous assign. This really looks very * much like other procedural assignments, at this point, but there