Skip to content

Commit

Permalink
Merge pull request #3994 from alainmarcel/alainmarcel-patch-1
Browse files Browse the repository at this point in the history
Attribute support on nets
  • Loading branch information
alaindargelas authored Oct 4, 2024
2 parents 9c3c533 + 70cbe61 commit b2c1d0d
Show file tree
Hide file tree
Showing 12 changed files with 404 additions and 28 deletions.
3 changes: 2 additions & 1 deletion include/Surelog/DesignCompile/CompileHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ class CompileHelper final {

bool compileNetDeclaration(DesignComponent* component, const FileContent* fC,
NodeId id, bool interface,
CompileDesign* compileDesign);
CompileDesign* compileDesign,
UHDM::VectorOfattribute* attributes);

bool compileDataDeclaration(DesignComponent* component, const FileContent* fC,
NodeId id, bool interface,
Expand Down
31 changes: 18 additions & 13 deletions src/DesignCompile/CompileHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2039,7 +2039,8 @@ bool CompileHelper::compileAnsiPortDeclaration(DesignComponent* component,
bool CompileHelper::compileNetDeclaration(DesignComponent* component,
const FileContent* fC, NodeId id,
bool interface,
CompileDesign* compileDesign) {
CompileDesign* compileDesign,
UHDM::VectorOfattribute* attributes) {
/*
n<> u<17> t<NetType_Wire> p<18> l<27>
n<> u<18> t<NetTypeOrTrireg_Net> p<22> c<17> s<21> l<27>
Expand Down Expand Up @@ -2136,6 +2137,7 @@ bool CompileHelper::compileNetDeclaration(DesignComponent* component,
if (portRef) portRef->setLowConn(sig);
sig->setDelay(delay);
sig->setStatic();
sig->attributes(attributes);
if (isSigned) sig->setSigned();
component->getSignals().push_back(sig);
}
Expand Down Expand Up @@ -4527,20 +4529,23 @@ std::vector<UHDM::attribute*>* CompileHelper::compileAttributes(
if (fC->Type(nodeId) == VObjectType::paAttribute_instance) {
results = s.MakeAttributeVec();
while (fC->Type(nodeId) == VObjectType::paAttribute_instance) {
UHDM::attribute* attribute = s.MakeAttribute();
NodeId Attr_spec = fC->Child(nodeId);
NodeId Attr_name = fC->Child(Attr_spec);
const std::string_view name = fC->SymName(fC->Child(Attr_name));
attribute->VpiName(name);
attribute->VpiParent(pexpr);
fC->populateCoreMembers(Attr_spec, Attr_spec, attribute);
results->push_back(attribute);
if (NodeId Constant_expression = fC->Sibling(Attr_name)) {
if (UHDM::expr* expr = (UHDM::expr*)compileExpression(
component, fC, Constant_expression, compileDesign, Reduce::No,
attribute)) {
attribute->VpiValue(expr->VpiValue());
while (fC->Type(Attr_spec) == VObjectType::paAttr_spec) {
UHDM::attribute* attribute = s.MakeAttribute();
NodeId Attr_name = fC->Child(Attr_spec);
const std::string_view name = fC->SymName(fC->Child(Attr_name));
attribute->VpiName(name);
attribute->VpiParent(pexpr);
fC->populateCoreMembers(Attr_spec, Attr_spec, attribute);
results->push_back(attribute);
if (NodeId Constant_expression = fC->Sibling(Attr_name)) {
if (UHDM::expr* expr = (UHDM::expr*)compileExpression(
component, fC, Constant_expression, compileDesign, Reduce::No,
attribute)) {
attribute->VpiValue(expr->VpiValue());
}
}
Attr_spec = fC->Sibling(Attr_spec);
}
nodeId = fC->Sibling(nodeId);
}
Expand Down
4 changes: 2 additions & 2 deletions src/DesignCompile/CompileModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ bool CompileModule::collectModuleObjects_(CollectType collectType) {
case VObjectType::paNet_declaration: {
if (collectType != CollectType::DEFINITION) break;
m_helper.compileNetDeclaration(m_module, fC, id, false,
m_compileDesign);
m_compileDesign, m_attributes);
m_attributes = nullptr;
break;
}
Expand Down Expand Up @@ -1091,7 +1091,7 @@ bool CompileModule::collectInterfaceObjects_(CollectType collectType) {
case VObjectType::paNet_declaration: {
if (collectType != CollectType::DEFINITION) break;
m_helper.compileNetDeclaration(m_module, fC, id, true,
m_compileDesign);
m_compileDesign, m_attributes);
m_attributes = nullptr;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/DesignCompile/CompilePackage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ bool CompilePackage::collectObjects_(CollectType collectType, Reduce reduce) {
case VObjectType::paNet_declaration: {
if (collectType != CollectType::DEFINITION) break;
m_helper.compileNetDeclaration(m_package, fC, id, false,
m_compileDesign);
m_compileDesign, m_attributes);
m_attributes = nullptr;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/DesignCompile/CompileProgram.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ bool CompileProgram::collectObjects_(CollectType collectType) {
case VObjectType::paNet_declaration: {
if (collectType != CollectType::DEFINITION) break;
m_helper.compileNetDeclaration(m_program, fC, id, false,
m_compileDesign);
m_compileDesign, m_attributes);
m_attributes = nullptr;
break;
}
Expand Down
Loading

0 comments on commit b2c1d0d

Please sign in to comment.