| 2206 | } |
| 2207 | |
| 2208 | void 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 | |
| 2255 | bool CompileHelper::compileDataDeclaration( |
| 2256 | DesignComponent* component, const FileContent* fC, NodeId id, |
no test coverage detected