Cleanup vhdl and most of vvp cppcheck issues
This commit is contained in:
parent
c3d550e03e
commit
e51ce2a8e9
|
|
@ -32,9 +32,9 @@ void require_support_function(support_function_t f)
|
|||
scope->add_decl(new support_function(f));
|
||||
}
|
||||
|
||||
const char *support_function::function_name(support_function_t type)
|
||||
const char *support_function::function_name(support_function_t sf_type)
|
||||
{
|
||||
switch (type) {
|
||||
switch (sf_type) {
|
||||
case SF_UNSIGNED_TO_BOOLEAN: return "Unsigned_To_Boolean";
|
||||
case SF_SIGNED_TO_BOOLEAN: return "Signed_To_Boolean";
|
||||
case SF_BOOLEAN_TO_LOGIC: return "Boolean_To_Logic";
|
||||
|
|
@ -54,9 +54,9 @@ const char *support_function::function_name(support_function_t type)
|
|||
return "Invalid";
|
||||
}
|
||||
|
||||
vhdl_type *support_function::function_type(support_function_t type)
|
||||
vhdl_type *support_function::function_type(support_function_t sf_type)
|
||||
{
|
||||
switch (type) {
|
||||
switch (sf_type) {
|
||||
case SF_UNSIGNED_TO_BOOLEAN:
|
||||
case SF_SIGNED_TO_BOOLEAN:
|
||||
return vhdl_type::boolean();
|
||||
|
|
@ -105,9 +105,9 @@ void support_function::emit_reduction(std::ostream &of, int level,
|
|||
|
||||
void support_function::emit(std::ostream &of, int level) const
|
||||
{
|
||||
of << nl_string(level) << "function " << function_name(type_);
|
||||
of << nl_string(level) << "function " << function_name(sf_type_);
|
||||
|
||||
switch (type_) {
|
||||
switch (sf_type_) {
|
||||
case SF_UNSIGNED_TO_BOOLEAN:
|
||||
of << "(X : unsigned) return Boolean is" << nl_string(level)
|
||||
<< "begin" << nl_string(indent(level))
|
||||
|
|
|
|||
|
|
@ -41,19 +41,19 @@ enum support_function_t {
|
|||
|
||||
class support_function : public vhdl_function {
|
||||
public:
|
||||
explicit support_function(support_function_t type)
|
||||
: vhdl_function(function_name(type), function_type(type)),
|
||||
type_(type) {}
|
||||
explicit support_function(support_function_t sf_type)
|
||||
: vhdl_function(function_name(sf_type), function_type(sf_type)),
|
||||
sf_type_(sf_type) {}
|
||||
void emit(std::ostream &of, int level) const override;
|
||||
static const char *function_name(support_function_t type);
|
||||
static vhdl_type *function_type(support_function_t type);
|
||||
static const char *function_name(support_function_t sf_type);
|
||||
static vhdl_type *function_type(support_function_t sf_type);
|
||||
|
||||
private:
|
||||
static void emit_ternary(std::ostream &of, int level);
|
||||
static void emit_reduction(std::ostream &of, int level, const char *op,
|
||||
char unit);
|
||||
|
||||
support_function_t type_;
|
||||
support_function_t sf_type_;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -2,6 +2,13 @@
|
|||
// text is used in strchr()/strrchr() which take a char* not a const char*
|
||||
constParameterPointer:lexor.lex:698
|
||||
|
||||
// Yes, the assetion should always trigger
|
||||
incorrectStringBooleanError:expression_stream.cc:153
|
||||
incorrectStringBooleanError:expression_stream.cc:158
|
||||
|
||||
// cppcheck is wrong this cannot be a const
|
||||
constVariableReference:library.cc:255
|
||||
|
||||
// We only use a StringHeap or a StringHepLex
|
||||
duplInheritedMember:libmisc/StringHeap.h:99
|
||||
duplInheritedMember:libmisc/StringHeap.h:100
|
||||
|
|
|
|||
|
|
@ -76,12 +76,15 @@ ExpAttribute::~ExpAttribute()
|
|||
list<Expression*>*ExpAttribute::clone_args() const {
|
||||
list<Expression*>*new_args = NULL;
|
||||
|
||||
ivl_assert(*this, !args_);
|
||||
/* This is not a proper implementation so assert for now.
|
||||
if(args_) {
|
||||
for(list<Expression*>::iterator it = args_->begin();
|
||||
it != args_->end(); ++it) {
|
||||
new_args->push_back((*it)->clone());
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
return new_args;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -438,7 +438,6 @@ class ExpTypeAttribute : public ExpAttribute {
|
|||
int elaborate_expr(Entity*ent, ScopeBase*scope, const VType*ltype) override;
|
||||
void write_to_stream(std::ostream&fd) const override;
|
||||
// Some attributes can be evaluated at compile time
|
||||
bool evaluate(ScopeBase*scope, int64_t&val) const;
|
||||
bool evaluate(Entity*ent, ScopeBase*scope, int64_t&val) const override;
|
||||
void dump(std::ostream&out, int indent = 0) const override;
|
||||
void visit(ExprVisitor& func) override;
|
||||
|
|
|
|||
|
|
@ -386,7 +386,7 @@ class VTypeRecord : public VType {
|
|||
|
||||
bool can_be_packed() const override { return true; }
|
||||
const element_t* element_by_name(perm_string name, int*index = NULL) const;
|
||||
inline const std::vector<element_t*> get_elements() const { return elements_; }
|
||||
inline const std::vector<element_t*>&get_elements() const { return elements_; }
|
||||
|
||||
private:
|
||||
std::vector<element_t*> elements_;
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ invalidPointerCast:class_type.cc:332
|
|||
invalidPointerCast:class_type.cc:338
|
||||
invalidPointerCast:class_type.cc:339
|
||||
cstyleCast:ufunc.cc:80
|
||||
cstyleCast:vpi_priv.cc:226
|
||||
cstyleCast:vpi_scope.cc:615
|
||||
|
||||
// Skip the sscanf() field width limit warning
|
||||
invalidscanf:compile.cc:597
|
||||
|
|
@ -29,6 +31,11 @@ invalidscanf:compile.cc:609
|
|||
// By convention we put statics at the top scope.
|
||||
variableScope:vpi_priv.cc:623
|
||||
|
||||
// Changing this breaks the compile
|
||||
constParameterPointer:vthread.cc:423
|
||||
useInitializationList:delay.cc:513
|
||||
constParameterPointer:vpi_priv.cc:1434
|
||||
|
||||
// Operator new/delete are static so cannot override
|
||||
duplInheritedMember:vvp_net.h:1476
|
||||
duplInheritedMember:vvp_net.h:1477
|
||||
|
|
@ -49,20 +56,20 @@ duplInheritedMember:vvp_net_sig.cc:810
|
|||
duplInheritedMember:vvp_net_sig.cc:815
|
||||
duplInheritedMember:schedule.cc:143
|
||||
duplInheritedMember:schedule.cc:149
|
||||
duplInheritedMember:schedule.cc:212
|
||||
duplInheritedMember:schedule.cc:218
|
||||
duplInheritedMember:schedule.cc:249
|
||||
duplInheritedMember:schedule.cc:255
|
||||
duplInheritedMember:schedule.cc:286
|
||||
duplInheritedMember:schedule.cc:292
|
||||
duplInheritedMember:schedule.cc:319
|
||||
duplInheritedMember:schedule.cc:325
|
||||
duplInheritedMember:schedule.cc:391
|
||||
duplInheritedMember:schedule.cc:397
|
||||
duplInheritedMember:schedule.cc:480
|
||||
duplInheritedMember:schedule.cc:486
|
||||
duplInheritedMember:schedule.cc:521
|
||||
duplInheritedMember:schedule.cc:527
|
||||
duplInheritedMember:schedule.cc:213
|
||||
duplInheritedMember:schedule.cc:219
|
||||
duplInheritedMember:schedule.cc:250
|
||||
duplInheritedMember:schedule.cc:256
|
||||
duplInheritedMember:schedule.cc:287
|
||||
duplInheritedMember:schedule.cc:293
|
||||
duplInheritedMember:schedule.cc:320
|
||||
duplInheritedMember:schedule.cc:326
|
||||
duplInheritedMember:schedule.cc:393
|
||||
duplInheritedMember:schedule.cc:399
|
||||
duplInheritedMember:schedule.cc:484
|
||||
duplInheritedMember:schedule.cc:490
|
||||
duplInheritedMember:schedule.cc:525
|
||||
duplInheritedMember:schedule.cc:531
|
||||
|
||||
// The derived class calls the base class routine and uses private inheritance
|
||||
duplInheritedMember:symbols.h:112
|
||||
|
|
@ -72,6 +79,14 @@ duplicateValueTernary:class_type.cc:268
|
|||
|
||||
// cppcheck is wrong this can be true or false
|
||||
knownConditionTrueFalse:vthread.cc:2986
|
||||
knownConditionTrueFalse:vpi_priv.cc:657
|
||||
knownConditionTrueFalse:vpi_priv.cc:1955
|
||||
|
||||
// cppcheck is wrong this is already const
|
||||
constParameterPointer:vpi_tasks.cc:259
|
||||
|
||||
// For some cases this expression can be different
|
||||
duplicateExpression:vpi_signal.cc:1189
|
||||
|
||||
// cppcheck does not relize this is deleted[] in the called routine
|
||||
leakNoVarFunctionCall:compile.cc:452
|
||||
|
|
@ -96,6 +111,28 @@ uninitMemberVar:delay.cc:1005
|
|||
uninitMemberVar:delay.cc:1045
|
||||
// The intermod path has the values added after creation
|
||||
uninitMemberVar:delay.cc:1395
|
||||
// The island values are set after creation
|
||||
uninitDerivedMemberVar:island_tran.cc:60
|
||||
// The cb_data is set after creation
|
||||
uninitMemberVar:vpi_callback.cc:182
|
||||
// The funct is set after creation
|
||||
uninitMemberVar:vpi_event.cc:28
|
||||
// Iterator values are set after creation
|
||||
uninitMemberVar:vpi_iter.cc:41
|
||||
// Scope values are set after creation
|
||||
uninitMemberVar:vpi_scope.cc:353
|
||||
// The real var values are set after creation
|
||||
uninitMemberVar:vpi_real.cc:158
|
||||
// The PV values are set after creation
|
||||
uninitMemberVar:vpi_signal.cc:1577
|
||||
// The info/is_user_defn are added ater creation
|
||||
uninitMemberVar:vpi_tasks.cc:41
|
||||
// All the values are set after creation using the default constructor
|
||||
noConstructor:vpi_tasks.cc:158
|
||||
|
||||
// We check memory usage using valgrind.
|
||||
unsafeClassCanLeak:vpi_priv.h:750
|
||||
unsafeClassCanLeak:permaheap.h:47
|
||||
|
||||
// Index calculation
|
||||
thisSubtraction:vpi_priv.h:430
|
||||
|
|
@ -104,6 +141,7 @@ thisSubtraction:array_common.h:91
|
|||
// The interface is from the standard.
|
||||
constParameterCallback:vpi_priv.cc:1110
|
||||
constParameterPointer:vpi_mcd.cc:158
|
||||
constParameterPointer:vpi_priv.cc:1110
|
||||
|
||||
// cppcheck is missing the code adds a \0 at the previous location.
|
||||
knownConditionTrueFalse:vpi_modules.cc:118
|
||||
|
|
@ -184,7 +222,7 @@ unusedFunction:array.cc:848
|
|||
// intermodpath_delete()
|
||||
unusedFunction:delay.cc:1462
|
||||
// count_force4_pool()
|
||||
unusedFunction:schedule.cc:402
|
||||
unusedFunction:schedule.cc:404
|
||||
// call_scope()
|
||||
unusedFunction:ufunc.h:62
|
||||
// get_bit()
|
||||
|
|
@ -192,13 +230,13 @@ unusedFunction:vpi_priv.h:477
|
|||
// copy_bits()
|
||||
unusedFunction:vvp_net.cc:615
|
||||
// mov()
|
||||
unusedFunction:vvp_net.cc:1546
|
||||
unusedFunction:vvp_net.cc:1547
|
||||
// eq_xz()
|
||||
unusedFunction:vvp_net.cc:1751
|
||||
unusedFunction:vvp_net.cc:1752
|
||||
// as_string()
|
||||
unusedFunction:vvp_net.cc:1854
|
||||
unusedFunction:vvp_net.cc:1855
|
||||
// fully_featured_resolv_()
|
||||
unusedFunction:vvp_net.cc:3580
|
||||
unusedFunction:vvp_net.cc:3581
|
||||
// words()
|
||||
unusedFunction:vvp_net.h:595
|
||||
// force_vec8()
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2005-2025 Stephen Williams <steve@icarus.com>
|
||||
* Copyright (c) 2005-2026 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
|
||||
|
|
@ -489,19 +489,19 @@ void vvp_fun_delay::run_run()
|
|||
delete cur;
|
||||
}
|
||||
|
||||
void vvp_fun_delay::run_run_vec4_(struct event_*cur)
|
||||
void vvp_fun_delay::run_run_vec4_(const struct event_*cur)
|
||||
{
|
||||
cur_vec4_ = cur->ptr_vec4;
|
||||
net_->send_vec4(cur_vec4_, 0);
|
||||
}
|
||||
|
||||
void vvp_fun_delay::run_run_vec8_(struct vvp_fun_delay::event_*cur)
|
||||
void vvp_fun_delay::run_run_vec8_(const struct vvp_fun_delay::event_*cur)
|
||||
{
|
||||
cur_vec8_ = cur->ptr_vec8;
|
||||
net_->send_vec8(cur_vec8_);
|
||||
}
|
||||
|
||||
void vvp_fun_delay::run_run_real_(struct vvp_fun_delay::event_*cur)
|
||||
void vvp_fun_delay::run_run_real_(const struct vvp_fun_delay::event_*cur)
|
||||
{
|
||||
cur_real_ = cur->ptr_real;
|
||||
net_->send_real(cur_real_, 0);
|
||||
|
|
|
|||
10
vvp/delay.h
10
vvp/delay.h
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef IVL_delay_H
|
||||
#define IVL_delay_H
|
||||
/*
|
||||
* Copyright 2005-2025 Stephen Williams
|
||||
* Copyright 2005-2026 Stephen Williams
|
||||
*
|
||||
* This source code is free software; you can redistribute it
|
||||
* and/or modify it in source code form under the terms of the GNU
|
||||
|
|
@ -80,7 +80,7 @@ class vvp_fun_delay : public vvp_net_fun_t, private vvp_gen_event_s {
|
|||
ptr_real = 0.0;
|
||||
next = NULL;
|
||||
}
|
||||
void (vvp_fun_delay::*run_run_ptr)(struct vvp_fun_delay::event_*cur);
|
||||
void (vvp_fun_delay::*run_run_ptr)(const struct vvp_fun_delay::event_*cur);
|
||||
const vvp_time64_t sim_time;
|
||||
vvp_vector4_t ptr_vec4;
|
||||
vvp_vector8_t ptr_vec8;
|
||||
|
|
@ -107,9 +107,9 @@ class vvp_fun_delay : public vvp_net_fun_t, private vvp_gen_event_s {
|
|||
virtual void run_run() override;
|
||||
|
||||
|
||||
void run_run_vec4_(struct vvp_fun_delay::event_*cur);
|
||||
void run_run_vec8_(struct vvp_fun_delay::event_*cur);
|
||||
void run_run_real_(struct vvp_fun_delay::event_*cur);
|
||||
void run_run_vec4_(const struct vvp_fun_delay::event_*cur);
|
||||
void run_run_vec8_(const struct vvp_fun_delay::event_*cur);
|
||||
void run_run_real_(const struct vvp_fun_delay::event_*cur);
|
||||
|
||||
private:
|
||||
vvp_net_t*net_;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2001-2025 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 2001-2026 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
|
||||
|
|
@ -65,7 +65,7 @@ struct event_s {
|
|||
|
||||
// Fallback new/delete
|
||||
static void*operator new (size_t size) { return ::new char[size]; }
|
||||
static void operator delete(void*ptr) { ::delete[]( (char*)ptr ); }
|
||||
static void operator delete(void*ptr) { ::delete[]( static_cast<char*>(ptr) ); }
|
||||
};
|
||||
|
||||
void event_s::single_step_display(void)
|
||||
|
|
@ -174,6 +174,7 @@ struct assign_vector4_event_s : public event_s {
|
|||
explicit assign_vector4_event_s(const vvp_vector4_t&that) : val(that) {
|
||||
base = 0;
|
||||
vwid = 0;
|
||||
next = NULL;
|
||||
}
|
||||
|
||||
/* Where to do the assign. */
|
||||
|
|
@ -335,6 +336,7 @@ struct force_vector4_event_s : public event_s {
|
|||
net = NULL;
|
||||
base = 0;
|
||||
vwid = 0;
|
||||
next = NULL;
|
||||
}
|
||||
/* Where to do the force. */
|
||||
vvp_net_t*net;
|
||||
|
|
@ -409,11 +411,13 @@ struct propagate_vector4_event_s : public event_s {
|
|||
/* The default constructor. */
|
||||
explicit propagate_vector4_event_s(const vvp_vector4_t&that) : val(that) {
|
||||
net = NULL;
|
||||
next = NULL;
|
||||
}
|
||||
/* A constructor that makes the val directly. */
|
||||
propagate_vector4_event_s(const vvp_vector4_t&that, unsigned adr, unsigned wid)
|
||||
: val(that,adr,wid) {
|
||||
net = NULL;
|
||||
next = NULL;
|
||||
}
|
||||
|
||||
/* Propagate the output of this net. */
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2005-2025 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 2005-2026 Stephen Williams (steve@icarus.com)
|
||||
*
|
||||
* (This is a rewrite of code that was ...
|
||||
* Copyright (c) 2001 Stephan Boettcher <stephan@nevis.columbia.edu>)
|
||||
|
|
@ -935,7 +935,8 @@ void vvp_udp_fun_core::run_run()
|
|||
void vvp_udp_fun_core::recv_vec4_from_inputs(unsigned port)
|
||||
{
|
||||
/* For now, assume udps are 1-bit wide. */
|
||||
assert(value(port).size() == 1);
|
||||
unsigned port_width = value(port).size();
|
||||
assert(port_width == 1);
|
||||
|
||||
unsigned long mask = 1UL << port;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2001-2025 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 2001-2026 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 2001 Stephan Boettcher <stephan@nevis.columbia.edu>
|
||||
*
|
||||
* This source code is free software; you can redistribute it
|
||||
|
|
@ -285,15 +285,15 @@ class __vpiVThrVec4Stack : public __vpiHandle {
|
|||
void vpi_get_value(p_vpi_value val) override;
|
||||
vpiHandle vpi_put_value(p_vpi_value val, int flags) override;
|
||||
private:
|
||||
void vpi_get_value_string_(p_vpi_value vp, const vvp_vector4_t&val);
|
||||
void vpi_get_value_binstr_(p_vpi_value vp, const vvp_vector4_t&val);
|
||||
static void vpi_get_value_string_(p_vpi_value vp, const vvp_vector4_t&val);
|
||||
static void vpi_get_value_binstr_(p_vpi_value vp, const vvp_vector4_t&val);
|
||||
void vpi_get_value_decstr_(p_vpi_value vp, const vvp_vector4_t&val);
|
||||
void vpi_get_value_int_ (p_vpi_value vp, const vvp_vector4_t&val);
|
||||
void vpi_get_value_real_ (p_vpi_value vp, const vvp_vector4_t&val);
|
||||
void vpi_get_value_strength_(p_vpi_value vp, const vvp_vector4_t&val);
|
||||
void vpi_get_value_octstr_(p_vpi_value vp, const vvp_vector4_t&val);
|
||||
void vpi_get_value_hexstr_(p_vpi_value vp, const vvp_vector4_t&val);
|
||||
void vpi_get_value_vector_(p_vpi_value vp, const vvp_vector4_t&val);
|
||||
static void vpi_get_value_real_ (p_vpi_value vp, const vvp_vector4_t&val);
|
||||
static void vpi_get_value_strength_(p_vpi_value vp, const vvp_vector4_t&val);
|
||||
static void vpi_get_value_octstr_(p_vpi_value vp, const vvp_vector4_t&val);
|
||||
static void vpi_get_value_hexstr_(p_vpi_value vp, const vvp_vector4_t&val);
|
||||
static void vpi_get_value_vector_(p_vpi_value vp, const vvp_vector4_t&val);
|
||||
private:
|
||||
unsigned depth_;
|
||||
bool signed_flag_;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2004-2024 Stephen Williams (steve@icarus.com)
|
||||
* Copyright (c) 2004-2026 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
|
||||
|
|
@ -637,7 +637,8 @@ void vvp_vector4_t::copy_bits(const vvp_vector4_t&that)
|
|||
the bit values. */
|
||||
if (size_ <= BITS_PER_WORD && that.size_ <= BITS_PER_WORD) {
|
||||
unsigned bits_to_copy = (that.size_ < size_) ? that.size_ : size_;
|
||||
unsigned long mask = (1UL << bits_to_copy) - 1UL;
|
||||
unsigned long mask = ((bits_to_copy < BITS_PER_WORD) ? (1UL << bits_to_copy) :
|
||||
(0UL)) - 1UL;
|
||||
abits_val_ &= ~mask;
|
||||
bbits_val_ &= ~mask;
|
||||
abits_val_ |= that.abits_val_&mask;
|
||||
|
|
|
|||
Loading…
Reference in New Issue