cppcheck updates

This commit is contained in:
Cary R 2025-11-23 01:28:22 -08:00
parent 1c6f0e768a
commit d87dbb08cf
63 changed files with 491 additions and 503 deletions

View File

@ -382,13 +382,11 @@ PEIdent::~PEIdent()
static bool find_enum_constant(LexicalScope*scope, perm_string name)
{
for (vector<enum_type_t*>::const_iterator cur = scope->enum_sets.begin() ;
cur != scope->enum_sets.end() ; ++ cur) {
for (list<named_pexpr_t>::const_iterator idx = (*cur)->names->begin() ;
idx != (*cur)->names->end() ; ++ idx) {
if (idx->name == name) return true;
}
}
std::any_of(scope->enum_sets.cbegin(), scope->enum_sets.cend(),
[name](const enum_type_t *cur) {
return std::any_of(cur->names->cbegin(), cur->names->cend(),
[name](const named_pexpr_t idx){return idx.name == name;});
});
return false;
}

View File

@ -131,7 +131,6 @@ class PGAssign : public PGate {
void dump(std::ostream&out, unsigned ind =4) const override;
virtual void elaborate(Design*des, NetScope*scope) const override;
virtual bool elaborate_sig(Design*des, NetScope*scope) const override;
private:
void elaborate_unpacked_array_(Design*des, NetScope*scope, NetNet*lval) const;
@ -170,7 +169,6 @@ class PGBuiltin : public PGate {
virtual void dump(std::ostream&out, unsigned ind =4) const override;
virtual void elaborate(Design*, NetScope*scope) const override;
virtual bool elaborate_sig(Design*des, NetScope*scope) const override;
private:
void calculate_gate_and_lval_count_(unsigned&gate_count,

View File

@ -28,11 +28,6 @@ bool NetAssign::is_asynchronous()
return true;
}
bool NetCondit::is_asynchronous()
{
return false;
}
/*
* NetEvWait statements come from statements of the form @(...) in the
* Verilog source. These event waits are considered asynchronous if

View File

@ -1,11 +1,17 @@
// These are correct and are used to find the base (zero) pin.
thisSubtraction:netlist.h:5311
thisSubtraction:netlist.h:5320
thisSubtraction:netlist.h:5310
thisSubtraction:netlist.h:5319
// This is used when running a debugger
// debugger_release
knownConditionTrueFalse:main.cc:931
// Yes, it's a duplicate
duplicateCondition:elaborate.cc:7672
// To complicated to use std::find_if()
useStlAlgorithm:map_named_args.cc:38
// This are just stubs
// vpi_control()
unusedFunction:vpi_modules.cc:109
@ -685,9 +691,15 @@ unusedFunction:t-dll.cc:2368
// is_before()
unusedFunction:verinum.cc:592
// Errors in the generated yacc and lex files
// Errors/limitations in the generated yacc and lex files
constVariablePointer:<stdout>
cstyleCast:<stdout>
nullPointer:<stdout>
redundantInitialization:<stdout>
syntaxError:<stdout>
unusedFunction:<stdout>
duplicateBreak:lexor.lex
allocaCalled:parse.cc
syntaxError:parse.cc
allocaCalled:syn-rules.cc
constVariablePointer:syn-rules.cc

View File

@ -403,7 +403,7 @@ NetExpr* PEAssignPattern::elaborate_expr_packed_(Design *des, NetScope *scope,
width /= dims[cur_dim].width();
cur_dim++;
NetEConcat *concat = new NetEConcat(parms_.size(), 1, base_type);
NetEConcat *neconcat = new NetEConcat(parms_.size(), 1, base_type);
for (size_t idx = 0; idx < parms_.size(); idx++) {
NetExpr *expr;
// Handle nested assignment patterns as a special case. We do not
@ -419,10 +419,10 @@ NetExpr* PEAssignPattern::elaborate_expr_packed_(Design *des, NetScope *scope,
base_type, width,
parms_[idx], need_const);
if (expr)
concat->set(idx, expr);
neconcat->set(idx, expr);
}
return concat;
return neconcat;
}
NetExpr* PEAssignPattern::elaborate_expr_struct_(Design *des, NetScope *scope,
@ -439,17 +439,16 @@ NetExpr* PEAssignPattern::elaborate_expr_struct_(Design *des, NetScope *scope,
des->errors++;
}
NetEConcat *concat = new NetEConcat(parms_.size(), 1,
struct_type->base_type());
NetEConcat *neconcat = new NetEConcat(parms_.size(), 1, struct_type->base_type());
for (size_t idx = 0; idx < std::min(parms_.size(), members.size()); idx++) {
auto expr = elaborate_rval_expr(des, scope,
members[idx].net_type,
parms_[idx], need_const);
if (expr)
concat->set(idx, expr);
neconcat->set(idx, expr);
}
return concat;
return neconcat;
}
NetExpr* PEAssignPattern::elaborate_expr(Design*des, NetScope*, unsigned, unsigned) const
@ -4263,7 +4262,7 @@ ivl_type_t PEIdent::resolve_type_(Design *des, const symbol_search_results &sr,
else
type = sr.type;
auto path = sr.path_tail.cbegin();
auto cpath = sr.path_tail.cbegin();
ivl_assert(*this, !sr.path_head.empty());
@ -4301,12 +4300,12 @@ ivl_type_t PEIdent::resolve_type_(Design *des, const symbol_search_results &sr,
}
}
if (path == sr.path_tail.cend())
if (cpath == sr.path_tail.cend())
return type;
// Next look up the next path element based on name
const auto &name = path->name;
const auto &name = cpath->name;
if (auto class_type = dynamic_cast<const netclass_t*>(type)) {
// If the type is an object, the next path member may be a
@ -4363,8 +4362,8 @@ ivl_type_t PEIdent::resolve_type_(Design *des, const symbol_search_results &sr,
return nullptr;
}
indices = &path->index;
path++;
indices = &cpath->index;
cpath++;
}
return type;

View File

@ -616,8 +616,6 @@ NetNet* PEIdent::elaborate_lnet_common_(Design*des, NetScope*scope,
// array word assignment.
bool widx_flag = false;
list<long> unpacked_indices_const;
// Detect the net is a structure and there was a method path
// detected. We have already broken the path_ into the path to
// the net, and the path of member names. For example, if the
@ -685,6 +683,8 @@ NetNet* PEIdent::elaborate_lnet_common_(Design*des, NetScope*scope,
return 0;
}
use_path.pop_front();
member_off += tmp_off;
member_width = member->net_type->packed_width();
@ -692,9 +692,8 @@ NetNet* PEIdent::elaborate_lnet_common_(Design*des, NetScope*scope,
struct_type = tmp_struct;
} else {
struct_type = 0;
assert (use_path.empty());
}
use_path.pop_front();
}
// Look for part selects on the final member. For example if
@ -772,6 +771,8 @@ NetNet* PEIdent::elaborate_lnet_common_(Design*des, NetScope*scope,
} else if (sig->unpacked_dimensions() > 0) {
list<long> unpacked_indices_const;
// Make sure there are enough indices to address an array element.
if (path_tail.index.size() < sig->unpacked_dimensions()) {
cerr << get_fileline() << ": error: Array " << path()

View File

@ -449,16 +449,6 @@ bool PGate::elaborate_sig(Design*, NetScope*) const
return true;
}
bool PGBuiltin::elaborate_sig(Design*, NetScope*) const
{
return true;
}
bool PGAssign::elaborate_sig(Design*, NetScope*) const
{
return true;
}
bool PGModule::elaborate_sig_mod_(Design*des, NetScope*scope,
const Module*rmod) const
{

View File

@ -1139,12 +1139,9 @@ NetNet*PGModule::resize_net_to_port_(Design*des, NetScope*scope,
static bool need_bufz_for_input_port(const vector<NetNet*>&prts)
{
if (prts[0]->port_type() != NetNet::PINPUT)
return false;
if (prts[0]->pin(0).nexus()->drivers_present())
return true;
if (prts.empty()) return false;
if (prts[0]->port_type() != NetNet::PINPUT) return false;
if (prts[0]->pin(0).nexus()->drivers_present()) return true;
return false;
}
@ -1573,7 +1570,7 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, NetScope*scope) const
// array, then there should be no sub-ports and
// the r-value expression is processed
// differently.
if (prts.size() >= 1 && prts[0]->unpacked_dimensions() > 0) {
if (!prts.empty() && prts[0]->unpacked_dimensions() > 0) {
ivl_assert(*this, prts.size()==1);
elaborate_unpacked_port(des, scope, prts[0], pins[idx],
ptype, rmod, idx);
@ -1681,7 +1678,7 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, NetScope*scope) const
if ((sig->data_type() == IVL_VT_REAL ) &&
!prts.empty() && (prts[0]->data_type() != IVL_VT_REAL )) {
sig = cast_to_int4(des, scope, sig,
prts_vector_width/instance.size());
prts_vector_width/instance.size());
}
// If we have a bit/vector signal driving a real port
// then we convert the value to a real.
@ -1983,7 +1980,6 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, NetScope*scope) const
// to the port from the outside, and the prts object is
// an array of signals to be connected to the sig.
NetConcat*ctmp;
if (prts.size() == 1) {
@ -2027,6 +2023,7 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, NetScope*scope) const
} else switch (ptype) {
case NetNet::POUTPUT:
NetConcat*ctmp;
ctmp = new NetConcat(scope, scope->local_symbol(),
prts_vector_width, prts.size());
ctmp->set_line(*this);

View File

@ -23,8 +23,9 @@
# include <cstring>
# include <cassert>
#ifdef CHECK_WITH_VALGRIND
# include "ivl_alloc.h"
#ifdef CHECK_WITH_VALGRIND
static char **string_pool = NULL;
static unsigned string_pool_count = 0;
#endif
@ -71,7 +72,7 @@ const char* StringHeap::add(const char*text)
// realloc shrink of the memory region will return the
// same pointer.
if (rem > 0) {
char*old = cell_base_;
const char*old = cell_base_;
cell_base_ = static_cast<char*>(realloc(cell_base_, cell_ptr_));
assert(cell_base_ != 0);
assert(cell_base_ == old);

View File

@ -3238,7 +3238,6 @@ class NetCondit : public NetProc {
bool nested_func = false) const override;
virtual void nex_output(NexusSet&o) override;
bool is_asynchronous() override;
bool synth_async(Design*des, NetScope*scope,
NexusSet&nex_map, NetBus&nex_out,
NetBus&enables, std::vector<mask_t>&bitmasks) override;

View File

@ -339,7 +339,8 @@ bool NetAssignBase::synth_async(Design*des, NetScope*scope,
lval_->more = 0;
if (!synth_async(des, scope, nex_map, nex_out, enables, bitmasks))
flag = false;
lval_ = lval_->more = more;
lval_->more = more;
lval_ = lval_->more;
offset += width;
}
lval_ = full_lval;

View File

@ -115,11 +115,9 @@ bool dll_target::func_def(const NetScope*net)
stmt_cur_ = 0;
scop->ports = def->port_count() + 1;
if (scop->ports > 0) {
scop->u_.port = new ivl_signal_t[scop->ports];
for (unsigned idx = 1 ; idx < scop->ports ; idx += 1)
scop->u_.port[idx] = find_signal(des_, def->port(idx-1));
}
scop->u_.port = new ivl_signal_t[scop->ports];
for (unsigned idx = 1 ; idx < scop->ports ; idx += 1)
scop->u_.port[idx] = find_signal(des_, def->port(idx-1));
/* FIXME: the ivl_target API expects port-0 to be the output
port. This assumes that the return value is a signal, which

View File

@ -838,10 +838,10 @@ ostream& operator<< (ostream&o, const verinum&v)
return o;
}
verinum::V trim_left = v.get(v.len()-1);
unsigned idx;
if (v.has_sign()) {
verinum::V trim_left = v.get(v.len()-1);
for (idx = v.len()-1; idx > 0; idx -= 1)
if (trim_left != v.get(idx-1))
break;

View File

@ -374,3 +374,11 @@ variableScope:sys_random.c:47
variableScope:sys_random.c:70
variableScope:sys_random.c:93
variableScope:sys_random.c:148
// Issues in Lex/Yacc files
allocaCalled:sdf_parse.c
allocaCalled:table_mod_parse.c
constVariablePointer:<stdout>
duplicateBreak:<stdout>
nullPointer:<stdout>
redundantInitialization:<stdout>

View File

@ -55,7 +55,7 @@ class vvp_arith_ : public vvp_net_fun_t {
class vvp_arith_abs : public vvp_net_fun_t {
public:
explicit vvp_arith_abs();
~vvp_arith_abs();
~vvp_arith_abs() override;
void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit,
vvp_context_t) override;
@ -71,7 +71,7 @@ class vvp_arith_abs : public vvp_net_fun_t {
class vvp_arith_cast_int : public vvp_net_fun_t {
public:
explicit vvp_arith_cast_int(unsigned wid);
~vvp_arith_cast_int();
~vvp_arith_cast_int() override;
void recv_real(vvp_net_ptr_t ptr, double bit,
vvp_context_t) override;
@ -83,7 +83,7 @@ class vvp_arith_cast_int : public vvp_net_fun_t {
class vvp_arith_cast_real : public vvp_net_fun_t {
public:
explicit vvp_arith_cast_real(bool signed_flag);
~vvp_arith_cast_real();
~vvp_arith_cast_real() override;
void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit,
vvp_context_t) override;
@ -98,7 +98,7 @@ class vvp_arith_cast_real : public vvp_net_fun_t {
class vvp_arith_cast_vec2 : public vvp_net_fun_t {
public:
explicit vvp_arith_cast_vec2(unsigned wid);
~vvp_arith_cast_vec2();
~vvp_arith_cast_vec2() override;
void recv_real(vvp_net_ptr_t ptr, double bit,
vvp_context_t) override;
@ -116,7 +116,7 @@ class vvp_arith_div : public vvp_arith_ {
public:
explicit vvp_arith_div(unsigned wid, bool signed_flag);
~vvp_arith_div();
~vvp_arith_div() override;
void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit,
vvp_context_t) override;
private:
@ -128,7 +128,7 @@ class vvp_arith_mod : public vvp_arith_ {
public:
explicit vvp_arith_mod(unsigned wid, bool signed_flag);
~vvp_arith_mod();
~vvp_arith_mod() override;
void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit,
vvp_context_t) override;
private:
@ -260,7 +260,7 @@ class vvp_arith_mult : public vvp_arith_ {
public:
explicit vvp_arith_mult(unsigned wid);
~vvp_arith_mult();
~vvp_arith_mult() override;
void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit,
vvp_context_t) override;
private:
@ -271,7 +271,7 @@ class vvp_arith_pow : public vvp_arith_ {
public:
explicit vvp_arith_pow(unsigned wid, bool signed_flag);
~vvp_arith_pow();
~vvp_arith_pow() override;
void recv_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&bit,
vvp_context_t) override;
private:
@ -282,7 +282,7 @@ class vvp_arith_sub : public vvp_arith_ {
public:
explicit vvp_arith_sub(unsigned wid);
~vvp_arith_sub();
~vvp_arith_sub() override;
virtual void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
vvp_context_t) override;
@ -292,7 +292,7 @@ class vvp_arith_sum : public vvp_arith_ {
public:
explicit vvp_arith_sum(unsigned wid);
~vvp_arith_sum();
~vvp_arith_sum() override;
virtual void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
vvp_context_t) override;
@ -302,7 +302,7 @@ class vvp_shiftl : public vvp_arith_ {
public:
explicit vvp_shiftl(unsigned wid);
~vvp_shiftl();
~vvp_shiftl() override;
virtual void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
vvp_context_t) override;
};
@ -311,7 +311,7 @@ class vvp_shiftr : public vvp_arith_ {
public:
explicit vvp_shiftr(unsigned wid, bool signed_flag);
~vvp_shiftr();
~vvp_shiftr() override;
virtual void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
vvp_context_t) override;
@ -342,7 +342,7 @@ class vvp_arith_sum_real : public vvp_arith_real_ {
public:
explicit vvp_arith_sum_real();
~vvp_arith_sum_real();
~vvp_arith_sum_real() override;
void recv_real(vvp_net_ptr_t ptr, double bit,
vvp_context_t) override;
};
@ -351,7 +351,7 @@ class vvp_arith_div_real : public vvp_arith_real_ {
public:
explicit vvp_arith_div_real();
~vvp_arith_div_real();
~vvp_arith_div_real() override;
void recv_real(vvp_net_ptr_t ptr, double bit,
vvp_context_t) override;
};
@ -360,7 +360,7 @@ class vvp_arith_mod_real : public vvp_arith_real_ {
public:
explicit vvp_arith_mod_real();
~vvp_arith_mod_real();
~vvp_arith_mod_real() override;
void recv_real(vvp_net_ptr_t ptr, double bit,
vvp_context_t) override;
};
@ -369,7 +369,7 @@ class vvp_arith_mult_real : public vvp_arith_real_ {
public:
explicit vvp_arith_mult_real();
~vvp_arith_mult_real();
~vvp_arith_mult_real() override;
void recv_real(vvp_net_ptr_t ptr, double bit,
vvp_context_t) override;
};
@ -378,7 +378,7 @@ class vvp_arith_pow_real : public vvp_arith_real_ {
public:
explicit vvp_arith_pow_real();
~vvp_arith_pow_real();
~vvp_arith_pow_real() override;
void recv_real(vvp_net_ptr_t ptr, double bit,
vvp_context_t) override;
};
@ -387,7 +387,7 @@ class vvp_arith_sub_real : public vvp_arith_real_ {
public:
explicit vvp_arith_sub_real();
~vvp_arith_sub_real();
~vvp_arith_sub_real() override;
void recv_real(vvp_net_ptr_t ptr, double bit,
vvp_context_t) override;
};

View File

@ -134,7 +134,7 @@ static bool vpi_array_is_real(const vvp_array_t arr)
// This must be a net array so look at element 0 to find the type.
assert(arr->nets != 0);
assert(arr->get_size() > 0);
struct __vpiRealVar*rsig = dynamic_cast<__vpiRealVar*>(arr->nets[0]);
const struct __vpiRealVar*rsig = dynamic_cast<__vpiRealVar*>(arr->nets[0]);
if (rsig) {
return true;
}
@ -787,9 +787,9 @@ string __vpiArray::get_word_str(unsigned address)
return "";
}
vpiHandle vpip_make_array(char*label, const char*name,
int first_addr, int last_addr,
bool signed_flag)
vpiHandle vpip_make_array(const char*label, const char*name,
int first_addr, int last_addr,
bool signed_flag)
{
struct __vpiArray*obj = new __vpiArray;
@ -1014,7 +1014,7 @@ void compile_net_array(char*label, char*name, int last, int first)
vpiHandle obj = vpip_make_array(label, name, first, last, false);
struct __vpiArray*arr = dynamic_cast<__vpiArray*>(obj);
arr->nets = (vpiHandle*)calloc(arr->get_size(), sizeof(vpiHandle));
arr->nets = static_cast<vpiHandle*>(calloc(arr->get_size(), sizeof(vpiHandle)));
count_net_arrays += 1;
count_net_array_words += arr->get_size();
@ -1028,7 +1028,7 @@ class vvp_fun_arrayport : public vvp_net_fun_t {
public:
explicit vvp_fun_arrayport(vvp_array_t mem, vvp_net_t*net);
explicit vvp_fun_arrayport(vvp_array_t mem, vvp_net_t*net, long addr);
~vvp_fun_arrayport();
~vvp_fun_arrayport() override;
virtual void check_word_change(unsigned long addr) = 0;
@ -1063,7 +1063,7 @@ class vvp_fun_arrayport_sa : public vvp_fun_arrayport {
public:
explicit vvp_fun_arrayport_sa(vvp_array_t mem, vvp_net_t*net);
explicit vvp_fun_arrayport_sa(vvp_array_t mem, vvp_net_t*net, long addr);
~vvp_fun_arrayport_sa();
~vvp_fun_arrayport_sa() override;
void check_word_change(unsigned long addr) override;
@ -1127,7 +1127,7 @@ class vvp_fun_arrayport_aa : public vvp_fun_arrayport, public automatic_hooks_s
public:
explicit vvp_fun_arrayport_aa(__vpiScope*context_scope, vvp_array_t mem, vvp_net_t*net);
explicit vvp_fun_arrayport_aa(__vpiScope*context_scope, vvp_array_t mem, vvp_net_t*net, long addr);
~vvp_fun_arrayport_aa();
~vvp_fun_arrayport_aa() override;
void alloc_instance(vvp_context_t context) override;
void reset_instance(vvp_context_t context) override;
@ -1227,7 +1227,7 @@ void vvp_fun_arrayport_aa::recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit
void vvp_fun_arrayport_aa::check_word_change_(unsigned long addr,
vvp_context_t context)
{
unsigned long*port_addr = static_cast<unsigned long*>
const unsigned long*port_addr = static_cast<unsigned long*>
(vvp_get_context_item(context, context_idx_));
if (addr != *port_addr)
@ -1443,7 +1443,7 @@ bool array_port_resolv_list_t::resolve(bool mes)
class array_word_part_callback : public array_word_value_callback {
public:
explicit array_word_part_callback(p_cb_data data);
~array_word_part_callback();
~array_word_part_callback() override;
bool test_value_callback_ready(void) override;
@ -1494,7 +1494,7 @@ value_callback*vpip_array_word_change(p_cb_data data)
{
struct __vpiArray*parent = 0;
array_word_value_callback*cbh = 0;
if (struct __vpiArrayWord*word = array_var_word_from_handle(data->obj)) {
if (const struct __vpiArrayWord*word = array_var_word_from_handle(data->obj)) {
parent = static_cast<__vpiArray*>(word->get_parent());
unsigned addr = word->get_index();
cbh = new array_word_value_callback(data);
@ -1684,7 +1684,7 @@ void compile_array_cleanup(void)
#ifdef CHECK_WITH_VALGRIND
void memory_delete(vpiHandle item)
{
struct __vpiArray*arr = (struct __vpiArray*) item;
struct __vpiArray*arr = static_cast<struct __vpiArray*>(item);
if (arr->vals_words) delete [] (arr->vals_words-1);
// if (arr->vals4) {}
@ -1707,8 +1707,8 @@ void memory_delete(vpiHandle item)
} else {
assert(arr->nets[idx]->get_type_code() ==
vpiRealVar);
struct __vpiRealVar *sigr = (struct __vpiRealVar *)
arr->nets[idx];
struct __vpiRealVar *sigr = static_cast<struct __vpiRealVar *>
(arr->nets[idx]);
constant_delete(sigr->id.index);
// Why are only the real words still here?
delete arr->nets[idx];
@ -1728,7 +1728,7 @@ void memory_delete(vpiHandle item)
void A_delete(vpiHandle item)
{
struct __vpiArrayVthrA*obj = (struct __vpiArrayVthrA*) item;
struct __vpiArrayVthrA*obj = static_cast<struct __vpiArrayVthrA*>(item);
if (obj->address_handle) {
switch (obj->address_handle->get_type_code()) {
case vpiMemoryWord:
@ -1749,7 +1749,7 @@ void A_delete(vpiHandle item)
void APV_delete(vpiHandle item)
{
struct __vpiArrayVthrAPV*obj = (struct __vpiArrayVthrAPV*) item;
struct __vpiArrayVthrAPV*obj = static_cast<struct __vpiArrayVthrAPV*>(item);
delete obj;
}
#endif

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2022 Stephen Williams (steve@icarus.com)
* Copyright (c) 2014-2025 Stephen Williams (steve@icarus.com)
* Copyright (c) 2014 CERN
* @author Maciej Suminski <maciej.suminski@cern.ch>
*
@ -181,23 +181,23 @@ struct __vpiArrayWord*array_var_word_from_handle(vpiHandle ref)
{
if (ref == 0)
return 0;
__vpiArrayWord::as_word_t*ptr = dynamic_cast<__vpiArrayWord::as_word_t*> (ref);
const __vpiArrayWord::as_word_t*ptr = dynamic_cast<__vpiArrayWord::as_word_t*> (ref);
if (ptr == 0)
return 0;
return (struct __vpiArrayWord*) ref;
return (struct __vpiArrayWord*)(ref);
}
struct __vpiArrayWord* array_var_index_from_handle(vpiHandle ref)
{
if (ref == 0)
return 0;
__vpiArrayWord::as_index_t*ptr = dynamic_cast<__vpiArrayWord::as_index_t*> (ref);
const __vpiArrayWord::as_index_t*ptr = dynamic_cast<__vpiArrayWord::as_index_t*> (ref);
if (ptr == 0)
return 0;
assert(sizeof(__vpiHandle) == sizeof(__vpiArrayWord::as_index_t));
assert(sizeof(__vpiHandle) == sizeof(__vpiArrayWord::as_word_t));
return (struct __vpiArrayWord*) (ref-1);
return (struct __vpiArrayWord*)(ref-1);
}

View File

@ -125,7 +125,7 @@ void class_property_t::get_object(char*, vvp_object_t&, uint64_t)
template <class T> class property_atom : public class_property_t {
public:
inline explicit property_atom(void) { }
~property_atom() { }
~property_atom() override { }
size_t instance_size() const override { return sizeof(T); }
@ -144,7 +144,7 @@ template <class T> class property_atom : public class_property_t {
class property_bit : public class_property_t {
public:
explicit inline property_bit(size_t wid): wid_(wid) { }
~property_bit() { }
~property_bit() override { }
size_t instance_size() const override { return sizeof(vvp_vector2_t); }
@ -169,7 +169,7 @@ class property_bit : public class_property_t {
class property_logic : public class_property_t {
public:
explicit inline property_logic(size_t wid): wid_(wid) { }
~property_logic() { }
~property_logic() override { }
size_t instance_size() const override { return sizeof(vvp_vector4_t); }
@ -194,7 +194,7 @@ class property_logic : public class_property_t {
template <class T> class property_real : public class_property_t {
public:
inline explicit property_real(void) { }
~property_real() { }
~property_real() override { }
size_t instance_size() const override { return sizeof(T); }
@ -213,7 +213,7 @@ template <class T> class property_real : public class_property_t {
class property_string : public class_property_t {
public:
inline explicit property_string(void) { }
~property_string() { }
~property_string() override { }
size_t instance_size() const override { return sizeof(std::string); }
@ -235,7 +235,7 @@ class property_string : public class_property_t {
class property_object : public class_property_t {
public:
inline explicit property_object(uint64_t as): array_size_(as==0? 1 : as) { }
~property_object() { }
~property_object() override { }
size_t instance_size() const override { return array_size_ * sizeof(vvp_object_t); }
@ -291,14 +291,14 @@ void property_bit::set_vec4(char*buf, const vvp_vector4_t&val)
void property_bit::get_vec4(char*buf, vvp_vector4_t&val)
{
vvp_vector2_t*obj = reinterpret_cast<vvp_vector2_t*> (buf+offset_);
const vvp_vector2_t*obj = reinterpret_cast<vvp_vector2_t*> (buf+offset_);
val = vector2_to_vector4(*obj, obj->size());
}
void property_bit::copy(char*dst, char*src)
{
vvp_vector2_t*dst_obj = reinterpret_cast<vvp_vector2_t*> (dst+offset_);
vvp_vector2_t*src_obj = reinterpret_cast<vvp_vector2_t*> (src+offset_);
const vvp_vector2_t*src_obj = reinterpret_cast<vvp_vector2_t*> (src+offset_);
*dst_obj = *src_obj;
}
@ -310,14 +310,14 @@ void property_logic::set_vec4(char*buf, const vvp_vector4_t&val)
void property_logic::get_vec4(char*buf, vvp_vector4_t&val)
{
vvp_vector4_t*obj = reinterpret_cast<vvp_vector4_t*> (buf+offset_);
const vvp_vector4_t*obj = reinterpret_cast<vvp_vector4_t*> (buf+offset_);
val = *obj;
}
void property_logic::copy(char*dst, char*src)
{
vvp_vector4_t*dst_obj = reinterpret_cast<vvp_vector4_t*> (dst+offset_);
vvp_vector4_t*src_obj = reinterpret_cast<vvp_vector4_t*> (src+offset_);
const vvp_vector4_t*src_obj = reinterpret_cast<vvp_vector4_t*> (src+offset_);
*dst_obj = *src_obj;
}
@ -348,14 +348,14 @@ void property_string::set_string(char*buf, const string&val)
string property_string::get_string(char*buf)
{
string*tmp = reinterpret_cast<string*>(buf+offset_);
const string*tmp = reinterpret_cast<string*>(buf+offset_);
return *tmp;
}
void property_string::copy(char*dst, char*src)
{
string*dst_obj = reinterpret_cast<string*> (dst+offset_);
string*src_obj = reinterpret_cast<string*> (src+offset_);
const string*src_obj = reinterpret_cast<string*> (src+offset_);
*dst_obj = *src_obj;
}
@ -382,14 +382,14 @@ void property_object::set_object(char*buf, const vvp_object_t&val, uint64_t idx)
void property_object::get_object(char*buf, vvp_object_t&val, uint64_t idx)
{
assert(idx < array_size_);
vvp_object_t*tmp = reinterpret_cast<vvp_object_t*>(buf+offset_);
const vvp_object_t*tmp = reinterpret_cast<vvp_object_t*>(buf+offset_);
val = tmp[idx];
}
void property_object::copy(char*dst, char*src)
{
vvp_object_t*dst_obj = reinterpret_cast<vvp_object_t*>(dst+offset_);
vvp_object_t*src_obj = reinterpret_cast<vvp_object_t*>(src+offset_);
const vvp_object_t*src_obj = reinterpret_cast<vvp_object_t*>(src+offset_);
for (size_t idx = 0 ; idx < array_size_ ; idx += 1)
dst_obj[idx] = src_obj[idx];
}

View File

@ -39,7 +39,7 @@ class class_type : public __vpiHandle {
public:
explicit class_type(const std::string&nam, size_t nprop);
~class_type();
~class_type() override;
// This is the name of the class type.
inline const std::string&class_name(void) const { return class_name_; }

View File

@ -326,8 +326,8 @@ static const unsigned opcode_count =
static int opcode_compare(const void*k, const void*r)
{
const char*kp = (const char*)k;
const struct opcode_table_s*rp = (const struct opcode_table_s*)r;
const char*kp = static_cast<const char*>(k);
const struct opcode_table_s*rp = static_cast<const struct opcode_table_s*>(r);
return strcmp(kp, rp->mnemonic);
}
@ -398,7 +398,7 @@ vvp_net_t* vvp_net_lookup(const char*label)
the vpiHandle. */
symbol_value_t val = sym_get_value(sym_vpi, label);
if (val.ptr) {
vpiHandle vpi = (vpiHandle) val.ptr;
vpiHandle vpi = static_cast<vpiHandle>(val.ptr);
switch (vpi->get_type_code()) {
case vpiNet:
case vpiReg:
@ -420,7 +420,7 @@ vvp_net_t* vvp_net_lookup(const char*label)
case vpiStringVar:
case vpiArrayVar:
case vpiClassVar: {
__vpiBaseVar*sig = dynamic_cast<__vpiBaseVar*>(vpi);
const __vpiBaseVar*sig = dynamic_cast<__vpiBaseVar*>(vpi);
return sig->get_net();
}
@ -636,7 +636,7 @@ bool vpi_handle_resolv_list_s::resolve(bool mes)
}
if (val.ptr) {
*handle = (vpiHandle) val.ptr;
*handle = static_cast<vpiHandle>(val.ptr);
return true;
}
@ -1761,7 +1761,7 @@ char **compile_udp_table(char **table, char *row)
for (tt = table; tt && *tt; tt++) { }
int n = (tt-table) + 2;
table = (char**)realloc(table, n*sizeof(char*));
table = static_cast<char**>(realloc(table, n*sizeof(char*)));
table[n-2] = row;
table[n-1] = 0x0;
@ -1784,9 +1784,10 @@ void compile_code(char*label, char*mnem, comp_operands_t opa)
compile_codelabel(label);
/* Lookup the opcode in the opcode table. */
struct opcode_table_s*op = (struct opcode_table_s*)
bsearch(mnem, opcode_table, opcode_count,
sizeof(struct opcode_table_s), &opcode_compare);
struct opcode_table_s*op = static_cast<struct opcode_table_s*>
(bsearch(mnem, opcode_table, opcode_count,
sizeof(struct opcode_table_s),
&opcode_compare));
if (op == 0) {
yyerror("Invalid opcode");
compile_errors += 1;

View File

@ -37,7 +37,7 @@ class vvp_fun_concat : public vvp_net_fun_t, protected vvp_gen_event_s {
public:
vvp_fun_concat(unsigned w0, unsigned w1,
unsigned w2, unsigned w3);
~vvp_fun_concat();
~vvp_fun_concat() override;
void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
vvp_context_t context) final;
@ -57,7 +57,7 @@ class vvp_fun_concat8 : public vvp_net_fun_t, protected vvp_gen_event_s {
public:
vvp_fun_concat8(unsigned w0, unsigned w1,
unsigned w2, unsigned w3);
~vvp_fun_concat8();
~vvp_fun_concat8() override;
void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
vvp_context_t context) final;
@ -86,7 +86,7 @@ class vvp_fun_repeat : public vvp_net_fun_t {
public:
vvp_fun_repeat(unsigned width, unsigned repeat);
~vvp_fun_repeat();
~vvp_fun_repeat() override;
void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
vvp_context_t context) override;

View File

@ -1,7 +1,7 @@
#ifndef IVL_config_H
#define IVL_config_H
/*
* Copyright (c) 2001-2022 Stephen Williams (steve@icarus.com)
* Copyright (c) 2001-2025 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
@ -204,7 +204,7 @@ inline int64_t i64round(double x)
static inline char*strndup(const char*s, size_t n)
{
if (strlen(s) < n) return strdup(s);
char*tmp = (char*)malloc(n+1);
char*tmp = static_cast<char*>(malloc(n+1));
strncpy(tmp, s, n);
tmp[n] = 0;
return tmp;

View File

@ -1,3 +1,10 @@
// Only for conditional debugging
knownConditionTrueFalse:lib_main.cc:289
// Index calculation
thisSubtraction:vpi_priv.h:430
thisSubtraction:array_common.h:91
// We use guarded memory allocation routines, but cppcheck is not
// noticing this so it is complaining we could return a NULL value.
nullPointerOutOfMemory:delay.cc:829 // calloc @ 828
@ -107,11 +114,14 @@ unusedFunction:vvp_net.cc:1751
// as_string()
unusedFunction:vvp_net.cc:1854
// fully_featured_resolv_()
unusedFunction:vvp_net.cc:3582
unusedFunction:vvp_net.cc:3580
// words()
unusedFunction:vvp_net.h:595
// force_vec8()
unusedFunction:vvp_net_sig.cc:128
// Unused functions from the lexor
duplicateBreak:lexor.lex
unusedFunction:lexor.cc
unusedStructMember:lexor.lex
allocaCalled:parse.cc

View File

@ -90,7 +90,7 @@ class vvp_fun_delay : public vvp_net_fun_t, private vvp_gen_event_s {
public:
vvp_fun_delay(vvp_net_t*net, unsigned width, const vvp_delay_t&d);
~vvp_fun_delay();
~vvp_fun_delay() override;
void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
vvp_context_t) override;
@ -167,7 +167,7 @@ class vvp_fun_modpath : public vvp_net_fun_t, private vvp_gen_event_s {
public:
vvp_fun_modpath(vvp_net_t*net, unsigned width);
~vvp_fun_modpath();
~vvp_fun_modpath() override;
void add_modpath_src(vvp_fun_modpath_src*that, bool ifnone);
@ -197,7 +197,7 @@ class vvp_fun_modpath_src : public vvp_net_fun_t {
public:
explicit vvp_fun_modpath_src(vvp_time64_t const del[12]);
protected:
~vvp_fun_modpath_src();
~vvp_fun_modpath_src() override;
public:
void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
@ -243,7 +243,7 @@ class vvp_fun_intermodpath : public vvp_net_fun_t, private vvp_gen_event_s {
public:
vvp_fun_intermodpath(vvp_net_t*net, unsigned width);
~vvp_fun_intermodpath();
~vvp_fun_intermodpath() override;
void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
vvp_context_t) override;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005-2016 Stephen Williams (steve@icarus.com)
* Copyright (c) 2005-2025 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
@ -57,10 +57,9 @@ vvp_dff_aset::vvp_dff_aset(unsigned width, bool negedge)
{
}
vvp_dff_asc::vvp_dff_asc(unsigned width, bool negedge, char*asc_value)
: vvp_dff(width, negedge)
vvp_dff_asc::vvp_dff_asc(unsigned width, bool negedge, const char*asc_value)
: vvp_dff(width, negedge), asc_value_(c4string_to_vector4(asc_value))
{
asc_value_ = c4string_to_vector4(asc_value);
}
void vvp_dff::recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,

View File

@ -39,7 +39,7 @@ class vvp_dff : public vvp_net_fun_t {
public:
explicit vvp_dff(unsigned width, bool negedge);
~vvp_dff();
~vvp_dff() override;
void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
vvp_context_t) override;
@ -90,7 +90,7 @@ class vvp_dff_aset : public vvp_dff {
class vvp_dff_asc : public vvp_dff {
public:
explicit vvp_dff_asc(unsigned width, bool negedge, char*asc_value);
explicit vvp_dff_asc(unsigned width, bool negedge, const char*asc_value);
private:
void recv_async(vvp_net_ptr_t port) override;

View File

@ -85,8 +85,8 @@ int __vpiEnumTypespec::vpi_get(int code)
vpiHandle __vpiEnumTypespec::vpi_iterate(int code)
{
if (code == vpiEnumConst) {
vpiHandle*args = (vpiHandle*)
calloc(names.size(), sizeof(vpiHandle*));
vpiHandle*args = static_cast<vpiHandle*>
(calloc(names.size(), sizeof(vpiHandle*)));
for (size_t idx = 0 ; idx < names.size() ; idx += 1)
args[idx] = &names[idx];

View File

@ -42,7 +42,7 @@ class evctl_real : public evctl {
public:
explicit evctl_real(class __vpiHandle*handle, double value,
unsigned long ecount);
virtual ~evctl_real() {}
virtual ~evctl_real() override {}
void run_run() override;
private:
@ -55,7 +55,7 @@ class evctl_vector : public evctl {
public:
explicit evctl_vector(vvp_net_ptr_t ptr, const vvp_vector4_t&value,
unsigned off, unsigned wid, unsigned long ecount);
virtual ~evctl_vector() {}
virtual ~evctl_vector() override {}
void run_run() override;
private:
@ -71,7 +71,7 @@ class evctl_array : public evctl {
explicit evctl_array(vvp_array_t memory, unsigned index,
const vvp_vector4_t&value, unsigned off,
unsigned long ecount);
virtual ~evctl_array() {}
virtual ~evctl_array() override {}
virtual void run_run() override;
private:
@ -86,7 +86,7 @@ class evctl_array_r : public evctl {
public:
explicit evctl_array_r(vvp_array_t memory, unsigned index,
double value, unsigned long ecount);
virtual ~evctl_array_r() {}
virtual ~evctl_array_r() override {}
virtual void run_run() override;
private:
@ -154,7 +154,7 @@ class vvp_fun_edge : public vvp_net_fun_t, public waitable_hooks_s {
public:
typedef unsigned short edge_t;
explicit vvp_fun_edge(edge_t e);
virtual ~vvp_fun_edge();
virtual ~vvp_fun_edge() override;
protected:
bool recv_vec4_(const vvp_vector4_t&bit,
@ -178,7 +178,7 @@ class vvp_fun_edge_sa : public vvp_fun_edge {
public:
explicit vvp_fun_edge_sa(edge_t e);
virtual ~vvp_fun_edge_sa();
virtual ~vvp_fun_edge_sa() override;
vthread_t add_waiting_thread(vthread_t thread) override;
@ -198,7 +198,7 @@ class vvp_fun_edge_aa : public vvp_fun_edge, public automatic_hooks_s {
public:
explicit vvp_fun_edge_aa(edge_t e);
virtual ~vvp_fun_edge_aa();
virtual ~vvp_fun_edge_aa() override;
void alloc_instance(vvp_context_t context) override;
void reset_instance(vvp_context_t context) override;
@ -236,7 +236,7 @@ class vvp_fun_anyedge : public vvp_net_fun_t, public waitable_hooks_s {
public:
explicit vvp_fun_anyedge();
virtual ~vvp_fun_anyedge();
virtual ~vvp_fun_anyedge() override;
protected:
anyedge_value*last_value_[4];
@ -249,7 +249,7 @@ class vvp_fun_anyedge_sa : public vvp_fun_anyedge {
public:
explicit vvp_fun_anyedge_sa();
virtual ~vvp_fun_anyedge_sa();
virtual ~vvp_fun_anyedge_sa() override;
vthread_t add_waiting_thread(vthread_t thread) override;
@ -277,7 +277,7 @@ class vvp_fun_anyedge_aa : public vvp_fun_anyedge, public automatic_hooks_s {
public:
explicit vvp_fun_anyedge_aa();
virtual ~vvp_fun_anyedge_aa();
virtual ~vvp_fun_anyedge_aa() override;
void alloc_instance(vvp_context_t context) override;
void reset_instance(vvp_context_t context) override;
@ -311,7 +311,7 @@ class vvp_fun_event_or : public vvp_net_fun_t, public waitable_hooks_s {
public:
explicit vvp_fun_event_or(vvp_net_t*base_net);
~vvp_fun_event_or();
~vvp_fun_event_or() override;
protected:
vvp_net_t*base_net_;
@ -324,7 +324,7 @@ class vvp_fun_event_or_sa : public vvp_fun_event_or {
public:
explicit vvp_fun_event_or_sa(vvp_net_t*base_net);
~vvp_fun_event_or_sa();
~vvp_fun_event_or_sa() override;
vthread_t add_waiting_thread(vthread_t thread) override;
@ -342,7 +342,7 @@ class vvp_fun_event_or_aa : public vvp_fun_event_or, public automatic_hooks_s {
public:
explicit vvp_fun_event_or_aa(vvp_net_t*base_net);
~vvp_fun_event_or_aa();
~vvp_fun_event_or_aa() override;
void alloc_instance(vvp_context_t context) override;
void reset_instance(vvp_context_t context) override;
@ -369,7 +369,7 @@ class vvp_named_event : public vvp_net_fun_t, public waitable_hooks_s {
public:
explicit vvp_named_event(class __vpiHandle*eh);
~vvp_named_event();
~vvp_named_event() override;
protected:
class __vpiHandle*handle_;
@ -382,7 +382,7 @@ class vvp_named_event_sa : public vvp_named_event {
public:
explicit vvp_named_event_sa(class __vpiHandle*eh);
~vvp_named_event_sa();
~vvp_named_event_sa() override;
vthread_t add_waiting_thread(vthread_t thread) override;
@ -400,7 +400,7 @@ class vvp_named_event_aa : public vvp_named_event, public automatic_hooks_s {
public:
explicit vvp_named_event_aa(class __vpiHandle*eh);
~vvp_named_event_aa();
~vvp_named_event_aa() override;
void alloc_instance(vvp_context_t context) override;
void reset_instance(vvp_context_t context) override;

View File

@ -89,7 +89,7 @@ char* __vpiFileLine::vpi_get_str(int code)
{ return file_line_get_str(code, this); }
vpiHandle vpip_build_file_line(char*description, long file_idx, long lineno)
vpiHandle vpip_build_file_line(const char*description, long file_idx, long lineno)
{
__vpiFileLine*obj = new __vpiFileLine(description, file_idx, lineno);

View File

@ -278,7 +278,7 @@ bool vvp_island_branch_tran::rerun_test_enabled()
inline vvp_vector8_t resolve_ambiguous(const vvp_vector8_t&a,
const vvp_vector8_t&b,
tran_state_t state,
unsigned str_map[8])
const unsigned str_map[8])
{
assert(a.size() == b.size());
vvp_vector8_t out (a.size());
@ -307,7 +307,7 @@ inline vvp_vector8_t resolve_ambiguous(const vvp_vector8_t&a,
}
static void push_value_through_branches(const vvp_vector8_t&val,
list<vvp_branch_ptr_t>&connections);
const list<vvp_branch_ptr_t>&connections);
static void push_value_through_branch(const vvp_vector8_t&val,
vvp_branch_ptr_t cur)
@ -367,10 +367,10 @@ static void push_value_through_branch(const vvp_vector8_t&val,
}
static void push_value_through_branches(const vvp_vector8_t&val,
list<vvp_branch_ptr_t>&connections)
const list<vvp_branch_ptr_t>&connections)
{
for (list<vvp_branch_ptr_t>::iterator idx = connections.begin()
; idx != connections.end() ; ++ idx ) {
for (list<vvp_branch_ptr_t>::const_iterator idx = connections.cbegin()
; idx != connections.cend() ; ++ idx ) {
push_value_through_branch(val, *idx);
}

View File

@ -32,7 +32,7 @@ class vvp_latch : public vvp_net_fun_t {
public:
explicit vvp_latch(unsigned width);
~vvp_latch();
~vvp_latch() override;
void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
vvp_context_t) override;

View File

@ -132,129 +132,129 @@ inline uint64_t strtouint64(const char*str, char**endptr, int base)
".arith/div" { return K_ARITH_DIV; }
".arith/div.r" { return K_ARITH_DIV_R; }
".arith/div.s" { return K_ARITH_DIV_S; }
".arith/mod" { return K_ARITH_MOD; }
".arith/mod" { return K_ARITH_MOD; }
".arith/mod.r" { return K_ARITH_MOD_R; }
".arith/mod.s" { return K_ARITH_MOD_S; }
".arith/mult" { return K_ARITH_MULT; }
".arith/mult" { return K_ARITH_MULT; }
".arith/mult.r" { return K_ARITH_MULT_R; }
".arith/pow" { return K_ARITH_POW; }
".arith/pow.r" { return K_ARITH_POW_R; }
".arith/pow.s" { return K_ARITH_POW_S; }
".arith/sub" { return K_ARITH_SUB; }
".arith/sub.r" { return K_ARITH_SUB_R; }
".arith/sum" { return K_ARITH_SUM; }
".arith/pow" { return K_ARITH_POW; }
".arith/pow.r" { return K_ARITH_POW_R; }
".arith/pow.s" { return K_ARITH_POW_S; }
".arith/sub" { return K_ARITH_SUB; }
".arith/sub.r" { return K_ARITH_SUB_R; }
".arith/sum" { return K_ARITH_SUM; }
".arith/sum.r" { return K_ARITH_SUM_R; }
".array" { return K_ARRAY; }
".array/2s" { return K_ARRAY_2S; }
".array/2u" { return K_ARRAY_2U; }
".array/i" { return K_ARRAY_I; }
".array/obj" { return K_ARRAY_OBJ; }
".array/real" { return K_ARRAY_R; }
".array/s" { return K_ARRAY_S; }
".array/str" { return K_ARRAY_STR; }
".array/port" { return K_ARRAY_PORT; }
".cast/2" { return K_CAST_2; }
".cast/int" { return K_CAST_INT; }
".cast/real" { return K_CAST_REAL; }
".cast/real.s" { return K_CAST_REAL_S; }
".class" { return K_CLASS; }
".cmp/eeq" { return K_CMP_EEQ; }
".cmp/eqx" { return K_CMP_EQX; }
".cmp/eqz" { return K_CMP_EQZ; }
".cmp/eq" { return K_CMP_EQ; }
".cmp/eq.r" { return K_CMP_EQ_R; }
".cmp/nee" { return K_CMP_NEE; }
".cmp/ne" { return K_CMP_NE; }
".cmp/ne.r" { return K_CMP_NE_R; }
".cmp/ge" { return K_CMP_GE; }
".cmp/ge.r" { return K_CMP_GE_R; }
".cmp/ge.s" { return K_CMP_GE_S; }
".cmp/gt" { return K_CMP_GT; }
".cmp/gt.r" { return K_CMP_GT_R; }
".cmp/gt.s" { return K_CMP_GT_S; }
".cmp/weq" { return K_CMP_WEQ; }
".cmp/wne" { return K_CMP_WNE; }
".concat" { return K_CONCAT; }
".concat8" { return K_CONCAT8; }
".delay" { return K_DELAY; }
".dff/n" { return K_DFF_N; }
".dff/n/aclr" { return K_DFF_N_ACLR; }
".dff/n/aset" { return K_DFF_N_ASET; }
".dff/p" { return K_DFF_P; }
".dff/p/aclr" { return K_DFF_P_ACLR; }
".dff/p/aset" { return K_DFF_P_ASET; }
".enum2" { return K_ENUM2; }
".enum2/s" { return K_ENUM2_S; }
".enum4" { return K_ENUM4; }
".enum4/s" { return K_ENUM4_S; }
".event" { return K_EVENT; }
".event/or" { return K_EVENT_OR; }
".export" { return K_EXPORT; }
".extend/s" { return K_EXTEND_S; }
".functor" { return K_FUNCTOR; }
".import" { return K_IMPORT; }
".island" { return K_ISLAND; }
".latch" { return K_LATCH; }
".modpath" { return K_MODPATH; }
".net" { return K_NET; }
".net/2s" { return K_NET_2S; }
".net/2u" { return K_NET_2U; }
".net8" { return K_NET8; }
".net8/2s" { return K_NET8_2S; }
".net8/2u" { return K_NET8_2U; }
".net8/s" { return K_NET8_S; }
".net/real" { return K_NET_R; }
".net/s" { return K_NET_S; }
".param/l" { return K_PARAM_L; }
".param/str" { return K_PARAM_STR; }
".param/real" { return K_PARAM_REAL; }
".part" { return K_PART; }
".part/pv" { return K_PART_PV; }
".part/v" { return K_PART_V; }
".part/v.s" { return K_PART_V_S; }
".port" { return K_PORT; }
".port_info" { return K_PORT_INFO; }
".reduce/and" { return K_REDUCE_AND; }
".reduce/or" { return K_REDUCE_OR; }
".reduce/xor" { return K_REDUCE_XOR; }
".reduce/nand" { return K_REDUCE_NAND; }
".reduce/nor" { return K_REDUCE_NOR; }
".reduce/xnor" { return K_REDUCE_XNOR; }
".repeat" { return K_REPEAT; }
".resolv" { return K_RESOLV; }
".rtran" { return K_RTRAN; }
".rtranif0" { return K_RTRANIF0; }
".rtranif1" { return K_RTRANIF1; }
".scope" { return K_SCOPE; }
".sfunc" { return K_SFUNC; }
".sfunc/e" { return K_SFUNC_E; }
".shift/l" { return K_SHIFTL; }
".shift/r" { return K_SHIFTR; }
".shift/rs" { return K_SHIFTRS; }
".substitute" { return K_SUBSTITUTE; }
".thread" { return K_THREAD; }
".timescale" { return K_TIMESCALE; }
".tran" { return K_TRAN; }
".tranif0" { return K_TRANIF0; }
".tranif1" { return K_TRANIF1; }
".tranvp" { return K_TRANVP; }
".ufunc/real" { return K_UFUNC_REAL; }
".ufunc/vec4" { return K_UFUNC_VEC4; }
".ufunc/e" { return K_UFUNC_E; }
".var" { return K_VAR; }
".var/cobj" { return K_VAR_COBJECT; }
".var/darray" { return K_VAR_DARRAY; }
".var/queue" { return K_VAR_QUEUE; }
".var/real" { return K_VAR_R; }
".var/s" { return K_VAR_S; }
".var/str" { return K_VAR_STR; }
".var/i" { return K_VAR_I; /* integer */ }
".var/2s" { return K_VAR_2S; /* byte/shortint/int/longint signed */ }
".var/2u" { return K_VAR_2U; /* byte/shortint/int/longint unsigned */ }
".udp" { return K_UDP; }
".udp/c"(omb)? { return K_UDP_C; }
".udp/s"(equ)? { return K_UDP_S; }
"-debug" { return K_DEBUG; }
".array" { return K_ARRAY; }
".array/2s" { return K_ARRAY_2S; }
".array/2u" { return K_ARRAY_2U; }
".array/i" { return K_ARRAY_I; }
".array/obj" { return K_ARRAY_OBJ; }
".array/real" { return K_ARRAY_R; }
".array/s" { return K_ARRAY_S; }
".array/str" { return K_ARRAY_STR; }
".array/port" { return K_ARRAY_PORT; }
".cast/2" { return K_CAST_2; }
".cast/int" { return K_CAST_INT; }
".cast/real" { return K_CAST_REAL; }
".cast/real.s" { return K_CAST_REAL_S; }
".class" { return K_CLASS; }
".cmp/eeq" { return K_CMP_EEQ; }
".cmp/eqx" { return K_CMP_EQX; }
".cmp/eqz" { return K_CMP_EQZ; }
".cmp/eq" { return K_CMP_EQ; }
".cmp/eq.r" { return K_CMP_EQ_R; }
".cmp/nee" { return K_CMP_NEE; }
".cmp/ne" { return K_CMP_NE; }
".cmp/ne.r" { return K_CMP_NE_R; }
".cmp/ge" { return K_CMP_GE; }
".cmp/ge.r" { return K_CMP_GE_R; }
".cmp/ge.s" { return K_CMP_GE_S; }
".cmp/gt" { return K_CMP_GT; }
".cmp/gt.r" { return K_CMP_GT_R; }
".cmp/gt.s" { return K_CMP_GT_S; }
".cmp/weq" { return K_CMP_WEQ; }
".cmp/wne" { return K_CMP_WNE; }
".concat" { return K_CONCAT; }
".concat8" { return K_CONCAT8; }
".delay" { return K_DELAY; }
".dff/n" { return K_DFF_N; }
".dff/n/aclr" { return K_DFF_N_ACLR; }
".dff/n/aset" { return K_DFF_N_ASET; }
".dff/p" { return K_DFF_P; }
".dff/p/aclr" { return K_DFF_P_ACLR; }
".dff/p/aset" { return K_DFF_P_ASET; }
".enum2" { return K_ENUM2; }
".enum2/s" { return K_ENUM2_S; }
".enum4" { return K_ENUM4; }
".enum4/s" { return K_ENUM4_S; }
".event" { return K_EVENT; }
".event/or" { return K_EVENT_OR; }
".export" { return K_EXPORT; }
".extend/s" { return K_EXTEND_S; }
".functor" { return K_FUNCTOR; }
".import" { return K_IMPORT; }
".island" { return K_ISLAND; }
".latch" { return K_LATCH; }
".modpath" { return K_MODPATH; }
".net" { return K_NET; }
".net/2s" { return K_NET_2S; }
".net/2u" { return K_NET_2U; }
".net8" { return K_NET8; }
".net8/2s" { return K_NET8_2S; }
".net8/2u" { return K_NET8_2U; }
".net8/s" { return K_NET8_S; }
".net/real" { return K_NET_R; }
".net/s" { return K_NET_S; }
".param/l" { return K_PARAM_L; }
".param/str" { return K_PARAM_STR; }
".param/real" { return K_PARAM_REAL; }
".part" { return K_PART; }
".part/pv" { return K_PART_PV; }
".part/v" { return K_PART_V; }
".part/v.s" { return K_PART_V_S; }
".port" { return K_PORT; }
".port_info" { return K_PORT_INFO; }
".reduce/and" { return K_REDUCE_AND; }
".reduce/or" { return K_REDUCE_OR; }
".reduce/xor" { return K_REDUCE_XOR; }
".reduce/nand" { return K_REDUCE_NAND; }
".reduce/nor" { return K_REDUCE_NOR; }
".reduce/xnor" { return K_REDUCE_XNOR; }
".repeat" { return K_REPEAT; }
".resolv" { return K_RESOLV; }
".rtran" { return K_RTRAN; }
".rtranif0" { return K_RTRANIF0; }
".rtranif1" { return K_RTRANIF1; }
".scope" { return K_SCOPE; }
".sfunc" { return K_SFUNC; }
".sfunc/e" { return K_SFUNC_E; }
".shift/l" { return K_SHIFTL; }
".shift/r" { return K_SHIFTR; }
".shift/rs" { return K_SHIFTRS; }
".substitute" { return K_SUBSTITUTE; }
".thread" { return K_THREAD; }
".timescale" { return K_TIMESCALE; }
".tran" { return K_TRAN; }
".tranif0" { return K_TRANIF0; }
".tranif1" { return K_TRANIF1; }
".tranvp" { return K_TRANVP; }
".ufunc/real" { return K_UFUNC_REAL; }
".ufunc/vec4" { return K_UFUNC_VEC4; }
".ufunc/e" { return K_UFUNC_E; }
".var" { return K_VAR; }
".var/cobj" { return K_VAR_COBJECT; }
".var/darray" { return K_VAR_DARRAY; }
".var/queue" { return K_VAR_QUEUE; }
".var/real" { return K_VAR_R; }
".var/s" { return K_VAR_S; }
".var/str" { return K_VAR_STR; }
".var/i" { return K_VAR_I; /* integer */ }
".var/2s" { return K_VAR_2S; /* byte/shortint/int/longint signed */ }
".var/2u" { return K_VAR_2U; /* byte/shortint/int/longint unsigned */ }
".udp" { return K_UDP; }
".udp/c"(omb)? { return K_UDP_C; }
".udp/s"(equ)? { return K_UDP_S; }
"-debug" { return K_DEBUG; }
/* instructions start with a % character. The compiler decides what
kind of instruction this really is. The few exceptions (that have

View File

@ -1,5 +1,5 @@
const char COPYRIGHT[] =
"Copyright (c) 2001-2024 Stephen Williams (steve@icarus.com)";
"Copyright (c) 2001-2025 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
@ -300,7 +300,7 @@ void vvp_init(const char *logfile_name, int argc, char*argv[])
/* If the VVP_DEBUG variable is set, then it contains the path
to the vvp debug file. Open it for output. */
if (char*path = getenv("VVP_DEBUG")) {
if (const char*path = getenv("VVP_DEBUG")) {
debug_file.open(path, ios::out);
}

View File

@ -30,7 +30,7 @@ class vvp_fun_boolean_ : public vvp_net_fun_t, protected vvp_gen_event_s {
public:
explicit vvp_fun_boolean_(unsigned wid);
~vvp_fun_boolean_();
~vvp_fun_boolean_() override;
void recv_vec4(vvp_net_ptr_t p, const vvp_vector4_t&bit,
vvp_context_t) override;
@ -48,7 +48,7 @@ class vvp_fun_and : public vvp_fun_boolean_ {
public:
explicit vvp_fun_and(unsigned wid, bool invert);
~vvp_fun_and();
~vvp_fun_and() override;
private:
void run_run() override;
@ -59,7 +59,7 @@ class vvp_fun_equiv : public vvp_fun_boolean_ {
public:
explicit vvp_fun_equiv();
~vvp_fun_equiv();
~vvp_fun_equiv() override;
private:
void run_run() override;
@ -69,7 +69,7 @@ class vvp_fun_impl : public vvp_fun_boolean_ {
public:
explicit vvp_fun_impl();
~vvp_fun_impl();
~vvp_fun_impl() override;
private:
void run_run() override;
@ -82,7 +82,7 @@ class vvp_fun_buf_not_ : public vvp_net_fun_t, protected vvp_gen_event_s {
public:
explicit vvp_fun_buf_not_(unsigned wid);
~vvp_fun_buf_not_();
~vvp_fun_buf_not_() override;
void recv_vec4(vvp_net_ptr_t p, const vvp_vector4_t&bit,
vvp_context_t) override;
@ -106,7 +106,7 @@ class vvp_fun_buf: public vvp_fun_buf_not_ {
public:
explicit vvp_fun_buf(unsigned wid);
virtual ~vvp_fun_buf();
virtual ~vvp_fun_buf() override;
private:
void run_run() override;
@ -120,7 +120,7 @@ class vvp_fun_bufz: public vvp_net_fun_t {
public:
explicit vvp_fun_bufz();
virtual ~vvp_fun_bufz();
virtual ~vvp_fun_bufz() override;
void recv_vec4(vvp_net_ptr_t p, const vvp_vector4_t&bit,
vvp_context_t) override;
@ -161,7 +161,7 @@ class vvp_fun_muxz : public vvp_net_fun_t, private vvp_gen_event_s {
public:
explicit vvp_fun_muxz(unsigned width);
virtual ~vvp_fun_muxz();
virtual ~vvp_fun_muxz() override;
void recv_vec4(vvp_net_ptr_t p, const vvp_vector4_t&bit,
vvp_context_t) override;
@ -183,7 +183,7 @@ class vvp_fun_muxr : public vvp_net_fun_t, private vvp_gen_event_s {
public:
explicit vvp_fun_muxr();
virtual ~vvp_fun_muxr();
virtual ~vvp_fun_muxr() override;
void recv_vec4(vvp_net_ptr_t p, const vvp_vector4_t&bit,
vvp_context_t) override;
@ -204,7 +204,7 @@ class vvp_fun_not: public vvp_fun_buf_not_ {
public:
explicit vvp_fun_not(unsigned wid);
virtual ~vvp_fun_not();
virtual ~vvp_fun_not() override;
private:
void run_run() override;
@ -214,7 +214,7 @@ class vvp_fun_or : public vvp_fun_boolean_ {
public:
explicit vvp_fun_or(unsigned wid, bool invert);
~vvp_fun_or();
~vvp_fun_or() override;
private:
void run_run() override;
@ -225,7 +225,7 @@ class vvp_fun_xor : public vvp_fun_boolean_ {
public:
explicit vvp_fun_xor(unsigned wid, bool invert);
~vvp_fun_xor();
~vvp_fun_xor() override;
private:
void run_run() override;

View File

@ -1,7 +1,7 @@
%{
/*
* Copyright (c) 2001-2023 Stephen Williams (steve@icarus.com)
* Copyright (c) 2001-2025 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
@ -1017,24 +1017,24 @@ operands
operand
: symbol
{ comp_operands_t opa = (comp_operands_t)
calloc(1, sizeof(struct comp_operands_s));
{ comp_operands_t opa = static_cast<comp_operands_t>
(calloc(1, sizeof(struct comp_operands_s)));
opa->argc = 1;
opa->argv[0].ltype = L_SYMB;
opa->argv[0].symb = $1;
$$ = opa;
}
| T_NUMBER
{ comp_operands_t opa = (comp_operands_t)
calloc(1, sizeof(struct comp_operands_s));
{ comp_operands_t opa = static_cast<comp_operands_t>
(calloc(1, sizeof(struct comp_operands_s)));
opa->argc = 1;
opa->argv[0].ltype = L_NUMB;
opa->argv[0].numb = $1;
$$ = opa;
}
| T_STRING
{ comp_operands_t opa = (comp_operands_t)
calloc(1, sizeof(struct comp_operands_s));
{ comp_operands_t opa = static_cast<comp_operands_t>
(calloc(1, sizeof(struct comp_operands_s)));
opa->argc = 1;
opa->argv[0].ltype = L_STRING;
opa->argv[0].text = $1;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001-2010 Stephen Williams (steve@icarus.com)
* Copyright (c) 2001-2025 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
@ -39,8 +39,8 @@ void symbv_init(struct symbv_s*obj)
void symbv_add(struct symbv_s*obj, struct symb_s item)
{
obj->vect = (struct symb_s*)
realloc(obj->vect, (obj->cnt+1) * sizeof(struct symb_s));
obj->vect = static_cast<struct symb_s*>
(realloc(obj->vect, (obj->cnt+1) * sizeof(struct symb_s)));
obj->vect[obj->cnt] = item;
obj->cnt += 1;
}
@ -53,7 +53,7 @@ void numbv_init(struct numbv_s*obj)
void numbv_add(struct numbv_s*obj, long item)
{
obj->nvec = (long*) realloc(obj->nvec, (obj->cnt+1) * sizeof(long));
obj->nvec = static_cast<long*>(realloc(obj->nvec, (obj->cnt+1) * sizeof(long)));
obj->nvec[obj->cnt] = item;
obj->cnt += 1;
}
@ -74,8 +74,8 @@ void argv_init(struct argv_s*obj)
void argv_add(struct argv_s*obj, vpiHandle item)
{
obj->argv = (vpiHandle*)
realloc(obj->argv, (obj->argc+1)*sizeof(vpiHandle));
obj->argv = static_cast<vpiHandle*>
(realloc(obj->argv, (obj->argc+1)*sizeof(vpiHandle)));
obj->argv[obj->argc] = item;
obj->argc += 1;
}
@ -83,8 +83,8 @@ void argv_add(struct argv_s*obj, vpiHandle item)
void argv_sym_add(struct argv_s*obj, char *item)
{
argv_add(obj, 0x0);
obj->syms = (char**)
realloc(obj->syms, (obj->argc)*sizeof(char*));
obj->syms = static_cast<char**>
(realloc(obj->syms, (obj->argc)*sizeof(char*)));
obj->syms[obj->argc-1] = item;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2021 Stephen Williams (steve@icarus.com)
* Copyright (c) 2004-2025 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
@ -162,19 +162,20 @@ void vvp_fun_part_aa::recv_vec4_pv(vvp_net_ptr_t port, const vvp_vector4_t&bit,
unsigned base, unsigned vwid, vvp_context_t context)
{
if (context) {
vvp_vector4_t*val = static_cast<vvp_vector4_t*>
(vvp_get_context_item(context, context_idx_));
const vvp_vector4_t*val = static_cast<vvp_vector4_t*>
(vvp_get_context_item(context,
context_idx_));
vvp_vector4_t tmp (vwid, BIT4_Z);
tmp.set_vec(base_, *val);
tmp.set_vec(base, bit);
recv_vec4(port, tmp, context);
vvp_vector4_t tmp (vwid, BIT4_Z);
tmp.set_vec(base_, *val);
tmp.set_vec(base, bit);
recv_vec4(port, tmp, context);
} else {
context = context_scope_->live_contexts;
while (context) {
recv_vec4_pv(port, bit, base, vwid, context);
context = vvp_get_next_context(context);
}
context = context_scope_->live_contexts;
while (context) {
recv_vec4_pv(port, bit, base, vwid, context);
context = vvp_get_next_context(context);
}
}
}
@ -377,8 +378,9 @@ void vvp_fun_part_var_aa::recv_vec4_pv(vvp_net_ptr_t port, const vvp_vector4_t&b
unsigned base, unsigned vwid, vvp_context_t context)
{
if (context) {
vvp_fun_part_var_state_s*state = static_cast<vvp_fun_part_var_state_s*>
(vvp_get_context_item(context, context_idx_));
const vvp_fun_part_var_state_s*state = static_cast<vvp_fun_part_var_state_s*>
(vvp_get_context_item(context,
context_idx_));
vvp_vector4_t tmp = state->source;
if (tmp.size() == 0)

View File

@ -32,7 +32,7 @@ class vvp_fun_part : public vvp_net_fun_t {
public:
vvp_fun_part(unsigned base, unsigned wid);
~vvp_fun_part();
~vvp_fun_part() override;
unsigned get_base() const { return base_; }
unsigned get_wid() const { return wid_; }
@ -49,7 +49,7 @@ class vvp_fun_part_sa : public vvp_fun_part, public vvp_gen_event_s {
public:
vvp_fun_part_sa(unsigned base, unsigned wid);
~vvp_fun_part_sa();
~vvp_fun_part_sa() override;
public:
void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
@ -73,7 +73,7 @@ class vvp_fun_part_aa : public vvp_fun_part, public automatic_hooks_s {
public:
vvp_fun_part_aa(unsigned base, unsigned wid);
~vvp_fun_part_aa();
~vvp_fun_part_aa() override;
public:
void alloc_instance(vvp_context_t context) override;
@ -104,7 +104,7 @@ class vvp_fun_part_pv : public vvp_net_fun_t {
public:
vvp_fun_part_pv(unsigned base, unsigned wid, unsigned vec_wid);
~vvp_fun_part_pv();
~vvp_fun_part_pv() override;
public:
void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
@ -130,7 +130,7 @@ class vvp_fun_part_var : public vvp_net_fun_t {
public:
explicit vvp_fun_part_var(unsigned wid, bool is_signed);
~vvp_fun_part_var();
~vvp_fun_part_var() override;
protected:
bool recv_vec4_(vvp_net_ptr_t port, const vvp_vector4_t&bit,
@ -148,7 +148,7 @@ class vvp_fun_part_var_sa : public vvp_fun_part_var {
public:
explicit vvp_fun_part_var_sa(unsigned wid, bool is_signed);
~vvp_fun_part_var_sa();
~vvp_fun_part_var_sa() override;
public:
void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
@ -171,7 +171,7 @@ class vvp_fun_part_var_aa : public vvp_fun_part_var, public automatic_hooks_s {
public:
explicit vvp_fun_part_var_aa(unsigned wid, bool is_signed);
~vvp_fun_part_var_aa();
~vvp_fun_part_var_aa() override;
public:
void alloc_instance(vvp_context_t context) override;

View File

@ -35,7 +35,7 @@ class vvp_reduce_base : public vvp_net_fun_t {
public:
vvp_reduce_base();
virtual ~vvp_reduce_base();
virtual ~vvp_reduce_base() override;
void recv_vec4(vvp_net_ptr_t prt, const vvp_vector4_t&bit,
vvp_context_t context) override;
@ -83,7 +83,7 @@ class vvp_reduce_and : public vvp_reduce_base {
public:
vvp_reduce_and();
~vvp_reduce_and();
~vvp_reduce_and() override;
vvp_bit4_t calculate_result() const override;
};
@ -109,7 +109,7 @@ class vvp_reduce_or : public vvp_reduce_base {
public:
vvp_reduce_or();
~vvp_reduce_or();
~vvp_reduce_or() override;
vvp_bit4_t calculate_result() const override;
};
@ -135,7 +135,7 @@ class vvp_reduce_xor : public vvp_reduce_base {
public:
vvp_reduce_xor();
~vvp_reduce_xor();
~vvp_reduce_xor() override;
vvp_bit4_t calculate_result() const override;
};
@ -161,7 +161,7 @@ class vvp_reduce_nand : public vvp_reduce_base {
public:
vvp_reduce_nand();
~vvp_reduce_nand();
~vvp_reduce_nand() override;
vvp_bit4_t calculate_result() const override;
};
@ -187,7 +187,7 @@ class vvp_reduce_nor : public vvp_reduce_base {
public:
vvp_reduce_nor();
~vvp_reduce_nor();
~vvp_reduce_nor() override;
vvp_bit4_t calculate_result() const override;
};
@ -213,7 +213,7 @@ class vvp_reduce_xnor : public vvp_reduce_base {
public:
vvp_reduce_xnor();
~vvp_reduce_xnor();
~vvp_reduce_xnor() override;
vvp_bit4_t calculate_result() const override;
};

View File

@ -34,7 +34,7 @@ class resolv_core : public vvp_net_fun_t {
public:
explicit resolv_core(unsigned nports, vvp_net_t*net);
virtual ~resolv_core();
virtual ~resolv_core() override;
void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
vvp_context_t) override
@ -72,7 +72,7 @@ class resolv_extend : public vvp_net_fun_t {
public:
resolv_extend(resolv_core*core, unsigned port_base);
~resolv_extend();
~resolv_extend() override;
void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
vvp_context_t) override
@ -113,7 +113,7 @@ class resolv_tri : public resolv_core {
public:
explicit resolv_tri(unsigned nports, vvp_net_t*net,
vvp_scalar_t hiz_value);
~resolv_tri();
~resolv_tri() override;
void count_drivers(unsigned bit_idx, unsigned counts[3]) override;
@ -141,7 +141,7 @@ class resolv_wired_logic : public resolv_core {
public:
explicit resolv_wired_logic(unsigned nports, vvp_net_t*net);
virtual ~resolv_wired_logic();
virtual ~resolv_wired_logic() override;
void count_drivers(unsigned bit_idx, unsigned counts[3]) override;
@ -161,7 +161,7 @@ class resolv_triand : public resolv_wired_logic {
public:
explicit resolv_triand(unsigned nports, vvp_net_t*net);
~resolv_triand();
~resolv_triand() override;
private:
virtual vvp_vector4_t wired_logic_math_(vvp_vector4_t&a, vvp_vector4_t&b) override;
@ -171,7 +171,7 @@ class resolv_trior : public resolv_wired_logic {
public:
explicit resolv_trior(unsigned nports, vvp_net_t*net);
~resolv_trior();
~resolv_trior() override;
private:
virtual vvp_vector4_t wired_logic_math_(vvp_vector4_t&a, vvp_vector4_t&b) override;

View File

@ -25,7 +25,7 @@ class sfunc_core : public vvp_wide_fun_core, protected vvp_gen_event_s {
public:
sfunc_core(vvp_net_t*ptr, vpiHandle sys, unsigned argc, vpiHandle*argv);
~sfunc_core();
~sfunc_core() override;
void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
vvp_context_t context) override;

View File

@ -76,8 +76,8 @@ inline void* slab_t<SLAB_SIZE,CHUNK_COUNT>::alloc_slab()
item_cell_u*chunk = new item_cell_u[CHUNK_COUNT];
#ifdef CHECK_WITH_VALGRIND
slab_pool_count += 1;
slab_pool = (item_cell_u **) realloc(slab_pool,
slab_pool_count*sizeof(item_cell_u **));
slab_pool = static_cast<item_cell_u **>(realloc(slab_pool,
slab_pool_count*sizeof(item_cell_u **)));
slab_pool[slab_pool_count-1] = chunk;
#endif
for (unsigned idx = 0 ; idx < CHUNK_COUNT ; idx += 1) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003-2024 Stephen Williams (steve@icarus.com)
* Copyright (c) 2003-2025 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
@ -72,7 +72,7 @@ static char* readline_stub(const char*prompt)
static bool interact_flag = true;
static void cmd_call(unsigned argc, char*argv[])
static void cmd_call(unsigned argc, const char*argv[])
{
__vpiHandle**table;
unsigned ntable;
@ -88,8 +88,8 @@ static void cmd_call(unsigned argc, char*argv[])
/* This is an array of vpiHandles, for passing to the created
command. */
unsigned vpi_argc = argc - 1;
vpiHandle*vpi_argv = (vpiHandle*)calloc(vpi_argc, sizeof(vpiHandle));
vpiHandle*vpi_free = (vpiHandle*)calloc(vpi_argc, sizeof(vpiHandle));
vpiHandle*vpi_argv = static_cast<vpiHandle*>(calloc(vpi_argc, sizeof(vpiHandle)));
vpiHandle*vpi_free = static_cast<vpiHandle*>(calloc(vpi_argc, sizeof(vpiHandle)));
unsigned errors = 0;
@ -127,7 +127,7 @@ static void cmd_call(unsigned argc, char*argv[])
the name in argv[idx+2]. Look in the current scope. */
for (unsigned tmp = 0 ; (tmp < ntable)&& !handle ; tmp += 1) {
__vpiScope*scope;
const __vpiScope*scope;
const char*name;
switch (table[tmp]->get_type_code()) {
@ -193,26 +193,26 @@ static void cmd_call(unsigned argc, char*argv[])
free(vpi_free);
}
static void cmd_cont(unsigned, char*[])
static void cmd_cont(unsigned, const char*[])
{
interact_flag = false;
}
static void cmd_step(unsigned, char*[])
static void cmd_step(unsigned, const char*[])
{
interact_flag = false;
schedule_single_step(0);
}
static void cmd_finish(unsigned, char*[])
static void cmd_finish(unsigned, const char*[])
{
interact_flag = false;
schedule_finish(0);
}
static void cmd_help(unsigned, char*[]);
static void cmd_help(unsigned, const char*[]);
static void cmd_list(unsigned, char*[])
static void cmd_list(unsigned, const char*[])
{
__vpiHandle**table;
unsigned ntable;
@ -228,7 +228,7 @@ static void cmd_list(unsigned, char*[])
printf("%u items in this scope:\n", ntable);
for (unsigned idx = 0 ; idx < ntable ; idx += 1) {
__vpiScope*scope;
const __vpiScope*scope;
struct __vpiSignal*sig;
switch (table[idx]->get_type_code()) {
@ -312,7 +312,7 @@ static void cmd_list(unsigned, char*[])
}
}
static void cmd_load(unsigned argc, char*argv[])
static void cmd_load(unsigned argc, const char*argv[])
{
unsigned idx;
@ -322,15 +322,14 @@ static void cmd_load(unsigned argc, char*argv[])
}
}
static void cmd_pop(unsigned, char*[])
static void cmd_pop(unsigned, const char*[])
{
if (stop_current_scope != 0)
stop_current_scope = stop_current_scope->scope;
}
static void cmd_push(unsigned argc, char* argv[])
static void cmd_push(unsigned argc, const char* argv[])
{
for (unsigned idx = 1 ; idx < argc ; idx += 1) {
__vpiHandle**table;
unsigned ntable;
@ -367,13 +366,13 @@ static void cmd_push(unsigned argc, char* argv[])
}
}
static void cmd_time(unsigned, char*[])
static void cmd_time(unsigned, const char*[])
{
unsigned long ticks = schedule_simtime();
printf("%lu ticks\n", ticks);
}
static void cmd_trace(unsigned argc, char*argv[])
static void cmd_trace(unsigned argc, const char*argv[])
{
assert(argc);
switch (argc) {
@ -404,9 +403,9 @@ static void cmd_trace(unsigned argc, char*argv[])
}
}
static void cmd_where(unsigned, char*[])
static void cmd_where(unsigned, const char*[])
{
__vpiScope*cur = stop_current_scope;
const __vpiScope*cur = stop_current_scope;
while (cur) {
switch (cur->get_type_code()) {
@ -425,7 +424,7 @@ static void cmd_where(unsigned, char*[])
}
}
static void cmd_unknown(unsigned, char*argv[])
static void cmd_unknown(unsigned, const char*argv[])
{
printf("Unknown command: %s\n", argv[0]);
printf("Try the help command to get a summary\n"
@ -434,7 +433,7 @@ static void cmd_unknown(unsigned, char*argv[])
static struct {
const char*name;
void (*proc)(unsigned argc, char*argv[]);
void (*proc)(unsigned argc, const char*argv[]);
const char*summary;
} cmd_table[] = {
{ "cd", &cmd_push,
@ -468,7 +467,7 @@ static struct {
{ 0, &cmd_unknown, 0}
};
static void cmd_help(unsigned, char*[])
static void cmd_help(unsigned, const char*[])
{
printf("Commands can be from the following table of base commands,\n"
"or can be invocations of system tasks/functions.\n\n");
@ -486,7 +485,7 @@ static void cmd_help(unsigned, char*[])
static void invoke_command(char*txt)
{
unsigned argc = 0;
char**argv = new char*[strlen(txt)/2];
const char**argv = const_cast<const char**>(new char*[strlen(txt)/2]);
/* Chop the line into words. */
for (char*cp = txt+strspn(txt, " ")

View File

@ -28,7 +28,7 @@ class vvp_fun_substitute : public vvp_net_fun_t {
public:
vvp_fun_substitute(unsigned wid, unsigned soff, unsigned swid);
~vvp_fun_substitute();
~vvp_fun_substitute() override;
void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit, vvp_context_t) override;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005-2021 Stephen Williams (steve@icarus.com)
* Copyright (c) 2005-2025 Stephen Williams (steve@icarus.com)
*
* (This is a rewrite of code that was ...
* Copyright (c) 2001 Stephan Boettcher <stephan@nevis.columbia.edu>)
@ -84,7 +84,7 @@ ostream& operator <<(ostream&o, const struct udp_levels_table&table)
return o;
}
vvp_udp_s::vvp_udp_s(char*label, char*name__, unsigned ports,
vvp_udp_s::vvp_udp_s(const char*label, char*name__, unsigned ports,
vvp_bit4_t init, bool type)
: name_(name__), ports_(ports), init_(init), seq_(type)
{
@ -99,8 +99,8 @@ vvp_udp_s::vvp_udp_s(char*label, char*name__, unsigned ports,
#ifdef CHECK_WITH_VALGRIND
udp_defns_count += 1;
udp_defns = (vvp_udp_s **) realloc(udp_defns,
udp_defns_count*sizeof(vvp_udp_s **));
udp_defns = static_cast<vvp_udp_s **>(realloc(udp_defns,
udp_defns_count*sizeof(vvp_udp_s **)));
udp_defns[udp_defns_count-1] = this;
#endif
}
@ -120,7 +120,7 @@ vvp_bit4_t vvp_udp_s::get_init() const
return init_;
}
vvp_udp_comb_s::vvp_udp_comb_s(char*label, char*name__, unsigned ports)
vvp_udp_comb_s::vvp_udp_comb_s(const char*label, char*name__, unsigned ports)
: vvp_udp_s(label, name__, ports, BIT4_X, false)
{
levels0_ = 0;
@ -294,7 +294,7 @@ void vvp_udp_comb_s::compile_table(char**tab)
assert(nrows1 == nlevels1_);
}
vvp_udp_seq_s::vvp_udp_seq_s(char*label, char*name__,
vvp_udp_seq_s::vvp_udp_seq_s(const char*label, char*name__,
unsigned ports, vvp_bit4_t init)
: vvp_udp_s(label, name__, ports, init, true)
{
@ -330,7 +330,7 @@ vvp_udp_seq_s::~vvp_udp_seq_s()
void edge_based_on_char(struct udp_edges_table&cur, char chr, unsigned pos)
{
unsigned long mask_bit = 1 << pos;
unsigned long mask_bit = 1UL << pos;
switch (chr) {
case '0':
@ -826,7 +826,7 @@ vvp_bit4_t vvp_udp_seq_s::test_edges_(const udp_levels_table&cur,
entries. */
for (unsigned idx = 0 ; idx < nedges0_ ; idx += 1) {
struct udp_edges_table*row = edges0_ + idx;
const struct udp_edges_table*row = edges0_ + idx;
if (row->edge_position != edge_position)
continue;
@ -847,7 +847,7 @@ vvp_bit4_t vvp_udp_seq_s::test_edges_(const udp_levels_table&cur,
}
for (unsigned idx = 0 ; idx < nedges1_ ; idx += 1) {
struct udp_edges_table*row = edges1_ + idx;
const struct udp_edges_table*row = edges1_ + idx;
if (row->edge_position != edge_position)
continue;
@ -868,7 +868,7 @@ vvp_bit4_t vvp_udp_seq_s::test_edges_(const udp_levels_table&cur,
}
for (unsigned idx = 0 ; idx < nedgesL_ ; idx += 1) {
struct udp_edges_table*row = edgesL_ + idx;
const struct udp_edges_table*row = edgesL_ + idx;
if (row->edge_position != edge_position)
continue;

View File

@ -30,7 +30,7 @@ struct udp_levels_table;
struct vvp_udp_s {
public:
explicit vvp_udp_s(char*label, char*name, unsigned ports,
explicit vvp_udp_s(const char*label, char*name, unsigned ports,
vvp_bit4_t init, bool type);
virtual ~vvp_udp_s();
@ -114,8 +114,8 @@ extern std::ostream& operator<< (std::ostream&o, const struct udp_levels_table&t
class vvp_udp_comb_s : public vvp_udp_s {
public:
vvp_udp_comb_s(char*label, char*name__, unsigned ports);
~vvp_udp_comb_s();
vvp_udp_comb_s(const char*label, char*name__, unsigned ports);
~vvp_udp_comb_s() override;
void compile_table(char**tab);
// Test the cur table with the compiled rows, and return the
@ -180,8 +180,8 @@ struct udp_edges_table {
class vvp_udp_seq_s : public vvp_udp_s {
public:
vvp_udp_seq_s(char*label, char*name__, unsigned ports, vvp_bit4_t init);
~vvp_udp_seq_s();
vvp_udp_seq_s(const char*label, char*name__, unsigned ports, vvp_bit4_t init);
~vvp_udp_seq_s() override;
void compile_table(char**tab);
@ -226,7 +226,7 @@ class vvp_udp_fun_core : public vvp_wide_fun_core, private vvp_gen_event_s {
public:
vvp_udp_fun_core(vvp_net_t*net, vvp_udp_s*def);
~vvp_udp_fun_core();
~vvp_udp_fun_core() override;
void recv_vec4_from_inputs(unsigned) override;

View File

@ -45,7 +45,7 @@ class ufunc_real : public ufunc_core {
vvp_code_t start_address,
__vpiScope*call_scope,
char*scope_label);
~ufunc_real();
~ufunc_real() override;
void finish_thread() override;
};
@ -57,7 +57,7 @@ class ufunc_vec4 : public ufunc_core {
vvp_code_t start_address,
__vpiScope*call_scope,
char*scope_label);
~ufunc_vec4();
~ufunc_vec4() override;
void finish_thread() override;
};

View File

@ -57,7 +57,7 @@ class ufunc_core : public vvp_wide_fun_core {
vvp_code_t start_address,
__vpiScope*call_scope,
char*scope_label);
virtual ~ufunc_core() =0;
virtual ~ufunc_core() override =0;
__vpiScope*call_scope() { return call_scope_; }
__vpiScope*func_scope() { return func_scope_; }

View File

@ -270,7 +270,7 @@ vpiHandle vpip_make_string_const(char*text, bool persistent_flag)
class __vpiStringParam : public __vpiStringConst {
public:
__vpiStringParam(char*txt, char*name);
__vpiStringParam(char*txt, const char*name);
~__vpiStringParam() override;
int get_type_code(void) const override;
int vpi_get(int code) override;
@ -285,7 +285,7 @@ class __vpiStringParam : public __vpiStringConst {
const char*basename_;
};
inline __vpiStringParam::__vpiStringParam(char*txt, char*nam)
inline __vpiStringParam::__vpiStringParam(char*txt, const char*nam)
: __vpiStringConst(txt)
{
basename_ = nam;
@ -338,8 +338,8 @@ vpiHandle __vpiStringParam::vpi_handle(int code)
}
}
vpiHandle vpip_make_string_param(char*name, char*text,
bool local_flag, long file_idx, long lineno)
vpiHandle vpip_make_string_param(const char*name, char*text,
bool local_flag, long file_idx, long lineno)
{
__vpiStringParam*obj = new __vpiStringParam(text, name);
obj->scope = vpip_peek_current_scope();
@ -691,7 +691,7 @@ vpiHandle vpip_make_real_const(double value)
}
struct __vpiRealParam : public __vpiRealConst {
__vpiRealParam(double val, char*name);
__vpiRealParam(double val, const char*name);
~__vpiRealParam() override;
int get_type_code(void) const override;
int vpi_get(int code) override;
@ -707,7 +707,7 @@ struct __vpiRealParam : public __vpiRealConst {
};
inline __vpiRealParam::__vpiRealParam(double val, char*name)
inline __vpiRealParam::__vpiRealParam(double val, const char*name)
: __vpiRealConst(val)
{
basename_ = name;
@ -759,8 +759,8 @@ vpiHandle __vpiRealParam::vpi_handle(int code)
}
vpiHandle vpip_make_real_param(char*name, double value,
bool local_flag, long file_idx, long lineno)
vpiHandle vpip_make_real_param(const char*name, double value,
bool local_flag, long file_idx, long lineno)
{
struct __vpiRealParam*obj = new __vpiRealParam(value, name);

View File

@ -1092,7 +1092,7 @@ static t_vpi_time *timedup(const t_vpi_time *val)
}
/* Make a copy of a pointer to a vector value structure. */
static t_vpi_vecval *vectordup(t_vpi_vecval *val, PLI_INT32 size)
static t_vpi_vecval *vectordup(const t_vpi_vecval *val, PLI_INT32 size)
{
unsigned num_bytes;
t_vpi_vecval *rtn;
@ -1725,8 +1725,6 @@ vpiHandle vpi_handle_multi(PLI_INT32 type,
vvp_net_t* current_net = net1_ptr->ptr();
while (current_net) {
if (!current_net) break; // End of list
const vvp_fun_part* part = dynamic_cast<vvp_fun_part*>(current_net->fun);
// Its a part select!

View File

@ -61,7 +61,7 @@ extern vpip_routines_s vpi_routines;
extern bool show_file_line;
extern bool code_is_instrumented;
extern vpiHandle vpip_build_file_line(char*description,
extern vpiHandle vpip_build_file_line(const char*description,
long file_idx, long lineno);
/*
@ -194,7 +194,7 @@ class __vpiDecConst : public __vpiHandle {
*/
struct __vpiCallback : public __vpiHandle {
__vpiCallback();
~__vpiCallback();
~__vpiCallback() override;
int get_type_code(void) const override;
// Used for listing callbacks.
@ -362,7 +362,7 @@ struct __vpiSignal : public __vpiHandle {
public:
unsigned width() const;
vpiHandle get_index(int index);
void get_bit_value(struct __vpiBit*bit, p_vpi_value vp);
void get_bit_value(const struct __vpiBit*bit, p_vpi_value vp);
vpiHandle put_bit_value(struct __vpiBit*bit, p_vpi_value vp, int flags);
void make_bits();
@ -442,7 +442,7 @@ class vpiPortInfo : public __vpiHandle {
unsigned width,
const char *name,
char* buffer );
~vpiPortInfo();
~vpiPortInfo() override;
int get_type_code(void) const override { return vpiPort; }
int get_direction(void) { return direction_; }
@ -471,7 +471,7 @@ class vpiPortBitInfo : public __vpiHandle {
public:
vpiPortBitInfo(vpiPortInfo *parent,
unsigned bit);
~vpiPortBitInfo();
~vpiPortBitInfo() override;
int get_type_code(void) const override { return vpiPortBit; }
unsigned get_bit(void) const { return bit_; }
@ -619,7 +619,7 @@ class __vpiNamedEvent : public __vpiHandle {
public:
__vpiNamedEvent(__vpiScope*scope, const char*name);
~__vpiNamedEvent();
~__vpiNamedEvent() override;
int get_type_code(void) const override;
__vpiScope*get_scope(void) const { return scope_; }
int vpi_get(int code) override;
@ -694,7 +694,7 @@ class __vpiBaseVar : public __vpiHandle {
public:
__vpiBaseVar(__vpiScope*scope, const char*name, vvp_net_t*net);
#ifdef CHECK_WITH_VALGRIND
~__vpiBaseVar();
~__vpiBaseVar() override;
#endif
inline vvp_net_t* get_net() const { return net_; }
@ -826,9 +826,9 @@ private:
unsigned array_count;
__vpiScope*scope;
friend vpiHandle vpip_make_array(char*label, const char*name,
int first_addr, int last_addr,
bool signed_flag);
friend vpiHandle vpip_make_array(const char*label, const char*name,
int first_addr, int last_addr,
bool signed_flag);
friend void compile_array_alias(char*label, char*name, char*src);
};
@ -957,7 +957,7 @@ extern struct __vpiSysTaskCall*vpip_cur_task;
*/
vpiHandle vpip_make_string_const(char*text, bool persistent =true);
vpiHandle vpip_make_string_param(char*name, char*value, bool local_flag,
vpiHandle vpip_make_string_param(const char*name, char*value, bool local_flag,
long file_idx, long lineno);
struct __vpiBinaryConst : public __vpiHandle {
@ -989,7 +989,7 @@ class __vpiRealConst : public __vpiHandle {
};
vpiHandle vpip_make_real_const(double value);
vpiHandle vpip_make_real_param(char*name, double value, bool local_flag,
vpiHandle vpip_make_real_param(const char*name, double value, bool local_flag,
long file_idx, long lineno);
class __vpiNullConst : public __vpiHandle {

View File

@ -35,7 +35,7 @@ using namespace std;
static vector<vpiHandle> vpip_root_table;
static vpiHandle make_subset_iterator_(int type_code, vector<vpiHandle>&table);
static vpiHandle make_subset_iterator_(int type_code, const vector<vpiHandle>&table);
vpiHandle vpip_make_root_iterator(int type_code)
{
@ -313,7 +313,7 @@ static int compare_types(int code, int type)
return 0;
}
static vpiHandle make_subset_iterator_(int type_code, vector<vpiHandle>&table)
static vpiHandle make_subset_iterator_(int type_code, const vector<vpiHandle>&table)
{
unsigned mcnt = 0, ncnt = 0;
vpiHandle*args;

View File

@ -156,7 +156,7 @@ static vpiHandle fill_in_var4(struct __vpiSignal*obj,
* They work with full or partial signals.
*/
static void format_vpiBinStrVal(vvp_signal_value*sig, int base, unsigned wid,
static void format_vpiBinStrVal(const vvp_signal_value*sig, int base, unsigned wid,
s_vpi_value*vp)
{
char *rbuf = static_cast<char *>(need_result_buf(wid+1, RBUF_VAL));
@ -176,7 +176,7 @@ static void format_vpiBinStrVal(vvp_signal_value*sig, int base, unsigned wid,
vp->value.str = rbuf;
}
static void format_vpiOctStrVal(vvp_signal_value*sig, int base, unsigned wid,
static void format_vpiOctStrVal(const vvp_signal_value*sig, int base, unsigned wid,
s_vpi_value*vp)
{
unsigned dwid = (wid + 2) / 3;
@ -232,7 +232,7 @@ static void format_vpiOctStrVal(vvp_signal_value*sig, int base, unsigned wid,
vp->value.str = rbuf;
}
static void format_vpiHexStrVal(vvp_signal_value*sig, int base, unsigned wid,
static void format_vpiHexStrVal(const vvp_signal_value*sig, int base, unsigned wid,
s_vpi_value*vp)
{
unsigned dwid = (wid + 3) / 4;
@ -292,7 +292,7 @@ static void format_vpiHexStrVal(vvp_signal_value*sig, int base, unsigned wid,
vp->value.str = rbuf;
}
static void format_vpiDecStrVal(vvp_signal_value*sig, int base, unsigned wid,
static void format_vpiDecStrVal(const vvp_signal_value*sig, int base, unsigned wid,
int signed_flag, s_vpi_value*vp)
{
unsigned hwid = (sig->value_size()+2) / 3 + 1;
@ -337,7 +337,7 @@ static void format_vpiDecStrVal(vvp_signal_value*sig, int base, unsigned wid,
vp->value.str = rbuf;
}
static void format_vpiIntVal(vvp_signal_value*sig, int base, unsigned wid,
static void format_vpiIntVal(const vvp_signal_value*sig, int base, unsigned wid,
int signed_flag, s_vpi_value*vp)
{
vvp_vector4_t tmp;
@ -360,7 +360,7 @@ static void format_vpiIntVal(vvp_signal_value*sig, int base, unsigned wid,
}
}
static void format_vpiRealVal(vvp_signal_value*sig, int base, unsigned wid,
static void format_vpiRealVal(const vvp_signal_value*sig, int base, unsigned wid,
int signed_flag, s_vpi_value*vp)
{
vvp_vector4_t vec4(wid);
@ -376,7 +376,7 @@ static void format_vpiRealVal(vvp_signal_value*sig, int base, unsigned wid,
vector4_to_value(vec4, vp->value.real, signed_flag);
}
static void format_vpiStringVal(vvp_signal_value*sig, int base, unsigned wid,
static void format_vpiStringVal(const vvp_signal_value*sig, int base, unsigned wid,
s_vpi_value*vp)
{
/* The result will use a character for each 8 bits of the
@ -409,7 +409,7 @@ static void format_vpiStringVal(vvp_signal_value*sig, int base, unsigned wid,
vp->value.str = rbuf;
}
static void format_vpiScalarVal(vvp_signal_value*sig, int base,
static void format_vpiScalarVal(const vvp_signal_value*sig, int base,
s_vpi_value*vp)
{
if (base >= 0 && base < (signed)sig->value_size()) {
@ -436,7 +436,7 @@ static void format_vpiScalarVal(vvp_signal_value*sig, int base,
}
}
static void format_vpiStrengthVal(vvp_signal_value*sig, int base,
static void format_vpiStrengthVal(const vvp_signal_value*sig, int base,
unsigned wid, s_vpi_value*vp)
{
long end = base + (signed)wid;
@ -490,7 +490,7 @@ static void format_vpiStrengthVal(vvp_signal_value*sig, int base,
vp->value.strength = op;
}
static void format_vpiVectorVal(vvp_signal_value*sig, int base, unsigned wid,
static void format_vpiVectorVal(const vvp_signal_value*sig, int base, unsigned wid,
s_vpi_value*vp)
{
long end = base + (signed)wid;
@ -723,7 +723,7 @@ vpiHandle __vpiSignal::get_index(int idx)
return &(bits[norm_idx].as_bit);
}
void __vpiSignal::get_bit_value(struct __vpiBit*bit, p_vpi_value vp)
void __vpiSignal::get_bit_value(const struct __vpiBit*bit, p_vpi_value vp)
{
unsigned index = bit->get_norm_index();

View File

@ -143,7 +143,6 @@ static vpiHandle systask_iter(int, vpiHandle ref)
}
struct systask_def : public __vpiSysTaskCall {
virtual ~systask_def() override {}
virtual int get_type_code(void) const override { return vpiSysTaskCall; }
virtual int vpi_get(int code) override { return systask_get(code, this); }
virtual char*vpi_get_str(int code) override { return systask_get_str(code, this); }
@ -152,7 +151,6 @@ struct systask_def : public __vpiSysTaskCall {
};
struct sysfunc_def : public systask_def {
virtual ~sysfunc_def() override {};
virtual int get_type_code(void) const override { return vpiSysFuncCall; }
virtual int vpi_get(int code) override { return sysfunc_get(code, this); }
};
@ -258,7 +256,7 @@ int sysfunc_vec4::vpi_get(int code)
}
}
vpiHandle sysfunc_vec4::put_value_scalar_(p_vpi_value vp)
vpiHandle sysfunc_vec4::put_value_scalar_(const p_vpi_value vp)
{
switch (vp->value.scalar) {
case vpi0:

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001-2024 Stephen Williams (steve@icarus.com)
* Copyright (c) 2001-2025 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
@ -597,7 +597,7 @@ template vvp_vector4_t coerce_to_width(const vvp_vector4_t&that,
unsigned width);
static void multiply_array_imm(unsigned long*res, unsigned long*val,
static void multiply_array_imm(unsigned long*res, const unsigned long*val,
unsigned words, unsigned long imm)
{
for (unsigned idx = 0 ; idx < words ; idx += 1)
@ -1103,10 +1103,10 @@ bool of_ASSIGN_AR(vthread_t thr, vvp_code_t cp)
bool of_ASSIGN_ARD(vthread_t thr, vvp_code_t cp)
{
long adr = thr->words[3].w_int;
vvp_time64_t delay = thr->words[cp->bit_idx[0]].w_uint;
double value = thr->pop_real();
if (adr >= 0) {
vvp_time64_t delay = thr->words[cp->bit_idx[0]].w_uint;
schedule_assign_array_word(cp->array, adr, value, delay);
}
@ -2665,7 +2665,7 @@ bool of_DISABLE(vthread_t thr, vvp_code_t cp)
bool of_DISABLE_FLOW(vthread_t thr, vvp_code_t cp)
{
__vpiScope*scope = static_cast<__vpiScope*>(cp->handle);
const __vpiScope*scope = static_cast<__vpiScope*>(cp->handle);
vthread_t cur = thr;
while (cur && cur->parent_scope != scope)
@ -2753,7 +2753,7 @@ static unsigned long divide2words(unsigned long a, unsigned long b,
return result + a/b;
}
static unsigned long* divide_bits(unsigned long*ap, unsigned long*bp, unsigned wid)
static unsigned long* divide_bits(unsigned long*ap, const unsigned long*bp, unsigned wid)
{
// Do all our work a cpu-word at a time. The "words" variable
// is the number of words of the wid.
@ -3815,13 +3815,13 @@ bool of_JOIN_DETACH(vthread_t thr, vvp_code_t cp)
bool of_LOAD_AR(vthread_t thr, vvp_code_t cp)
{
unsigned idx = cp->bit_idx[0];
unsigned adr = thr->words[idx].w_int;
double word;
/* The result is 0.0 if the address is undefined. */
if (thr->flags[4] == BIT4_1) {
word = 0.0;
} else {
unsigned adr = thr->words[idx].w_int;
word = cp->array->get_word_r(adr);
}
@ -3900,13 +3900,13 @@ bool of_LOAD_OBJ(vthread_t thr, vvp_code_t cp)
bool of_LOAD_OBJA(vthread_t thr, vvp_code_t cp)
{
unsigned idx = cp->bit_idx[0];
unsigned adr = thr->words[idx].w_int;
vvp_object_t word;
/* The result is 0.0 if the address is undefined. */
if (thr->flags[4] == BIT4_1) {
; // Return nil
} else {
unsigned adr = thr->words[idx].w_int;
cp->array->get_word_obj(adr, word);
}
@ -3950,12 +3950,12 @@ bool of_LOAD_STR(vthread_t thr, vvp_code_t cp)
bool of_LOAD_STRA(vthread_t thr, vvp_code_t cp)
{
unsigned idx = cp->bit_idx[0];
unsigned adr = thr->words[idx].w_int;
string word;
if (thr->flags[4] == BIT4_1) {
word = "";
} else {
unsigned adr = thr->words[idx].w_int;
word = cp->array->get_word_str(adr);
}
@ -5124,7 +5124,6 @@ static bool qinsert(vthread_t thr, vvp_code_t cp, unsigned wid=0)
int64_t idx = thr->words[3].w_int;
ELEM value;
vvp_net_t*net = cp->net;
unsigned max_size = thr->words[cp->bit_idx[0]].w_int;
pop_value(thr, value, wid); // Pop the value to store.
vvp_queue*queue = get_queue_object<QTYPE>(thr, net);
@ -5142,8 +5141,10 @@ static bool qinsert(vthread_t thr, vvp_code_t cp, unsigned wid=0)
<< get_queue_type(value) << " index. ";
print_queue_value(value);
cerr << " was not added." << endl;
} else
} else {
unsigned max_size = thr->words[cp->bit_idx[0]].w_int;
queue->insert(idx, value, max_size);
}
return true;
}
@ -6027,7 +6028,6 @@ static bool store_qdar(vthread_t thr, vvp_code_t cp, unsigned wid=0)
int64_t idx = thr->words[3].w_int;
ELEM value;
vvp_net_t*net = cp->net;
unsigned max_size = thr->words[cp->bit_idx[0]].w_int;
pop_value(thr, value, wid); // Pop the value to store.
vvp_queue*queue = get_queue_object<QTYPE>(thr, net);
@ -6045,8 +6045,10 @@ static bool store_qdar(vthread_t thr, vvp_code_t cp, unsigned wid=0)
<< get_queue_type(value) << " index. ";
print_queue_value(value);
cerr << " was not added." << endl;
} else
} else {
unsigned max_size = thr->words[cp->bit_idx[0]].w_int;
queue->set_word_max(idx, value, max_size);
}
return true;
}
@ -6117,7 +6119,6 @@ static bool store_qobj(vthread_t thr, vvp_code_t cp, unsigned wid=0)
// FIXME: Can we actually use wid here?
(void)wid;
vvp_net_t*net = cp->net;
unsigned max_size = thr->words[cp->bit_idx[0]].w_int;
vvp_queue*queue = get_queue_object<QTYPE>(thr, net);
assert(queue);
@ -6128,8 +6129,10 @@ static bool store_qobj(vthread_t thr, vvp_code_t cp, unsigned wid=0)
// If it is null just clear the queue
if (src.test_nil())
queue->erase_tail(0);
else
else {
unsigned max_size = thr->words[cp->bit_idx[0]].w_int;
queue->copy_elems(src, max_size);
}
return true;
}
@ -6179,12 +6182,13 @@ template <typename ELEM>
static bool storea(vthread_t thr, vvp_code_t cp)
{
unsigned idx = cp->bit_idx[0];
unsigned adr = thr->words[idx].w_int;
ELEM val;
pop_value(thr, val, 0);
if (thr->flags[4] != BIT4_1)
if (thr->flags[4] != BIT4_1) {
unsigned adr = thr->words[idx].w_int;
cp->array->set_word(adr, val);
}
return true;
}
@ -6379,7 +6383,7 @@ bool of_SUBSTR_VEC4(vthread_t thr, vvp_code_t cp)
unsigned wid = cp->bit_idx[1];
int32_t sel = thr->words[sel_idx].w_int;
string&val = thr->peek_str(0);
const string&val = thr->peek_str(0);
assert(wid%8 == 0);

View File

@ -30,7 +30,7 @@ class vvp_cobject : public vvp_object {
public:
explicit vvp_cobject(const class_type*defn);
~vvp_cobject();
~vvp_cobject() override;
void set_vec4(size_t pid, const vvp_vector4_t&val);
void get_vec4(size_t pid, vvp_vector4_t&val);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2012-2020 Stephen Williams (steve@icarus.com)
* Copyright (c) 2012-2025 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
@ -509,10 +509,6 @@ void vvp_queue::push_front(const string&, unsigned)
cerr << "XXXX push_front(string) not implemented for " << typeid(*this).name() << endl;
}
vvp_queue_real::~vvp_queue_real()
{
}
/*
* Helper functions used while copying multiple elements into a queue.
*/
@ -665,10 +661,6 @@ void vvp_queue_real::erase_tail(unsigned idx)
queue.resize(idx);
}
vvp_queue_string::~vvp_queue_string()
{
}
void vvp_queue_string::copy_elems(vvp_object_t src, unsigned max_size)
{
if (vvp_queue*src_queue = src.peek<vvp_queue>())
@ -777,10 +769,6 @@ void vvp_queue_string::erase_tail(unsigned idx)
queue.resize(idx);
}
vvp_queue_vec4::~vvp_queue_vec4()
{
}
void vvp_queue_vec4::copy_elems(vvp_object_t src, unsigned max_size)
{
if (vvp_queue*src_queue = src.peek<vvp_queue>())

View File

@ -70,7 +70,7 @@ class vvp_darray_vec4 : public vvp_darray {
public:
inline vvp_darray_vec4(size_t siz, unsigned word_wid) :
array_(siz), word_wid_(word_wid) { }
~vvp_darray_vec4();
~vvp_darray_vec4() override;
size_t get_size(void) const override;
void set_word(unsigned adr, const vvp_vector4_t&value) override;
@ -89,7 +89,7 @@ class vvp_darray_vec2 : public vvp_darray {
public:
inline vvp_darray_vec2(size_t siz, unsigned word_wid) :
array_(siz), word_wid_(word_wid) { }
~vvp_darray_vec2();
~vvp_darray_vec2() override;
size_t get_size(void) const override;
void set_word(unsigned adr, const vvp_vector4_t&value) override;
@ -106,7 +106,7 @@ class vvp_darray_real : public vvp_darray {
public:
explicit inline vvp_darray_real(size_t siz) : array_(siz) { }
~vvp_darray_real();
~vvp_darray_real() override;
size_t get_size(void) const override;
void set_word(unsigned adr, double value) override;
@ -123,7 +123,7 @@ class vvp_darray_string : public vvp_darray {
public:
explicit inline vvp_darray_string(size_t siz) : array_(siz) { }
~vvp_darray_string();
~vvp_darray_string() override;
size_t get_size(void) const override;
void set_word(unsigned adr, const std::string&value) override;
@ -139,7 +139,7 @@ class vvp_darray_object : public vvp_darray {
public:
explicit inline vvp_darray_object(size_t siz) : array_(siz) { }
~vvp_darray_object();
~vvp_darray_object() override;
size_t get_size(void) const override;
void set_word(unsigned adr, const vvp_object_t&value) override;
@ -155,7 +155,7 @@ class vvp_queue : public vvp_darray {
public:
inline vvp_queue(void) { }
~vvp_queue();
~vvp_queue() override;
virtual size_t get_size(void) const override =0;
virtual void copy_elems(vvp_object_t src, unsigned max_size);
@ -184,8 +184,6 @@ class vvp_queue : public vvp_darray {
class vvp_queue_real : public vvp_queue {
public:
~vvp_queue_real() override;
size_t get_size(void) const override { return queue.size(); };
void copy_elems(vvp_object_t src, unsigned max_size) override;
void set_word_max(unsigned adr, double value, unsigned max_size) override;
@ -206,8 +204,6 @@ class vvp_queue_real : public vvp_queue {
class vvp_queue_string : public vvp_queue {
public:
~vvp_queue_string() override;
size_t get_size(void) const override { return queue.size(); };
void copy_elems(vvp_object_t src, unsigned max_size) override;
void set_word_max(unsigned adr, const std::string&value, unsigned max_size) override;
@ -228,8 +224,6 @@ class vvp_queue_string : public vvp_queue {
class vvp_queue_vec4 : public vvp_queue {
public:
~vvp_queue_vec4() override;
size_t get_size(void) const override { return queue.size(); };
void copy_elems(vvp_object_t src, unsigned max_size) override;
void set_word_max(unsigned adr, const vvp_vector4_t&value, unsigned max_size) override;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008-2022 Stephen Williams (steve@icarus.com)
* Copyright (c) 2008-2025 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
@ -274,8 +274,8 @@ void compile_island_base(char*label, vvp_island*use_island)
island_table->sym_set_value(label, use_island);
island_count += 1;
island_list = (vvp_island **)realloc(island_list,
island_count*sizeof(vvp_island **));
island_list = static_cast<vvp_island **>(realloc(island_list,
island_count*sizeof(vvp_island **)));
island_list[island_count-1] = use_island;
free(label);
}

View File

@ -61,7 +61,7 @@ class vvp_island : private vvp_gen_event_s {
public:
vvp_island();
virtual ~vvp_island();
virtual ~vvp_island() override;
// Ports call this method to flag that something happened at
// the input. The island will use this to create an active
@ -123,7 +123,7 @@ class vvp_island_port : public vvp_net_fun_t {
public:
explicit vvp_island_port(vvp_island*ip);
~vvp_island_port();
~vvp_island_port() override;
public: // Implement vvp_net_fun_t methods
virtual void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
@ -163,7 +163,7 @@ class vvp_island_port : public vvp_net_fun_t {
inline vvp_vector8_t island_get_value(vvp_net_t*net)
{
vvp_island_port*fun = dynamic_cast<vvp_island_port*>(net->fun);
vvp_wire_vec8*fil = dynamic_cast<vvp_wire_vec8*>(net->fil);
const vvp_wire_vec8*fil = dynamic_cast<vvp_wire_vec8*>(net->fil);
if (fil == 0) {
return fun->invalue;
@ -185,7 +185,7 @@ inline vvp_vector8_t island_get_value(vvp_net_t*net)
inline vvp_vector8_t island_get_sent_value(vvp_net_t*net)
{
vvp_island_port*fun = dynamic_cast<vvp_island_port*>(net->fun);
const vvp_island_port*fun = dynamic_cast<vvp_island_port*>(net->fun);
return fun->outvalue;
}

View File

@ -75,8 +75,8 @@ void* vvp_net_t::operator new (size_t size)
VALGRIND_MAKE_MEM_NOACCESS(vvp_net_alloc_table, size*VVP_NET_CHUNK);
VALGRIND_CREATE_MEMPOOL(vvp_net_alloc_table, 0, 0);
vvp_net_pool_count += 1;
vvp_net_pool = (vvp_net_t **) realloc(vvp_net_pool,
vvp_net_pool_count*sizeof(vvp_net_t **));
vvp_net_pool = static_cast<vvp_net_t **>(realloc(vvp_net_pool,
vvp_net_pool_count*sizeof(vvp_net_t **)));
vvp_net_pool[vvp_net_pool_count-1] = vvp_net_alloc_table;
#endif
}
@ -104,8 +104,8 @@ static unsigned local_net_pool_count = 0;
void pool_local_net(vvp_net_t*net)
{
local_net_pool_count += 1;
local_net_pool = (vvp_net_t **) realloc(local_net_pool,
local_net_pool_count*sizeof(vvp_net_t **));
local_net_pool = static_cast<vvp_net_t **>(realloc(local_net_pool,
local_net_pool_count*sizeof(vvp_net_t **)));
local_net_pool[local_net_pool_count-1] = net;
}
@ -2744,7 +2744,6 @@ static void multiply_long(unsigned long a, unsigned long b,
res[0] &= word_mask;
tmpa = (a >> 4UL*sizeof(unsigned long)) & word_mask;
tmpb = b & word_mask;
res[1] += tmpa * tmpb;
res[2] = res[1] >> 4UL*sizeof(unsigned long);
res[1] &= word_mask;
@ -2758,7 +2757,6 @@ static void multiply_long(unsigned long a, unsigned long b,
res[2] &= word_mask;
tmpa = (a >> 4UL*sizeof(unsigned long)) & word_mask;
tmpb = (b >> 4UL*sizeof(unsigned long)) & word_mask;
res[2] += tmpa * tmpb;
res[3] += res[2] >> 4UL*sizeof(unsigned long);
res[2] &= word_mask;

View File

@ -627,7 +627,7 @@ class vvp_vector4array_sa : public vvp_vector4array_t {
public:
vvp_vector4array_sa(unsigned width, unsigned words);
~vvp_vector4array_sa();
~vvp_vector4array_sa() override;
vvp_vector4_t get_word(unsigned idx) const override;
void set_word(unsigned idx, const vvp_vector4_t&that) override;
@ -643,7 +643,7 @@ class vvp_vector4array_aa : public vvp_vector4array_t, public automatic_hooks_s
public:
vvp_vector4array_aa(unsigned width, unsigned words);
~vvp_vector4array_aa();
~vvp_vector4array_aa() override;
void alloc_instance(vvp_context_t context) override;
void reset_instance(vvp_context_t context) override;
@ -1278,7 +1278,7 @@ class vvp_net_fil_t : public vvp_vpi_callback {
public:
vvp_net_fil_t();
virtual ~vvp_net_fil_t();
virtual ~vvp_net_fil_t() override;
public:
enum prop_t { STOP=0, PROP, REPL };
@ -1388,7 +1388,7 @@ class vvp_fun_force : public vvp_net_fun_t {
public:
vvp_fun_force();
~vvp_fun_force();
~vvp_fun_force() override;
void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
vvp_context_t context) override;
@ -1410,7 +1410,7 @@ class vvp_fun_drive : public vvp_net_fun_t {
public:
vvp_fun_drive(unsigned str0 =6, unsigned str1 =6);
~vvp_fun_drive();
~vvp_fun_drive() override;
void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
vvp_context_t context) override;
@ -1432,7 +1432,7 @@ class vvp_fun_extend_signed : public vvp_net_fun_t {
public:
explicit vvp_fun_extend_signed(unsigned wid);
~vvp_fun_extend_signed();
~vvp_fun_extend_signed() override;
void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
vvp_context_t context) override;
@ -1471,10 +1471,10 @@ class vvp_wide_fun_core : public vvp_net_fun_t {
public:
vvp_wide_fun_core(vvp_net_t*net, unsigned nports);
virtual ~vvp_wide_fun_core();
virtual ~vvp_wide_fun_core() override;
// These objects are not perm allocated.
void* operator new(std::size_t size) { return ::new char[size]; }
void operator delete(void* ptr) { ::delete[]((char*)ptr); }
void operator delete(void* ptr) { ::delete[](static_cast<char*>(ptr)); }
protected:
void propagate_vec4(const vvp_vector4_t&bit, vvp_time64_t delay =0);
@ -1513,7 +1513,7 @@ class vvp_wide_fun_t : public vvp_net_fun_t {
public:
vvp_wide_fun_t(vvp_wide_fun_core*c, unsigned base);
~vvp_wide_fun_t();
~vvp_wide_fun_t() override;
void recv_vec4(vvp_net_ptr_t port, const vvp_vector4_t&bit,
vvp_context_t context) override;

View File

@ -161,7 +161,7 @@ class vvp_fun_signal4_aa : public vvp_fun_signal_vec, public automatic_signal_ba
public:
explicit vvp_fun_signal4_aa(unsigned wid, vvp_bit4_t init=BIT4_X);
~vvp_fun_signal4_aa();
~vvp_fun_signal4_aa() override;
void alloc_instance(vvp_context_t context) override;
void reset_instance(vvp_context_t context) override;
@ -227,7 +227,7 @@ class vvp_fun_signal_real_aa : public vvp_fun_signal_real, public automatic_sign
public:
explicit vvp_fun_signal_real_aa();
~vvp_fun_signal_real_aa();
~vvp_fun_signal_real_aa() override;
void alloc_instance(vvp_context_t context) override;
void reset_instance(vvp_context_t context) override;
@ -293,7 +293,7 @@ class vvp_fun_signal_string_aa : public vvp_fun_signal_string, public automatic_
public:
explicit vvp_fun_signal_string_aa();
~vvp_fun_signal_string_aa();
~vvp_fun_signal_string_aa() override;
void alloc_instance(vvp_context_t context) override;
void reset_instance(vvp_context_t context) override;
@ -355,7 +355,7 @@ class vvp_fun_signal_object_aa : public vvp_fun_signal_object, public automatic_
public:
explicit vvp_fun_signal_object_aa(unsigned size);
~vvp_fun_signal_object_aa();
~vvp_fun_signal_object_aa() override;
void alloc_instance(vvp_context_t context) override;
void reset_instance(vvp_context_t context) override;
@ -405,7 +405,7 @@ class vvp_wire_base : public vvp_net_fil_t, public vvp_signal_value {
public:
vvp_wire_base();
~vvp_wire_base();
~vvp_wire_base() override;
// Support for $countdrivers
virtual vvp_bit4_t driven_value(unsigned idx) const;