Cleanup cppcheck warnings in vvp

This commit is contained in:
Cary R 2021-01-01 00:19:27 -08:00
parent 053777f16d
commit 66c5d8cc20
10 changed files with 61 additions and 65 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005-2016 Stephen Williams <steve@icarus.com>
* Copyright (c) 2005-2020 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
@ -166,13 +166,13 @@ vvp_fun_delay::vvp_fun_delay(vvp_net_t*n, unsigned width, const vvp_delay_t&d)
// to simulation time units.
__vpiScope*scope = vpip_peek_current_scope();
int pow = scope->time_units - scope->time_precision;
int powr = scope->time_units - scope->time_precision;
round_ = 1;
for (int lp = 0; lp < pow; lp += 1) round_ *= 10;
for (int lp = 0; lp < powr; lp += 1) round_ *= 10;
pow = scope->time_precision - vpip_get_time_precision();
powr = scope->time_precision - vpip_get_time_precision();
scale_ = 1;
for (int lp = 0; lp < pow; lp += 1) scale_ *= 10;
for (int lp = 0; lp < powr; lp += 1) scale_ *= 10;
}
vvp_fun_delay::~vvp_fun_delay()

View File

@ -987,20 +987,20 @@ void compile_event(char*label, char*type, unsigned argc, struct symb_s*argv)
} else {
vvp_fun_edge::edge_t edge = vvp_edge_none;
vvp_fun_edge::edge_t edge_type = vvp_edge_none;
if (strcmp(type,"posedge") == 0)
edge = vvp_edge_posedge;
edge_type = vvp_edge_posedge;
else if (strcmp(type,"negedge") == 0)
edge = vvp_edge_negedge;
edge_type = vvp_edge_negedge;
assert(argc <= 4);
free(type);
if (vpip_peek_current_scope()->is_automatic()) {
fun = new vvp_fun_edge_aa(edge);
fun = new vvp_fun_edge_aa(edge_type);
} else {
fun = new vvp_fun_edge_sa(edge);
fun = new vvp_fun_edge_sa(edge_type);
}
}

View File

