2024-05-17 14:38:34 +00:00
|
|
|
// -*- mode: C++; c-file-style: "cc-mode" -*-
|
|
|
|
//*************************************************************************
|
|
|
|
//
|
|
|
|
// Code available from: https://verilator.org
|
|
|
|
//
|
|
|
|
// Copyright 2024 by Wilson Snyder. This program is free software; you can
|
|
|
|
// redistribute it and/or modify it under the terms of either the GNU Lesser
|
|
|
|
// General Public License Version 3 or the Perl Artistic License Version 2.0.
|
|
|
|
// SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
|
|
|
|
//
|
|
|
|
//*************************************************************************
|
|
|
|
///
|
|
|
|
/// \file
|
|
|
|
/// \brief Verilated randomization header
|
|
|
|
///
|
|
|
|
/// This file is included automatically by Verilator in some of the C++ files
|
|
|
|
/// it generates if randomization features are used.
|
|
|
|
///
|
|
|
|
/// This file is not part of the Verilated public-facing API.
|
|
|
|
/// It is only for internal use.
|
|
|
|
///
|
|
|
|
/// See the internals documentation docs/internals.rst for details.
|
|
|
|
///
|
|
|
|
//*************************************************************************
|
|
|
|
#ifndef VERILATOR_VERILATED_RANDOM_H_
|
|
|
|
#define VERILATOR_VERILATED_RANDOM_H_
|
|
|
|
|
|
|
|
#include "verilated.h"
|
|
|
|
|
2024-11-08 19:04:58 +00:00
|
|
|
#include <iostream>
|
2024-09-10 13:33:14 +00:00
|
|
|
#include <ostream>
|
2024-12-12 16:31:54 +00:00
|
|
|
|
2024-05-17 14:38:34 +00:00
|
|
|
//=============================================================================
|
|
|
|
// VlRandomExpr and subclasses represent expressions for the constraint solver.
|
2024-11-08 19:04:58 +00:00
|
|
|
class ArrayInfo final {
|
|
|
|
public:
|
|
|
|
const std::string
|
|
|
|
m_name; // Name of the array variable, including index notation (e.g., arr[2][1])
|
|
|
|
void* const m_datap; // Reference to the array variable data
|
|
|
|
const int m_index; // Flattened (1D) index of the array element
|
|
|
|
const std::vector<size_t> m_indices; // Multi-dimensional indices of the array element
|
2024-12-12 16:31:54 +00:00
|
|
|
const std::vector<size_t> m_idxWidths; // Multi-dimensional indices' bit widths
|
2024-11-08 19:04:58 +00:00
|
|
|
|
2024-12-12 16:31:54 +00:00
|
|
|
ArrayInfo(const std::string& name, void* datap, int index, const std::vector<size_t>& indices,
|
|
|
|
const std::vector<size_t>& idxWidths)
|
2024-11-08 19:04:58 +00:00
|
|
|
: m_name(name)
|
|
|
|
, m_datap(datap)
|
|
|
|
, m_index(index)
|
2024-12-12 16:31:54 +00:00
|
|
|
, m_indices(indices)
|
|
|
|
, m_idxWidths(idxWidths) {}
|
2024-11-08 19:04:58 +00:00
|
|
|
};
|
|
|
|
using ArrayInfoMap = std::map<std::string, std::shared_ptr<const ArrayInfo>>;
|
2024-05-17 14:38:34 +00:00
|
|
|
|
2024-09-10 13:33:14 +00:00
|
|
|
class VlRandomVar VL_NOT_FINAL {
|
2024-05-17 14:38:34 +00:00
|
|
|
const char* const m_name; // Variable name
|
|
|
|
void* const m_datap; // Reference to variable data
|
|
|
|
const int m_width; // Variable width in bits
|
2024-10-02 14:29:47 +00:00
|
|
|
const int m_dimension; //Variable dimension, default is 0
|
2024-07-31 21:30:48 +00:00
|
|
|
const std::uint32_t m_randModeIdx; // rand_mode index
|
2024-05-17 14:38:34 +00:00
|
|
|
|
|
|
|
public:
|
2024-10-02 14:29:47 +00:00
|
|
|
VlRandomVar(const char* name, int width, void* datap, int dimension, std::uint32_t randModeIdx)
|
2024-05-17 14:38:34 +00:00
|
|
|
: m_name{name}
|
|
|
|
, m_datap{datap}
|
2024-07-31 21:30:48 +00:00
|
|
|
, m_width{width}
|
2024-10-02 14:29:47 +00:00
|
|
|
, m_dimension{dimension}
|
2024-07-31 21:30:48 +00:00
|
|
|
, m_randModeIdx{randModeIdx} {}
|
2024-09-10 13:33:14 +00:00
|
|
|
virtual ~VlRandomVar() = default;
|
2024-05-17 14:38:34 +00:00
|
|
|
const char* name() const { return m_name; }
|
|
|
|
int width() const { return m_width; }
|
2024-10-02 14:29:47 +00:00
|
|
|
int dimension() const { return m_dimension; }
|
2024-09-10 13:33:14 +00:00
|
|
|
virtual void* datap(int idx) const { return m_datap; }
|
2024-07-31 21:30:48 +00:00
|
|
|
std::uint32_t randModeIdx() const { return m_randModeIdx; }
|
|
|
|
bool randModeIdxNone() const { return randModeIdx() == std::numeric_limits<unsigned>::max(); }
|
2024-09-10 13:33:14 +00:00
|
|
|
bool set(const std::string& idx, const std::string& val) const;
|
|
|
|
virtual void emitGetValue(std::ostream& s) const;
|
|
|
|
virtual void emitExtract(std::ostream& s, int i) const;
|
|
|
|
virtual void emitType(std::ostream& s) const;
|
|
|
|
virtual int totalWidth() const;
|
2024-11-08 19:04:58 +00:00
|
|
|
mutable std::shared_ptr<const ArrayInfoMap> m_arrVarsRefp;
|
|
|
|
void setArrayInfo(const std::shared_ptr<const ArrayInfoMap>& arrVarsRefp) const {
|
|
|
|
m_arrVarsRefp = arrVarsRefp;
|
|
|
|
}
|
|
|
|
mutable std::map<std::string, int> count_cache;
|
|
|
|
int countMatchingElements(const ArrayInfoMap& arr_vars, const std::string& base_name) const {
|
|
|
|
if (VL_LIKELY(count_cache.find(base_name) != count_cache.end()))
|
|
|
|
return count_cache[base_name];
|
|
|
|
int count = 0;
|
|
|
|
for (int index = 0; arr_vars.find(base_name + std::to_string(index)) != arr_vars.end();
|
|
|
|
++index) {
|
|
|
|
++count;
|
|
|
|
}
|
|
|
|
count_cache[base_name] = count;
|
|
|
|
return count;
|
|
|
|
}
|
2024-09-10 13:33:14 +00:00
|
|
|
};
|
|
|
|
template <typename T>
|
2024-12-12 16:31:54 +00:00
|
|
|
class VlRandomArrayVarTemplate final : public VlRandomVar {
|
2024-09-10 13:33:14 +00:00
|
|
|
public:
|
2024-12-12 16:31:54 +00:00
|
|
|
VlRandomArrayVarTemplate(const char* name, int width, void* datap, int dimension,
|
|
|
|
std::uint32_t randModeIdx)
|
2024-10-02 14:29:47 +00:00
|
|
|
: VlRandomVar{name, width, datap, dimension, randModeIdx} {}
|
2024-09-10 13:33:14 +00:00
|
|
|
void* datap(int idx) const override {
|
2024-11-08 19:04:58 +00:00
|
|
|
const std::string indexed_name = name() + std::to_string(idx);
|
|
|
|
const auto it = m_arrVarsRefp->find(indexed_name);
|
2024-12-12 16:31:54 +00:00
|
|
|
if (it != m_arrVarsRefp->end()) {
|
|
|
|
return it->second->m_datap;
|
|
|
|
} else {
|
|
|
|
VL_FATAL_MT(__FILE__, __LINE__, "randomize", "indexed_name not found in m_arr_vars");
|
|
|
|
return nullptr;
|
|
|
|
}
|
2024-09-10 13:33:14 +00:00
|
|
|
}
|
2024-12-12 16:31:54 +00:00
|
|
|
void emitSelect(std::ostream& s, const std::vector<size_t>& indices,
|
|
|
|
const std::vector<size_t>& idxWidths) const {
|
2024-11-08 19:04:58 +00:00
|
|
|
for (size_t idx = 0; idx < indices.size(); ++idx) s << "(select ";
|
|
|
|
s << name();
|
|
|
|
for (size_t idx = 0; idx < indices.size(); ++idx) {
|
|
|
|
s << " #x";
|
2024-12-12 16:31:54 +00:00
|
|
|
const size_t bit_width = idxWidths[idx];
|
|
|
|
for (int j = bit_width - 4; j >= 0; j -= 4) {
|
2024-11-08 19:04:58 +00:00
|
|
|
s << "0123456789abcdef"[(indices[idx] >> j) & 0xf];
|
|
|
|
}
|
|
|
|
s << ")";
|
|
|
|
}
|
2024-09-10 13:33:14 +00:00
|
|
|
}
|
|
|
|
void emitGetValue(std::ostream& s) const override {
|
2024-11-08 19:04:58 +00:00
|
|
|
const int elementCounts = countMatchingElements(*m_arrVarsRefp, name());
|
|
|
|
for (int i = 0; i < elementCounts; i++) {
|
|
|
|
const std::string indexed_name = name() + std::to_string(i);
|
|
|
|
const auto it = m_arrVarsRefp->find(indexed_name);
|
|
|
|
if (it != m_arrVarsRefp->end()) {
|
|
|
|
const std::vector<size_t>& indices = it->second->m_indices;
|
2024-12-12 16:31:54 +00:00
|
|
|
const std::vector<size_t>& idxWidths = it->second->m_idxWidths;
|
|
|
|
emitSelect(s, indices, idxWidths);
|
|
|
|
} else {
|
|
|
|
VL_FATAL_MT(__FILE__, __LINE__, "randomize",
|
|
|
|
"indexed_name not found in m_arr_vars");
|
2024-11-08 19:04:58 +00:00
|
|
|
}
|
|
|
|
}
|
2024-09-10 13:33:14 +00:00
|
|
|
}
|
|
|
|
void emitType(std::ostream& s) const override {
|
2024-12-12 16:31:54 +00:00
|
|
|
const std::string indexed_name = name() + std::to_string(0);
|
2024-11-08 19:04:58 +00:00
|
|
|
const auto it = m_arrVarsRefp->find(indexed_name);
|
|
|
|
if (it != m_arrVarsRefp->end()) {
|
2024-12-12 16:31:54 +00:00
|
|
|
const std::vector<size_t>& idxWidths = it->second->m_idxWidths;
|
|
|
|
if (dimension() > 0) {
|
|
|
|
for (int i = 0; i < dimension(); ++i) {
|
|
|
|
s << "(Array (_ BitVec " << idxWidths[i] << ") ";
|
|
|
|
}
|
|
|
|
s << "(_ BitVec " << width() << ")";
|
|
|
|
for (int i = 0; i < dimension(); ++i) { s << ")"; }
|
2024-10-02 14:29:47 +00:00
|
|
|
}
|
2024-12-12 16:31:54 +00:00
|
|
|
} else {
|
|
|
|
VL_FATAL_MT(__FILE__, __LINE__, "randomize", "indexed_name not found in m_arr_vars");
|
2024-10-02 14:29:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
int totalWidth() const override {
|
2024-11-08 19:04:58 +00:00
|
|
|
const int elementCounts = countMatchingElements(*m_arrVarsRefp, name());
|
|
|
|
return width() * elementCounts;
|
2024-10-02 14:29:47 +00:00
|
|
|
}
|
|
|
|
void emitExtract(std::ostream& s, int i) const override {
|
|
|
|
const int j = i / width();
|
|
|
|
i = i % width();
|
|
|
|
s << " ((_ extract " << i << ' ' << i << ')';
|
2024-11-08 19:04:58 +00:00
|
|
|
const std::string indexed_name = name() + std::to_string(j);
|
|
|
|
const auto it = m_arrVarsRefp->find(indexed_name);
|
|
|
|
if (it != m_arrVarsRefp->end()) {
|
|
|
|
const std::vector<size_t>& indices = it->second->m_indices;
|
2024-12-12 16:31:54 +00:00
|
|
|
const std::vector<size_t>& idxWidths = it->second->m_idxWidths;
|
|
|
|
emitSelect(s, indices, idxWidths);
|
|
|
|
} else {
|
|
|
|
VL_FATAL_MT(__FILE__, __LINE__, "randomize", "indexed_name not found in m_arr_vars");
|
2024-11-08 19:04:58 +00:00
|
|
|
}
|
2024-10-02 14:29:47 +00:00
|
|
|
s << ')';
|
|
|
|
}
|
|
|
|
};
|
2024-05-17 14:38:34 +00:00
|
|
|
//=============================================================================
|
|
|
|
// VlRandomizer is the object holding constraints and variable references.
|
|
|
|
|
|
|
|
class VlRandomizer final {
|
|
|
|
// MEMBERS
|
|
|
|
std::vector<std::string> m_constraints; // Solver-dependent constraints
|
2024-07-31 21:30:48 +00:00
|
|
|
std::map<std::string, std::shared_ptr<const VlRandomVar>> m_vars; // Solver-dependent
|
|
|
|
// variables
|
2024-11-08 19:04:58 +00:00
|
|
|
ArrayInfoMap m_arr_vars; // Tracks each element in array structures for iteration
|
2024-12-12 16:31:54 +00:00
|
|
|
std::map<size_t, std::string> seen_values; // Record String Index to avoid conflicts
|
2024-07-31 21:30:48 +00:00
|
|
|
const VlQueue<CData>* m_randmode; // rand_mode state;
|
2024-05-17 14:38:34 +00:00
|
|
|
|
|
|
|
// PRIVATE METHODS
|
2024-08-28 14:11:39 +00:00
|
|
|
void randomConstraint(std::ostream& os, VlRNG& rngr, int bits);
|
2024-05-17 14:38:34 +00:00
|
|
|
bool parseSolution(std::iostream& file);
|
|
|
|
|
|
|
|
public:
|
2024-08-23 22:24:34 +00:00
|
|
|
// CONSTRUCTORS
|
|
|
|
VlRandomizer() = default;
|
|
|
|
~VlRandomizer() = default;
|
|
|
|
|
2024-05-17 14:38:34 +00:00
|
|
|
// METHODS
|
|
|
|
// Finds the next solution satisfying the constraints
|
|
|
|
bool next(VlRNG& rngr);
|
2024-12-12 16:31:54 +00:00
|
|
|
|
|
|
|
template <typename T_Key>
|
|
|
|
typename std::enable_if<std::is_integral<T_Key>::value>::type
|
|
|
|
process_key(const T_Key& key, std::string& indexed_name, size_t& integral_index,
|
|
|
|
const std::string& base_name, size_t& idx_width) {
|
|
|
|
integral_index = static_cast<size_t>(key);
|
|
|
|
indexed_name = base_name + "[" + std::to_string(integral_index) + "]";
|
|
|
|
idx_width = sizeof(T_Key) * 8;
|
|
|
|
}
|
|
|
|
template <typename T_Key>
|
|
|
|
typename std::enable_if<std::is_same<T_Key, std::string>::value>::type
|
|
|
|
process_key(const T_Key& key, std::string& indexed_name, size_t& integral_index,
|
|
|
|
const std::string& base_name, size_t& idx_width) {
|
|
|
|
integral_index = string_to_integral(key);
|
|
|
|
indexed_name = base_name + "[" + std::to_string(integral_index) + "]";
|
|
|
|
idx_width = 64; // 64-bit mask
|
|
|
|
}
|
|
|
|
template <typename T_Key>
|
|
|
|
typename std::enable_if<!std::is_integral<T_Key>::value
|
|
|
|
&& !std::is_same<T_Key, std::string>::value>::type
|
|
|
|
process_key(const T_Key& key, std::string& indexed_name, size_t& integral_index,
|
|
|
|
const std::string& base_name, size_t& idx_width) {
|
|
|
|
VL_FATAL_MT(__FILE__, __LINE__, "randomize",
|
|
|
|
"Unsupported: Only integral and string index of associative array is "
|
|
|
|
"supported currently.");
|
|
|
|
}
|
|
|
|
|
|
|
|
uint64_t string_to_integral(const std::string& str) {
|
|
|
|
uint64_t result = 0;
|
|
|
|
for (char c : str) { result = (result << 8) | static_cast<uint64_t>(c); }
|
|
|
|
|
|
|
|
#ifdef VL_DEBUG
|
|
|
|
if (seen_values.count(result) > 0 && seen_values[result] != str)
|
|
|
|
VL_WARN_MT(__FILE__, __LINE__, "randomize",
|
|
|
|
"Conflict detected: Different strings mapped to the same 64-bit index.");
|
|
|
|
seen_values[result] = str;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2024-05-17 14:38:34 +00:00
|
|
|
template <typename T>
|
2024-10-02 14:29:47 +00:00
|
|
|
void write_var(T& var, int width, const char* name, int dimension,
|
2024-07-31 21:30:48 +00:00
|
|
|
std::uint32_t randmodeIdx = std::numeric_limits<std::uint32_t>::max()) {
|
2024-09-10 13:33:14 +00:00
|
|
|
if (m_vars.find(name) != m_vars.end()) return;
|
2024-08-28 14:11:39 +00:00
|
|
|
// TODO: make_unique once VlRandomizer is per-instance not per-ref
|
2024-10-02 14:29:47 +00:00
|
|
|
m_vars[name]
|
|
|
|
= std::make_shared<const VlRandomVar>(name, width, &var, dimension, randmodeIdx);
|
2024-05-17 14:38:34 +00:00
|
|
|
}
|
2024-09-10 13:33:14 +00:00
|
|
|
template <typename T>
|
2024-10-02 14:29:47 +00:00
|
|
|
void write_var(VlQueue<T>& var, int width, const char* name, int dimension,
|
2024-09-10 13:33:14 +00:00
|
|
|
std::uint32_t randmodeIdx = std::numeric_limits<std::uint32_t>::max()) {
|
|
|
|
if (m_vars.find(name) != m_vars.end()) return;
|
2024-12-12 16:31:54 +00:00
|
|
|
m_vars[name] = std::make_shared<const VlRandomArrayVarTemplate<VlQueue<T>>>(
|
2024-10-02 14:29:47 +00:00
|
|
|
name, width, &var, dimension, randmodeIdx);
|
2024-11-08 19:04:58 +00:00
|
|
|
if (dimension > 0) {
|
|
|
|
idx = 0;
|
2024-12-12 16:31:54 +00:00
|
|
|
record_arr_table(var, name, dimension, {}, {});
|
2024-11-08 19:04:58 +00:00
|
|
|
}
|
2024-10-02 14:29:47 +00:00
|
|
|
}
|
2024-11-30 01:20:38 +00:00
|
|
|
template <typename T, std::size_t N_Depth>
|
|
|
|
void write_var(VlUnpacked<T, N_Depth>& var, int width, const char* name, int dimension,
|
2024-10-02 14:29:47 +00:00
|
|
|
std::uint32_t randmodeIdx = std::numeric_limits<std::uint32_t>::max()) {
|
|
|
|
if (m_vars.find(name) != m_vars.end()) return;
|
2024-12-12 16:31:54 +00:00
|
|
|
m_vars[name] = std::make_shared<const VlRandomArrayVarTemplate<VlUnpacked<T, N_Depth>>>(
|
2024-10-02 14:29:47 +00:00
|
|
|
name, width, &var, dimension, randmodeIdx);
|
2024-11-08 19:04:58 +00:00
|
|
|
if (dimension > 0) {
|
|
|
|
idx = 0;
|
2024-12-12 16:31:54 +00:00
|
|
|
record_arr_table(var, name, dimension, {}, {});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
template <typename T_Key, typename T_Value>
|
|
|
|
void write_var(VlAssocArray<T_Key, T_Value>& var, int width, const char* name, int dimension,
|
|
|
|
std::uint32_t randmodeIdx = std::numeric_limits<std::uint32_t>::max()) {
|
|
|
|
if (m_vars.find(name) != m_vars.end()) return;
|
|
|
|
m_vars[name]
|
|
|
|
= std::make_shared<const VlRandomArrayVarTemplate<VlAssocArray<T_Key, T_Value>>>(
|
|
|
|
name, width, &var, dimension, randmodeIdx);
|
|
|
|
if (dimension > 0) {
|
|
|
|
idx = 0;
|
|
|
|
record_arr_table(var, name, dimension, {}, {});
|
2024-11-08 19:04:58 +00:00
|
|
|
}
|
|
|
|
}
|
2024-12-12 16:31:54 +00:00
|
|
|
|
|
|
|
int idx;
|
2024-11-08 19:04:58 +00:00
|
|
|
std::string generateKey(const std::string& name, int idx) {
|
|
|
|
if (!name.empty() && name[0] == '\\') {
|
|
|
|
const size_t space_pos = name.find(' ');
|
|
|
|
return (space_pos != std::string::npos ? name.substr(0, space_pos) : name)
|
|
|
|
+ std::to_string(idx);
|
|
|
|
}
|
|
|
|
const size_t bracket_pos = name.find('[');
|
|
|
|
return (bracket_pos != std::string::npos ? name.substr(0, bracket_pos) : name)
|
|
|
|
+ std::to_string(idx);
|
|
|
|
}
|
2024-12-12 16:31:54 +00:00
|
|
|
|
2024-11-08 19:04:58 +00:00
|
|
|
template <typename T>
|
|
|
|
void record_arr_table(T& var, const std::string name, int dimension,
|
2024-12-12 16:31:54 +00:00
|
|
|
std::vector<size_t> indices, std::vector<size_t> idxWidths) {
|
2024-11-08 19:04:58 +00:00
|
|
|
const std::string key = generateKey(name, idx);
|
2024-12-12 16:31:54 +00:00
|
|
|
m_arr_vars[key] = std::make_shared<ArrayInfo>(name, &var, idx, indices, idxWidths);
|
|
|
|
++idx;
|
2024-11-08 19:04:58 +00:00
|
|
|
}
|
|
|
|
template <typename T>
|
|
|
|
void record_arr_table(VlQueue<T>& var, const std::string name, int dimension,
|
2024-12-12 16:31:54 +00:00
|
|
|
std::vector<size_t> indices, std::vector<size_t> idxWidths) {
|
2024-11-08 19:04:58 +00:00
|
|
|
if ((dimension > 0) && (var.size() != 0)) {
|
2024-12-12 16:31:54 +00:00
|
|
|
idxWidths.push_back(32);
|
2024-11-08 19:04:58 +00:00
|
|
|
for (size_t i = 0; i < var.size(); ++i) {
|
|
|
|
const std::string indexed_name = name + "[" + std::to_string(i) + "]";
|
|
|
|
indices.push_back(i);
|
2024-12-12 16:31:54 +00:00
|
|
|
record_arr_table(var.atWrite(i), indexed_name, dimension - 1, indices, idxWidths);
|
2024-11-08 19:04:58 +00:00
|
|
|
indices.pop_back();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-11-30 01:20:38 +00:00
|
|
|
template <typename T, std::size_t N_Depth>
|
|
|
|
void record_arr_table(VlUnpacked<T, N_Depth>& var, const std::string name, int dimension,
|
2024-12-12 16:31:54 +00:00
|
|
|
std::vector<size_t> indices, std::vector<size_t> idxWidths) {
|
2024-11-30 01:20:38 +00:00
|
|
|
if ((dimension > 0) && (N_Depth != 0)) {
|
2024-12-12 16:31:54 +00:00
|
|
|
idxWidths.push_back(32);
|
2024-11-30 01:20:38 +00:00
|
|
|
for (size_t i = 0; i < N_Depth; ++i) {
|
2024-11-08 19:04:58 +00:00
|
|
|
const std::string indexed_name = name + "[" + std::to_string(i) + "]";
|
|
|
|
indices.push_back(i);
|
2024-12-12 16:31:54 +00:00
|
|
|
record_arr_table(var.operator[](i), indexed_name, dimension - 1, indices,
|
|
|
|
idxWidths);
|
2024-11-08 19:04:58 +00:00
|
|
|
indices.pop_back();
|
|
|
|
}
|
|
|
|
}
|
2024-09-10 13:33:14 +00:00
|
|
|
}
|
2024-12-12 16:31:54 +00:00
|
|
|
template <typename T_Key, typename T_Value>
|
|
|
|
void record_arr_table(VlAssocArray<T_Key, T_Value>& var, const std::string name, int dimension,
|
|
|
|
std::vector<size_t> indices, std::vector<size_t> idxWidths) {
|
|
|
|
if ((dimension > 0) && (var.size() != 0)) {
|
|
|
|
for (auto it = var.begin(); it != var.end(); ++it) {
|
|
|
|
const T_Key& key = it->first;
|
|
|
|
const T_Value& value = it->second;
|
|
|
|
std::string indexed_name;
|
|
|
|
size_t integral_index;
|
|
|
|
size_t idx_width;
|
|
|
|
process_key(key, indexed_name, integral_index, name, idx_width);
|
|
|
|
idxWidths.push_back(idx_width);
|
|
|
|
indices.push_back(integral_index);
|
|
|
|
record_arr_table(var.at(key), indexed_name, dimension - 1, indices, idxWidths);
|
|
|
|
idxWidths.pop_back();
|
|
|
|
indices.pop_back();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-05-17 14:38:34 +00:00
|
|
|
void hard(std::string&& constraint);
|
2024-07-01 18:19:15 +00:00
|
|
|
void clear();
|
2024-07-31 21:30:48 +00:00
|
|
|
void set_randmode(const VlQueue<CData>& randmode) { m_randmode = &randmode; }
|
2024-05-17 14:38:34 +00:00
|
|
|
#ifdef VL_DEBUG
|
|
|
|
void dump() const;
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // Guard
|