Skip to content

Commit

Permalink
Merge pull request #3922 from alainmarcel/alainmarcel-patch-1
Browse files Browse the repository at this point in the history
int pattern assign support
  • Loading branch information
alaindargelas authored Nov 3, 2023
2 parents 318a5dc + 206e56e commit db9169d
Show file tree
Hide file tree
Showing 4 changed files with 427 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/DesignCompile/CompileHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5101,6 +5101,33 @@ UHDM::expr* CompileHelper::expandPatternAssignment(const typespec* tps,
for (uint64_t i = 0; i < size; i++) {
values[i] = defaultval;
}
// Apply any other indexed value
for (any* op : *operands) {
if (op->UhdmType() == uhdmtagged_pattern) {
taggedPattern = true;
tagged_pattern* tp = (tagged_pattern*)op;
if (const UHDM::ref_typespec* rt = tp->Typespec()) {
if (const typespec* tpsi = rt->Actual_typespec()) {
if (tpsi->UhdmType() == uhdminteger_typespec) {
integer_typespec* itps = (integer_typespec*)tpsi;
std::string_view v = itps->VpiValue();
v.remove_prefix(std::string_view("INT:").length());
int64_t index;
if (NumUtils::parseInt64(v, &index)) {
any* pattern = tp->Pattern();
if (pattern->UhdmType() == uhdmconstant) {
constant* c = (constant*)pattern;
UHDM::ExprEval eval;
int32_t val = eval.get_value(invalidValue, c);
if (index >= 0 && index < ((int64_t)size))
values[size - index - 1] = val;
}
}
}
}
}
}
}
}
} else {
int32_t valIndex = 0;
Expand Down
Loading

0 comments on commit db9169d

Please sign in to comment.