@ -461,7 +461,7 @@ void vvp_fun_muxz::run_run()
default:
{
unsigned min_size = a_.size();
unsigned max_size = a_.size();
unsigned max_size = min_size;
if (b_.size() < min_size)
min_size = b_.size();
if (b_.size() > max_size)

View File

@ -894,7 +894,7 @@ void schedule_propagate_vector(vvp_net_t*net,
void schedule_assign_array_word(vvp_array_t mem,
unsigned word_addr,
unsigned off,
vvp_vector4_t val,
const vvp_vector4_t&val,
vvp_time64_t delay)
{
struct assign_array_word_s*cur = new struct assign_array_word_s;
@ -926,7 +926,7 @@ void schedule_set_vector(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
schedule_event_(cur, 0, SEQ_ACTIVE);
}
void schedule_set_vector(vvp_net_ptr_t ptr, vvp_vector8_t bit)
void schedule_set_vector(vvp_net_ptr_t ptr, const vvp_vector8_t&bit)
{
struct assign_vector8_event_s*cur = new struct assign_vector8_event_s;
cur->ptr = ptr;
@ -942,7 +942,7 @@ void schedule_set_vector(vvp_net_ptr_t ptr, double bit)
schedule_event_(cur, 0, SEQ_ACTIVE);
}
void schedule_init_vector(vvp_net_ptr_t ptr, vvp_vector4_t bit)
void schedule_init_vector(vvp_net_ptr_t ptr, const vvp_vector4_t&bit)
{
struct assign_vector4_event_s*cur = new struct assign_vector4_event_s(bit);
cur->ptr = ptr;
@ -951,7 +951,7 @@ void schedule_init_vector(vvp_net_ptr_t ptr, vvp_vector4_t bit)
schedule_init_event(cur);
}
void schedule_init_vector(vvp_net_ptr_t ptr, vvp_vector8_t bit)
void schedule_init_vector(vvp_net_ptr_t ptr, const vvp_vector8_t&bit)
{
struct assign_vector8_event_s*cur = new struct assign_vector8_event_s;
cur->ptr = ptr;

View File

@ -1,7 +1,7 @@
#ifndef IVL_schedule_H
#define IVL_schedule_H
/*
* Copyright (c) 2001-2017 Stephen Williams (steve@icarus.com)
* Copyright (c) 2001-2020 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
@ -55,7 +55,7 @@ extern void schedule_assign_vector(vvp_net_ptr_t ptr,
extern void schedule_assign_array_word(vvp_array_t mem,
unsigned word_address,
unsigned off,
vvp_vector4_t val,
const vvp_vector4_t&val,
vvp_time64_t delay);
extern void schedule_assign_array_word(vvp_array_t mem,
@ -85,7 +85,7 @@ extern void schedule_propagate_vector(vvp_net_t*ptr,
* creates an event in the active queue.
*/
extern void schedule_set_vector(vvp_net_ptr_t ptr, const vvp_vector4_t&val);
extern void schedule_set_vector(vvp_net_ptr_t ptr, vvp_vector8_t val);
extern void schedule_set_vector(vvp_net_ptr_t ptr, const vvp_vector8_t&val);
extern void schedule_set_vector(vvp_net_ptr_t ptr, double val);
/*
@ -104,8 +104,8 @@ extern void schedule_t0_trigger(vvp_net_ptr_t ptr);
* variable, but still allows the initial value to be driven
* (propagated as events) through the rest of the net.
*/
extern void schedule_init_vector(vvp_net_ptr_t ptr, vvp_vector4_t val);
extern void schedule_init_vector(vvp_net_ptr_t ptr, vvp_vector8_t val);
extern void schedule_init_vector(vvp_net_ptr_t ptr, const vvp_vector4_t&val);
extern void schedule_init_vector(vvp_net_ptr_t ptr, const vvp_vector8_t&val);
extern void schedule_init_vector(vvp_net_ptr_t ptr, double val);
/*
* The schedule_init_propagate function is similar to the above but

View File

@ -483,7 +483,7 @@ inline static string get_queue_type(string&)
return "queue<string>";
}
inline static string get_queue_type(vvp_vector4_t value)
inline static string get_queue_type(const vvp_vector4_t&value)
{
ostringstream buf;
buf << "queue<vector[" << value.size() << "]>";
@ -496,12 +496,12 @@ inline static void print_queue_value(double value)
cerr << value;
}
inline static void print_queue_value(string value)
inline static void print_queue_value(const string&value)
{
cerr << "\"" << value << "\"";
}
inline static void print_queue_value(vvp_vector4_t value)
inline static void print_queue_value(const vvp_vector4_t&value)
{
cerr << value;
}
@ -1077,7 +1077,7 @@ bool of_ASSIGN_VEC4(vthread_t thr, vvp_code_t cp)
{
vvp_net_ptr_t ptr (cp->net, 0);
unsigned delay = cp->bit_idx[0];
vvp_vector4_t&val = thr->peek_vec4();
const vvp_vector4_t&val = thr->peek_vec4();
schedule_assign_vector(ptr, 0, 0, val, delay);
thr->pop_vec4(1);
@ -1121,7 +1121,6 @@ bool of_ASSIGN_VEC4_A_D(vthread_t thr, vvp_code_t cp)
}
if (off+wid > array_wid) {
val = val.subvalue(0, array_wid-off);
wid = val.size();
}
schedule_assign_array_word(cp->array, adr, off, val, del);
@ -1164,7 +1163,6 @@ bool of_ASSIGN_VEC4_A_E(vthread_t thr, vvp_code_t cp)
}
if (off+wid > array_wid) {
val = val.subvalue(0, array_wid-off);
wid = val.size();
}
if (thr->ecount == 0) {
@ -1213,7 +1211,6 @@ bool of_ASSIGN_VEC4_OFF_D(vthread_t thr, vvp_code_t cp)
}
if (off+wid > sig->value_size()) {
val = val.subvalue(0, sig->value_size()-off);
wid = val.size();
}
schedule_assign_vector(ptr, off, sig->value_size(), val, del);
@ -1255,7 +1252,6 @@ bool of_ASSIGN_VEC4_OFF_E(vthread_t thr, vvp_code_t cp)
}
if (off+wid > sig->value_size()) {
val = val.subvalue(0, sig->value_size()-off);
wid = val.size();
}
if (thr->ecount == 0) {
@ -1809,7 +1805,7 @@ bool of_CMPIE(vthread_t thr, vvp_code_t cp)
{
unsigned wid = cp->number;
vvp_vector4_t&lval = thr->peek_vec4();
const vvp_vector4_t&lval = thr->peek_vec4();
// I expect that most of the bits of an immediate value are
// going to be zero, so start the result vector with all zero
@ -1827,7 +1823,7 @@ bool of_CMPINE(vthread_t thr, vvp_code_t cp)
{
unsigned wid = cp->number;
vvp_vector4_t&lval = thr->peek_vec4();
const vvp_vector4_t&lval = thr->peek_vec4();
// I expect that most of the bits of an immediate value are
// going to be zero, so start the result vector with all zero
@ -1944,7 +1940,7 @@ bool of_CMPIS(vthread_t thr, vvp_code_t cp)
{
unsigned wid = cp->number;
vvp_vector4_t&lval = thr->peek_vec4();
const vvp_vector4_t&lval = thr->peek_vec4();
// I expect that most of the bits of an immediate value are
// going to be zero, so start the result vector with all zero
@ -2080,7 +2076,7 @@ bool of_CMPIU(vthread_t thr, vvp_code_t cp)
{
unsigned wid = cp->number;
vvp_vector4_t&lval = thr->peek_vec4();
const vvp_vector4_t&lval = thr->peek_vec4();
// I expect that most of the bits of an immediate value are
// going to be zero, so start the result vector with all zero
@ -5813,7 +5809,7 @@ inline static string get_darray_type(string&)
return "darray<string>";
}
inline static string get_darray_type(vvp_vector4_t value)
inline static string get_darray_type(const vvp_vector4_t&value)
{
ostringstream buf;
buf << "darray<vector[" << value.size() << "]>";
@ -5975,17 +5971,17 @@ static void pop_prop_val(vthread_t thr, vvp_vector4_t&val, unsigned wid)
val.resize(wid);
}
static void set_val(vvp_cobject*cobj, size_t pid, double&val)
static void set_val(vvp_cobject*cobj, size_t pid, const double&val)
{
cobj->set_real(pid, val);
}
static void set_val(vvp_cobject*cobj, size_t pid, string&val)
static void set_val(vvp_cobject*cobj, size_t pid, const string&val)
{
cobj->set_string(pid, val);
}
static void set_val(vvp_cobject*cobj, size_t pid, vvp_vector4_t&val)
static void set_val(vvp_cobject*cobj, size_t pid, const vvp_vector4_t&val)
{
cobj->set_vec4(pid, val);
}
@ -6202,12 +6198,12 @@ bool of_STORE_QOBJ_V(vthread_t thr, vvp_code_t cp)
return store_qobj<vvp_vector4_t, vvp_queue_vec4>(thr, cp, cp->bit_idx[1]);
}
static void vvp_send(vthread_t thr, vvp_net_ptr_t ptr, double&val)
static void vvp_send(vthread_t thr, vvp_net_ptr_t ptr, const double&val)
{
vvp_send_real(ptr, val, thr->wt_context);
}
static void vvp_send(vthread_t thr, vvp_net_ptr_t ptr, string&val)
static void vvp_send(vthread_t thr, vvp_net_ptr_t ptr, const string&val)
{
vvp_send_string(ptr, val, thr->wt_context);
}
@ -6358,7 +6354,7 @@ bool of_STORE_VEC4A(vthread_t thr, vvp_code_t cp)
unsigned adr_index = cp->bit_idx[0];
unsigned off_index = cp->bit_idx[1];
vvp_vector4_t&value = thr->peek_vec4();
const vvp_vector4_t&value = thr->peek_vec4();
long adr = adr_index? thr->words[adr_index].w_int : 0;
long off = off_index? thr->words[off_index].w_int : 0;

View File

@ -516,7 +516,7 @@ vvp_queue_real::~vvp_queue_real()
/*
* Helper functions used while copying multiple elements into a queue.
*/
static void print_copy_is_too_big(size_t src_size, unsigned max_size, string qtype)
static void print_copy_is_too_big(size_t src_size, unsigned max_size, const string&qtype)
{
cerr << get_fileline()
<< "Warning: queue<" << qtype << "> is bounded to have at most "

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008-2015 Stephen Williams (steve@icarus.com)
* Copyright (c) 2008-2020 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
@ -62,9 +62,9 @@ vvp_island::~vvp_island()
if (!at_EOS) assert(0);
while (branches_) {
vvp_island_branch *next = branches_->next_branch;
vvp_island_branch *next_br = branches_->next_branch;
delete branches_;
branches_ = next;
branches_ = next_br;
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2018 Stephen Williams (steve@icarus.com)
* Copyright (c) 2004-2020 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
@ -561,36 +561,36 @@ unsigned long multiply_with_carry(unsigned long a, unsigned long b,
void vvp_send_vec8(vvp_net_ptr_t ptr, const vvp_vector8_t&val)
{
while (vvp_net_t*cur = ptr.ptr()) {
vvp_net_ptr_t next = cur->port[ptr.port()];
vvp_net_ptr_t next_val = cur->port[ptr.port()];
if (cur->fun)
cur->fun->recv_vec8(ptr, val);
ptr = next;
ptr = next_val;
}
}
void vvp_send_real(vvp_net_ptr_t ptr, double val, vvp_context_t context)
{
while (vvp_net_t*cur = ptr.ptr()) {
vvp_net_ptr_t next = cur->port[ptr.port()];
vvp_net_ptr_t next_val = cur->port[ptr.port()];
if (cur->fun)
cur->fun->recv_real(ptr, val, context);
ptr = next;
ptr = next_val;
}
}
void vvp_send_long(vvp_net_ptr_t ptr, long val)
{
while (vvp_net_t*cur = ptr.ptr()) {
vvp_net_ptr_t next = cur->port[ptr.port()];
vvp_net_ptr_t next_val = cur->port[ptr.port()];
if (cur->fun)
cur->fun->recv_long(ptr, val);
ptr = next;
ptr = next_val;
}
}
@ -598,12 +598,12 @@ void vvp_send_long_pv(vvp_net_ptr_t ptr, long val,
unsigned base, unsigned wid)
{
while (vvp_net_t*cur = ptr.ptr()) {
vvp_net_ptr_t next = cur->port[ptr.port()];
vvp_net_ptr_t next_val = cur->port[ptr.port()];
if (cur->fun)
cur->fun->recv_long_pv(ptr, val, base, wid);
ptr = next;
ptr = next_val;
}
}
@ -3441,7 +3441,7 @@ void vvp_wide_fun_core::recv_real_from_inputs(unsigned)
}
void vvp_wide_fun_core::dispatch_vec4_from_input_(unsigned port,
vvp_vector4_t bit)
const vvp_vector4_t&bit)
{
assert(port < nports_);
if (port_values_ == 0) port_values_ = new vvp_vector4_t [nports_];

View File

@ -1,7 +1,7 @@
#ifndef IVL_vvp_net_H
#define IVL_vvp_net_H
/*
* Copyright (c) 2004-2018 Stephen Williams (steve@icarus.com)
* Copyright (c) 2004-2020 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
@ -1564,7 +1564,7 @@ class vvp_wide_fun_core : public vvp_net_fun_t {
virtual void recv_real_from_inputs(unsigned port);
friend class vvp_wide_fun_t;
void dispatch_vec4_from_input_(unsigned port, vvp_vector4_t bit);
void dispatch_vec4_from_input_(unsigned port, const vvp_vector4_t&bit);
void dispatch_real_from_input_(unsigned port, double bit);
private:
@ -1606,12 +1606,12 @@ class vvp_wide_fun_t : public vvp_net_fun_t {
inline void vvp_send_vec4(vvp_net_ptr_t ptr, const vvp_vector4_t&val, vvp_context_t context)
{
while (class vvp_net_t*cur = ptr.ptr()) {
vvp_net_ptr_t next = cur->port[ptr.port()];
vvp_net_ptr_t next_val = cur->port[ptr.port()];
if (cur->fun)
cur->fun->recv_vec4(ptr, val, context);
ptr = next;
ptr = next_val;
}
}
@ -1625,24 +1625,24 @@ extern void vvp_send_long_pv(vvp_net_ptr_t ptr, long val,
inline void vvp_send_string(vvp_net_ptr_t ptr, const std::string&val, vvp_context_t context)
{
while (vvp_net_t*cur = ptr.ptr()) {
vvp_net_ptr_t next = cur->port[ptr.port()];
vvp_net_ptr_t next_val = cur->port[ptr.port()];
if (cur->fun)
cur->fun->recv_string(ptr, val, context);
ptr = next;
ptr = next_val;
}
}
inline void vvp_send_object(vvp_net_ptr_t ptr, vvp_object_t val, vvp_context_t context)
{
while (vvp_net_t*cur = ptr.ptr()) {
vvp_net_ptr_t next = cur->port[ptr.port()];
vvp_net_ptr_t next_val = cur->port[ptr.port()];
if (cur->fun)
cur->fun->recv_object(ptr, val, context);
ptr = next;
ptr = next_val;
}
}
@ -1670,12 +1670,12 @@ inline void vvp_send_vec4_pv(vvp_net_ptr_t ptr, const vvp_vector4_t&val,
vvp_context_t context)
{
while (class vvp_net_t*cur = ptr.ptr()) {
vvp_net_ptr_t next = cur->port[ptr.port()];
vvp_net_ptr_t next_val = cur->port[ptr.port()];
if (cur->fun)
cur->fun->recv_vec4_pv(ptr, val, base, wid, vwid, context);
ptr = next;
ptr = next_val;
}
}
@ -1683,12 +1683,12 @@ inline void vvp_send_vec8_pv(vvp_net_ptr_t ptr, const vvp_vector8_t&val,
unsigned base, unsigned wid, unsigned vwid)
{
while (class vvp_net_t*cur = ptr.ptr()) {
vvp_net_ptr_t next = cur->port[ptr.port()];
vvp_net_ptr_t next_val = cur->port[ptr.port()];
if (cur->fun)
cur->fun->recv_vec8_pv(ptr, val, base, wid, vwid);
ptr = next;
ptr = next_val;
}
}