From b7b77b2e75ec5726769def1c95489f316f50d82c Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Tue, 20 May 2014 00:08:03 +0100 Subject: [PATCH 1/4] Correct fix for GitHub issue 19. --- vvp/vvp_net.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/vvp/vvp_net.cc b/vvp/vvp_net.cc index aaf8f0203..0c29fa4b6 100644 --- a/vvp/vvp_net.cc +++ b/vvp/vvp_net.cc @@ -1713,8 +1713,10 @@ template bool vector4_to_value(const vvp_vector4_t&vec, T&val) break; case BIT4_1: // On overflow, return the maximum value of type T - if (msk == 0) return ~msk; - res |= msk; + if (msk == 0) + res = ~msk; + else + res |= msk; break; default: return false; From 6547fdee3dd03ceca07af9817f506213528b03ee Mon Sep 17 00:00:00 2001 From: Cary R Date: Wed, 21 May 2014 09:00:47 -0700 Subject: [PATCH 2/4] vlog95: for cppcheck the target functions are used by the compiler. --- tgt-vlog95/Makefile.in | 3 ++- tgt-vlog95/cppcheck.sup | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 tgt-vlog95/cppcheck.sup diff --git a/tgt-vlog95/Makefile.in b/tgt-vlog95/Makefile.in index 19428f2e9..69a57b618 100644 --- a/tgt-vlog95/Makefile.in +++ b/tgt-vlog95/Makefile.in @@ -56,7 +56,8 @@ distclean: clean rm -f Makefile config.log cppcheck: $(O:.o=.c) - cppcheck --enable=all -f $(INCLUDE_PATH) $^ + cppcheck --enable=all -f --suppressions-list=$(srcdir)/cppcheck.sup \ + --relative-paths=$(srcdir) $(INCLUDE_PATH) $^ Makefile: $(srcdir)/Makefile.in ../config.status cd ..; ./config.status --file=tgt-vlog95/$@ diff --git a/tgt-vlog95/cppcheck.sup b/tgt-vlog95/cppcheck.sup new file mode 100644 index 000000000..f1a757bf9 --- /dev/null +++ b/tgt-vlog95/cppcheck.sup @@ -0,0 +1,8 @@ +// These are the global access functions called from the compiler so they +// are not used here. + +// target_design() +unusedFunction:vlog95.c:59 + +// target_query() +unusedFunction:vlog95.c:226 From d96e8872c1ac5fca5a4c8df871bfee9525672268 Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Fri, 23 May 2014 21:55:46 +0100 Subject: [PATCH 3/4] Fix for GitHub issue 25 - compiler crash when function declared outside module. This is an error in traditional Verilog and a unsupported feature in SystemVerilog. Fail gracefully with a suitable error/sorry message. Do the same for task declarations. --- pform.cc | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/pform.cc b/pform.cc index b8a408b86..7b899b688 100644 --- a/pform.cc +++ b/pform.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998-2013 Stephen Williams (steve@icarus.com) + * Copyright (c) 1998-2014 Stephen Williams (steve@icarus.com) * Copyright CERN 2013 / Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it @@ -344,7 +344,16 @@ PTask* pform_push_task_scope(const struct vlltype&loc, char*name, bool is_auto) FILE_NAME(task, loc); PScopeExtra*scopex = find_nearest_scopex(lexical_scope); - assert(scopex); + if ((scopex == 0) && (generation_flag < GN_VER2005_SV)) { + cerr << task->get_fileline() << ": error: task declarations " + "must be contained within a module." << endl; + error_count += 1; + } + if ((scopex == 0) && (generation_flag >= GN_VER2005_SV)) { + cerr << task->get_fileline() << ": sorry: task declarations " + "in the compilation unit scope are not yet supported." << endl; + error_count += 1; + } if (pform_cur_generate) { // Check if the task is already in the dictionary. @@ -357,7 +366,7 @@ PTask* pform_push_task_scope(const struct vlltype&loc, char*name, bool is_auto) error_count += 1; } pform_cur_generate->tasks[task->pscope_name()] = task; - } else { + } else if (scopex) { // Check if the task is already in the dictionary. if (scopex->tasks.find(task->pscope_name()) != scopex->tasks.end()) { cerr << task->get_fileline() << ": error: duplicate " @@ -381,13 +390,17 @@ PFunction* pform_push_function_scope(const struct vlltype&loc, const char*name, PFunction*func = new PFunction(func_name, lexical_scope, is_auto); FILE_NAME(func, loc); - LexicalScope*scope = lexical_scope; - PScopeExtra*scopex = dynamic_cast (scope); - while (scope && !scopex) { - scope = scope->parent_scope(); - scopex = dynamic_cast (scope); + PScopeExtra*scopex = find_nearest_scopex(lexical_scope); + if ((scopex == 0) && (generation_flag < GN_VER2005_SV)) { + cerr << func->get_fileline() << ": error: function declarations " + "must be contained within a module." << endl; + error_count += 1; + } + if ((scopex == 0) && (generation_flag >= GN_VER2005_SV)) { + cerr << func->get_fileline() << ": sorry: function declarations " + "in the compilation unit scope are not yet supported." << endl; + error_count += 1; } - assert(scopex); if (pform_cur_generate) { // Check if the function is already in the dictionary. @@ -400,7 +413,7 @@ PFunction* pform_push_function_scope(const struct vlltype&loc, const char*name, error_count += 1; } pform_cur_generate->funcs[func->pscope_name()] = func; - } else { + } else if (scopex != 0) { // Check if the function is already in the dictionary. if (scopex->funcs.find(func->pscope_name()) != scopex->funcs.end()) { cerr << func->get_fileline() << ": error: duplicate " From d05abf5ca4c93f0f386c86af19c6e1b494fa84ed Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Fri, 23 May 2014 22:36:28 +0100 Subject: [PATCH 4/4] Fix for GitHub issue 26 - compiler crash when module port has no internal net. The compiler correctly reports an error when a module port has no associated internal net/reg, but could crash when the module was instantiated. --- elaborate.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/elaborate.cc b/elaborate.cc index be406747e..783840a81 100644 --- a/elaborate.cc +++ b/elaborate.cc @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998-2013 Stephen Williams (steve@icarus.com) + * Copyright (c) 1998-2014 Stephen Williams (steve@icarus.com) * Copyright CERN 2013 / Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it @@ -1307,6 +1307,10 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, NetScope*scope) const perm_string pname = peek_tail_name(mport[0]->path()); NetNet*tmp = instance[0]->find_signal(pname); + + // Handle the error case where there is no internal + // signal connected to the port. + if (!tmp) continue; assert(tmp); if (tmp->port_type() == NetNet::PINPUT) {