Fixed VlQueue falling into wrong template spec inside VlRandomizer
Signed-off-by: Adam Kostrzewski <akostrzewski@internships.antmicro.com>
This commit is contained in:
parent
f316ec0d66
commit
e4e95c04c0
|
|
@ -377,12 +377,12 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register queue of non-struct types
|
// Register queue of non-struct types
|
||||||
template <typename T>
|
template <typename T, size_t N_MaxSize>
|
||||||
typename std::enable_if<!VlContainsCustomStruct<T>::value, void>::type
|
typename std::enable_if<!VlContainsCustomStruct<T>::value, void>::type
|
||||||
write_var(VlQueue<T>& var, int width, const char* name, int dimension,
|
write_var(VlQueue<T, N_MaxSize>& var, int width, const char* name, int dimension,
|
||||||
std::uint32_t randmodeIdx = std::numeric_limits<std::uint32_t>::max()) {
|
std::uint32_t randmodeIdx = std::numeric_limits<std::uint32_t>::max()) {
|
||||||
if (m_vars.find(name) == m_vars.end()) {
|
if (m_vars.find(name) == m_vars.end()) {
|
||||||
m_vars[name] = std::make_shared<const VlRandomArrayVarTemplate<VlQueue<T>>>(
|
m_vars[name] = std::make_shared<const VlRandomArrayVarTemplate<VlQueue<T, N_MaxSize>>>(
|
||||||
name, width, &var, dimension, randmodeIdx);
|
name, width, &var, dimension, randmodeIdx);
|
||||||
}
|
}
|
||||||
if (dimension > 0) {
|
if (dimension > 0) {
|
||||||
|
|
@ -394,9 +394,9 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Register queue of structs
|
// Register queue of structs
|
||||||
template <typename T>
|
template <typename T, size_t N_MaxSize>
|
||||||
typename std::enable_if<VlContainsCustomStruct<T>::value, void>::type
|
typename std::enable_if<VlContainsCustomStruct<T>::value, void>::type
|
||||||
write_var(VlQueue<T>& var, int width, const char* name, int dimension,
|
write_var(VlQueue<T, N_MaxSize>& var, int width, const char* name, int dimension,
|
||||||
std::uint32_t randmodeIdx = std::numeric_limits<std::uint32_t>::max()) {
|
std::uint32_t randmodeIdx = std::numeric_limits<std::uint32_t>::max()) {
|
||||||
if (dimension > 0) record_struct_arr(var, name, dimension, {}, {});
|
if (dimension > 0) record_struct_arr(var, name, dimension, {}, {});
|
||||||
}
|
}
|
||||||
|
|
@ -488,8 +488,8 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recursively record all elements in a queue
|
// Recursively record all elements in a queue
|
||||||
template <typename T>
|
template <typename T, size_t N_MaxSize>
|
||||||
void record_arr_table(VlQueue<T>& var, const std::string& name, int dimension,
|
void record_arr_table(VlQueue<T, N_MaxSize>& var, const std::string& name, int dimension,
|
||||||
std::vector<IData> indices, std::vector<size_t> idxWidths) {
|
std::vector<IData> indices, std::vector<size_t> idxWidths) {
|
||||||
if ((dimension > 0) && (var.size() != 0)) {
|
if ((dimension > 0) && (var.size() != 0)) {
|
||||||
idxWidths.push_back(32);
|
idxWidths.push_back(32);
|
||||||
|
|
@ -562,8 +562,8 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recursively process VlQueue of structs
|
// Recursively process VlQueue of structs
|
||||||
template <typename T>
|
template <typename T, size_t N_MaxSize>
|
||||||
void record_struct_arr(VlQueue<T>& var, const std::string& name, int dimension,
|
void record_struct_arr(VlQueue<T, N_MaxSize>& var, const std::string& name, int dimension,
|
||||||
std::vector<IData> indices, std::vector<size_t> idxWidths) {
|
std::vector<IData> indices, std::vector<size_t> idxWidths) {
|
||||||
if ((dimension > 0) && (var.size() != 0)) {
|
if ((dimension > 0) && (var.size() != 0)) {
|
||||||
idxWidths.push_back(32);
|
idxWidths.push_back(32);
|
||||||
|
|
|
||||||
|
|
@ -24,10 +24,12 @@ end
|
||||||
|
|
||||||
class Foo;
|
class Foo;
|
||||||
rand int m_intQueue[$];
|
rand int m_intQueue[$];
|
||||||
|
rand int m_intQueueSized[$:9];
|
||||||
rand int m_idx;
|
rand int m_idx;
|
||||||
|
|
||||||
function new;
|
function new;
|
||||||
m_intQueue = '{10{0}};
|
m_intQueue = '{10{0}};
|
||||||
|
m_intQueueSized = '{10{0}};
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
constraint int_queue_c {
|
constraint int_queue_c {
|
||||||
|
|
@ -37,6 +39,13 @@ class Foo;
|
||||||
m_intQueue[i] inside {[0:127]};
|
m_intQueue[i] inside {[0:127]};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
constraint int_queue_sized_c {
|
||||||
|
m_idx inside {[0:9]};
|
||||||
|
m_intQueueSized[m_idx] == m_idx + 1;
|
||||||
|
foreach (m_intQueueSized[i]) {
|
||||||
|
m_intQueueSized[i] inside {[0:127]};
|
||||||
|
}
|
||||||
|
}
|
||||||
endclass
|
endclass
|
||||||
|
|
||||||
module t_randomize_queue_constraints;
|
module t_randomize_queue_constraints;
|
||||||
|
|
@ -47,6 +56,12 @@ module t_randomize_queue_constraints;
|
||||||
$display("Queue: %p", foo.m_intQueue);
|
$display("Queue: %p", foo.m_intQueue);
|
||||||
`check_rand(foo, foo.m_intQueue[3], foo.m_intQueue[5] inside {[0:127]});
|
`check_rand(foo, foo.m_intQueue[3], foo.m_intQueue[5] inside {[0:127]});
|
||||||
$display("Queue: %p", foo.m_intQueue);
|
$display("Queue: %p", foo.m_intQueue);
|
||||||
|
|
||||||
|
`check_rand(foo, foo.m_idx, foo.m_idx inside {[0:9]} && foo.m_intQueueSized[foo.m_idx] == foo.m_idx + 1);
|
||||||
|
$display("Queue: %p", foo.m_intQueueSized);
|
||||||
|
`check_rand(foo, foo.m_intQueueSized[3], foo.m_intQueueSized[5] inside {[0:127]});
|
||||||
|
$display("Queue: %p", foo.m_intQueueSized);
|
||||||
|
|
||||||
$write("*-* All Finished *-*\n");
|
$write("*-* All Finished *-*\n");
|
||||||
$finish;
|
$finish;
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue