Skip to content

Commit

Permalink
Merge pull request #1042 from alainmarcel/alainmarcel-patch-1
Browse files Browse the repository at this point in the history
seq lint rule
  • Loading branch information
alaindargelas committed Oct 11, 2023
2 parents 33fabc3 + 1027966 commit cf37173
Show file tree
Hide file tree
Showing 3 changed files with 37 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 @@ -63,7 +63,8 @@ enum ErrorType {
UHDM_UNDEFINED_VARIABLE = 726,
UHDM_INVALID_CASE_STMT_VALUE = 727,
UHDM_UNSUPPORTED_TYPESPEC = 728,
UHDM_UNRESOLVED_PROPERTY = 729
UHDM_UNRESOLVED_PROPERTY = 729,
UHDM_NON_TEMPORAL_SEQUENCE_USE = 730
};

#ifndef SWIG
Expand Down
32 changes: 32 additions & 0 deletions templates/UhdmLint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,24 @@ void UhdmLint::leaveEnum_typespec(const enum_typespec* object,
}
}

class DetectSequenceInst : public VpiListener {
public:
explicit DetectSequenceInst() {}
~DetectSequenceInst() override = default;
void leaveRef_obj(const ref_obj* object, vpiHandle handle) final {
if (decl && (seq_parent == nullptr))
seq_parent = object;
}
void leaveSequence_decl(const sequence_decl *object, vpiHandle handle) final {
decl = object;
}
const sequence_decl* seqDeclDetected() const { return decl; }
const ref_obj* parentRef() { return seq_parent; }
private:
const ref_obj* seq_parent = nullptr;
const sequence_decl* decl = nullptr;
};

void UhdmLint::leaveProperty_spec(const property_spec* prop_s,
vpiHandle handle) {
if (isInUhdmAllIterator()) return;
Expand All @@ -260,6 +278,20 @@ void UhdmLint::leaveProperty_spec(const property_spec* prop_s,
}
}
}
{
if (prop_s->VpiClockingEvent()) {
DetectSequenceInst seqDetector;
vpiHandle h = NewVpiHandle(exp);
seqDetector.listenAny(h);
vpi_free_object(h);
if (const sequence_decl* decl = seqDetector.seqDeclDetected()) {
const std::string errMsg(decl->VpiName());
serializer_->GetErrorHandler()(
ErrorType::UHDM_NON_TEMPORAL_SEQUENCE_USE, errMsg,
seqDetector.parentRef(), 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 @@ -166,6 +166,9 @@ int32_t main(int32_t argc, char **argv) {
case UHDM::UHDM_UNRESOLVED_PROPERTY:
errmsg = "Unresolved property";
break;
case UHDM::UHDM_NON_TEMPORAL_SEQUENCE_USE:
errmsg = "Sequence used in non-temporal context";
break;
}

if (object1) {
Expand Down

0 comments on commit cf37173

Please sign in to comment.