MCPcopy Create free account
hub / github.com/chipsalliance/Surelog / compileImportDeclaration

Method compileImportDeclaration

src/DesignCompile/CompileHelper.cpp:2208–2253  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2206}
2207
2208void CompileHelper::compileImportDeclaration(DesignComponent* component,
2209 const FileContent* fC,
2210 NodeId package_import_item_id,
2211 CompileDesign* compileDesign) {
2212 /*
2213 Verilog:
2214 import my_pkg::opcode_e, my_pkg::OPCODE_LOAD;
2215 Expected tree:
2216 n<my_pkg> u<27> t<StringConst> p<29> s<28> l<3>
2217 n<opcode_e> u<28> t<StringConst> p<29> l<3>
2218 n<> u<29> t<Package_import_item> p<33> c<27> s<32> l<3>
2219 n<my_pkg> u<30> t<StringConst> p<32> s<31> l<3>
2220 n<OPCODE_LOAD> u<31> t<StringConst> p<32> l<3>
2221 n<> u<32> t<Package_import_item> p<33> c<30> l<3>
2222 n<> u<33> t<Package_import_declaration> p<34> c<29> l<3>
2223 */
2224 Serializer& s = compileDesign->getSerializer();
2225 while (package_import_item_id) {
2226 import_typespec* import_stmt = s.MakeImport_typespec();
2227 fC->populateCoreMembers(package_import_item_id, package_import_item_id,
2228 import_stmt);
2229 import_stmt->VpiName(fC->SymName(package_import_item_id));
2230 NodeId package_name_id = fC->Child(package_import_item_id);
2231
2232 NodeId item_name_id = fC->Sibling(package_name_id);
2233 Value* item_name = m_exprBuilder.getValueFactory().newStValue();
2234 if (item_name_id) {
2235 item_name->set(fC->SymName(item_name_id));
2236 } else {
2237 item_name->set("*");
2238 }
2239 UHDM::constant* imported_item = constantFromValue(item_name, compileDesign);
2240 if (item_name_id) {
2241 // In case of "*" item_name_id will be 0
2242 fC->populateCoreMembers(item_name_id, item_name_id, imported_item);
2243 }
2244 m_exprBuilder.deleteValue(item_name);
2245 import_stmt->Item(imported_item);
2246
2247 const std::string_view package_name = fC->SymName(package_name_id);
2248 import_stmt->VpiName(package_name);
2249
2250 package_import_item_id = fC->Sibling(package_import_item_id);
2251 component->addImportedSymbol(import_stmt);
2252 }
2253}
2254
2255bool CompileHelper::compileDataDeclaration(
2256 DesignComponent* component, const FileContent* fC, NodeId id,

Callers 6

collectObjects_Method · 0.80
collectObjects_Method · 0.80
collectModuleObjects_Method · 0.80
compileMethod · 0.80
collectObjects_Method · 0.80

Calls 9

populateCoreMembersMethod · 0.80
newStValueMethod · 0.80
getValueFactoryMethod · 0.80
addImportedSymbolMethod · 0.80
SymNameMethod · 0.45
ChildMethod · 0.45
SiblingMethod · 0.45
setMethod · 0.45
deleteValueMethod · 0.45

Tested by

no test coverage detected