Skip to content

Commit 3cbbebf

Browse files
Merge pull request #1118 from alainmarcel/alainmarcel-patch-1
parameter value
2 parents 78cfaba + c074e02 commit 3cbbebf

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

templates/ExprEval.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <uhdm/NumUtils.h>
2929
#include <uhdm/clone_tree.h>
3030
#include <uhdm/uhdm.h>
31+
#include <uhdm/vpi_visitor.h>
3132

3233
#include <algorithm>
3334
#include <bitset>
@@ -288,6 +289,7 @@ any *ExprEval::getValue(std::string_view name, const any *inst,
288289

289290
while (the_instance) {
290291
VectorOfparam_assign *param_assigns = nullptr;
292+
VectorOfany *parameters = nullptr;
291293
VectorOftypespec *typespecs = nullptr;
292294
if (the_instance->UhdmType() == UHDM_OBJECT_TYPE::uhdmgen_scope_array) {
293295
} else if (the_instance->UhdmType() == UHDM_OBJECT_TYPE::uhdmdesign) {
@@ -296,6 +298,7 @@ any *ExprEval::getValue(std::string_view name, const any *inst,
296298
} else if (const scope *spe = any_cast<const scope *>(the_instance)) {
297299
param_assigns = spe->Param_assigns();
298300
typespecs = spe->Typespecs();
301+
parameters = spe->Parameters();
299302
}
300303
if (param_assigns) {
301304
for (auto p : *param_assigns) {
@@ -305,6 +308,16 @@ any *ExprEval::getValue(std::string_view name, const any *inst,
305308
}
306309
}
307310
}
311+
if ((result == nullptr) && parameters) {
312+
for (auto p : *parameters) {
313+
if (p->VpiName() == the_name) {
314+
if (p->UhdmType() == uhdmparameter) {
315+
result = (any*) p;
316+
break;
317+
}
318+
}
319+
}
320+
}
308321
if ((result == nullptr) && (typespecs != nullptr)) {
309322
for (auto p : *typespecs) {
310323
if (p->UhdmType() == UHDM_OBJECT_TYPE::uhdmenum_typespec) {
@@ -1928,6 +1941,9 @@ int64_t ExprEval::get_value(bool &invalidValue, const expr *expr, bool strict) {
19281941
type = vpiUIntConst;
19291942
sv = v->VpiValue();
19301943
}
1944+
} else if (const parameter *p = any_cast<const parameter *>(expr)) {
1945+
// default type
1946+
sv = p->VpiValue();
19311947
} else {
19321948
invalidValue = true;
19331949
}

0 commit comments

Comments
 (0)