Skip to content

Commit

Permalink
Merge pull request #1046 from alainmarcel/alainmarcel-patch-1
Browse files Browse the repository at this point in the history
pos int check
  • Loading branch information
alaindargelas authored Oct 19, 2023
2 parents 7e9ae0f + 815213d commit c42e783
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
3 changes: 2 additions & 1 deletion templates/Serializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ enum ErrorType {
UHDM_INVALID_CASE_STMT_VALUE = 727,
UHDM_UNSUPPORTED_TYPESPEC = 728,
UHDM_UNRESOLVED_PROPERTY = 729,
UHDM_NON_TEMPORAL_SEQUENCE_USE = 730
UHDM_NON_TEMPORAL_SEQUENCE_USE = 730,
UHDM_NON_POSITIVE_VALUE = 731
};

#ifndef SWIG
Expand Down
23 changes: 23 additions & 0 deletions templates/UhdmLint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,4 +314,27 @@ void UhdmLint::leaveProperty_spec(const property_spec* prop_s,
}
}

void UhdmLint::leaveSys_func_call(const sys_func_call* object,
vpiHandle handle) {
ExprEval eval;
eval.setDesign(design_);
if (object->VpiName() == "$past") {
if (auto arg = object->Tf_call_args()) {
if (arg->size() == 2) {
any* ex = arg->at(1);
bool invalidValue = false;
const int64_t val = eval.get_value(
invalidValue,
eval.reduceExpr(ex, invalidValue, nullptr, object->VpiParent()));
if (val <= 0 && (invalidValue == false)) {
const std::string errMsg = std::to_string(val);
serializer_->GetErrorHandler()(
ErrorType::UHDM_NON_POSITIVE_VALUE, errMsg,
ex, nullptr);
}
}
}
}
}

} // namespace UHDM
2 changes: 2 additions & 0 deletions templates/UhdmLint.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class UhdmLint final : public VpiListener {
void leaveProperty_spec(const property_spec* object,
vpiHandle handle) override;

void leaveSys_func_call(const sys_func_call* object, vpiHandle handle) override;

void checkMultiContAssign(const std::vector<UHDM::cont_assign*>* assigns);

Serializer* serializer_ = nullptr;
Expand Down
3 changes: 3 additions & 0 deletions util/uhdm-lint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ int32_t main(int32_t argc, char **argv) {
case UHDM::UHDM_NON_TEMPORAL_SEQUENCE_USE:
errmsg = "Sequence used in non-temporal context";
break;
case UHDM::UHDM_NON_POSITIVE_VALUE:
errmsg = "Non positive (<1) value";
break;
}

if (object1) {
Expand Down

0 comments on commit c42e783

Please sign in to comment.