Remove useless vvp_realarray_t
The vvp_darray_real class cal be used for static arrays as well and this is a more general solution anyhow. Kill the now useless vvp_realarray_t class.
This commit is contained in:
parent
f5717a6e87
commit
1527b87595
32
vvp/array.cc
32
vvp/array.cc
|
|
@ -18,11 +18,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
# include "array.h"
|
# include "array.h"
|
||||||
#include "symbols.h"
|
# include "symbols.h"
|
||||||
#include "schedule.h"
|
# include "schedule.h"
|
||||||
#include "vpi_priv.h"
|
# include "vpi_priv.h"
|
||||||
#include "vvp_net_sig.h"
|
# include "vvp_net_sig.h"
|
||||||
#include "config.h"
|
# include "vvp_darray.h"
|
||||||
|
# include "config.h"
|
||||||
#ifdef CHECK_WITH_VALGRIND
|
#ifdef CHECK_WITH_VALGRIND
|
||||||
#include "vvp_cleanup.h"
|
#include "vvp_cleanup.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -34,6 +35,8 @@
|
||||||
# include <cassert>
|
# include <cassert>
|
||||||
# include "ivl_alloc.h"
|
# include "ivl_alloc.h"
|
||||||
|
|
||||||
|
class vvp_darray_real;
|
||||||
|
|
||||||
unsigned long count_net_arrays = 0;
|
unsigned long count_net_arrays = 0;
|
||||||
unsigned long count_net_array_words = 0;
|
unsigned long count_net_array_words = 0;
|
||||||
unsigned long count_var_arrays = 0;
|
unsigned long count_var_arrays = 0;
|
||||||
|
|
@ -101,7 +104,7 @@ struct __vpiArray : public __vpiHandle {
|
||||||
vpiHandle*nets;
|
vpiHandle*nets;
|
||||||
// If this is a var array, then these are used instead of nets.
|
// If this is a var array, then these are used instead of nets.
|
||||||
vvp_vector4array_t *vals4;
|
vvp_vector4array_t *vals4;
|
||||||
vvp_realarray_t *valsr;
|
vvp_darray_real *valsr;
|
||||||
struct __vpiArrayWord*vals_words;
|
struct __vpiArrayWord*vals_words;
|
||||||
|
|
||||||
vvp_fun_arrayport*ports_;
|
vvp_fun_arrayport*ports_;
|
||||||
|
|
@ -1050,7 +1053,14 @@ double array_get_word_r(vvp_array_t arr, unsigned address)
|
||||||
if (arr->valsr) {
|
if (arr->valsr) {
|
||||||
assert(arr->vals4 == 0);
|
assert(arr->vals4 == 0);
|
||||||
assert(arr->nets == 0);
|
assert(arr->nets == 0);
|
||||||
return arr->valsr->get_word(address);
|
// In this context, address out of bounds returns 0.0
|
||||||
|
// instead of an error.
|
||||||
|
if (address >= arr->valsr->get_size())
|
||||||
|
return 0.0;
|
||||||
|
|
||||||
|
double val;
|
||||||
|
arr->valsr->get_word(address, val);
|
||||||
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(arr->nets);
|
assert(arr->nets);
|
||||||
|
|
@ -1199,7 +1209,7 @@ void compile_real_array(char*label, char*name, int last, int first,
|
||||||
struct __vpiArray*arr = dynamic_cast<__vpiArray*>(obj);
|
struct __vpiArray*arr = dynamic_cast<__vpiArray*>(obj);
|
||||||
|
|
||||||
/* Make the words. */
|
/* Make the words. */
|
||||||
arr->valsr = new vvp_realarray_t(arr->array_count);
|
arr->valsr = new vvp_darray_real(arr->array_count);
|
||||||
arr->vals_width = 1;
|
arr->vals_width = 1;
|
||||||
|
|
||||||
/* For a real array the MSB and LSB must be zero. */
|
/* For a real array the MSB and LSB must be zero. */
|
||||||
|
|
@ -1515,8 +1525,10 @@ void array_word_change(vvp_array_t array, unsigned long addr)
|
||||||
if (cur->test_value_callback_ready()) {
|
if (cur->test_value_callback_ready()) {
|
||||||
if (cur->cb_data.value) {
|
if (cur->cb_data.value) {
|
||||||
if (vpi_array_is_real(array)) {
|
if (vpi_array_is_real(array)) {
|
||||||
vpip_real_get_value(array->valsr->get_word(addr),
|
double val = 0.0;
|
||||||
cur->cb_data.value);
|
if (addr < array->valsr->get_size())
|
||||||
|
array->valsr->get_word(addr, val);
|
||||||
|
vpip_real_get_value(val, cur->cb_data.value);
|
||||||
} else {
|
} else {
|
||||||
vpip_vec4_get_value(array->vals4->get_word(addr),
|
vpip_vec4_get_value(array->vals4->get_word(addr),
|
||||||
array->vals_width,
|
array->vals_width,
|
||||||
|
|
|
||||||
|
|
@ -1779,36 +1779,6 @@ bool vector2_to_value(const vvp_vector2_t&a, int32_t&val, bool is_signed)
|
||||||
return a.size() <= 32;
|
return a.size() <= 32;
|
||||||
}
|
}
|
||||||
|
|
||||||
vvp_realarray_t::vvp_realarray_t(unsigned wor)
|
|
||||||
: words_(wor)
|
|
||||||
{
|
|
||||||
array_ = new double[words_];
|
|
||||||
// Real array words have a default value of zero.
|
|
||||||
for (unsigned idx = 0 ; idx < words_; idx += 1) {
|
|
||||||
array_[idx] = 0.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
vvp_realarray_t::~vvp_realarray_t()
|
|
||||||
{
|
|
||||||
delete[]array_;
|
|
||||||
}
|
|
||||||
|
|
||||||
void vvp_realarray_t::set_word(unsigned word, double value)
|
|
||||||
{
|
|
||||||
if (word >= words_)
|
|
||||||
return;
|
|
||||||
array_[word] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
double vvp_realarray_t::get_word(unsigned word) const
|
|
||||||
{
|
|
||||||
if (word >= words_)
|
|
||||||
return 0.0;
|
|
||||||
else
|
|
||||||
return array_[word];
|
|
||||||
}
|
|
||||||
|
|
||||||
vvp_vector4array_t::vvp_vector4array_t(unsigned width__, unsigned words__)
|
vvp_vector4array_t::vvp_vector4array_t(unsigned width__, unsigned words__)
|
||||||
: width_(width__), words_(words__)
|
: width_(width__), words_(words__)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef __vvp_net_H
|
#ifndef __vvp_net_H
|
||||||
#define __vvp_net_H
|
#define __vvp_net_H
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2004-2012 Stephen Williams (steve@icarus.com)
|
* Copyright (c) 2004-2013 Stephen Williams (steve@icarus.com)
|
||||||
*
|
*
|
||||||
* This source code is free software; you can redistribute it
|
* This source code is free software; you can redistribute it
|
||||||
* and/or modify it in source code form under the terms of the GNU
|
* and/or modify it in source code form under the terms of the GNU
|
||||||
|
|
@ -522,25 +522,6 @@ extern bool vector2_to_value(const vvp_vector2_t&a, int32_t&val, bool is_signed)
|
||||||
|
|
||||||
extern vvp_vector4_t vector4_from_text(const char*bits, unsigned wid);
|
extern vvp_vector4_t vector4_from_text(const char*bits, unsigned wid);
|
||||||
|
|
||||||
/*
|
|
||||||
* The __vpiArray handle uses instances of this to keep an array of
|
|
||||||
* real valued variables.
|
|
||||||
*/
|
|
||||||
class vvp_realarray_t {
|
|
||||||
|
|
||||||
public:
|
|
||||||
vvp_realarray_t(unsigned words);
|
|
||||||
~vvp_realarray_t();
|
|
||||||
|
|
||||||
unsigned words() const { return words_; }
|
|
||||||
|
|
||||||
double get_word(unsigned idx) const;
|
|
||||||
void set_word(unsigned idx, double val);
|
|
||||||
|
|
||||||
private:
|
|
||||||
unsigned words_;
|
|
||||||
double*array_;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* vvp_vector4array_t
|
* vvp_vector4array_t
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue