| 308 | } |
| 309 | |
| 310 | void ModuleInstance::overrideParentChild(ModuleInstance* parent, |
| 311 | ModuleInstance* interm, |
| 312 | ModuleInstance* child, |
| 313 | UHDM::Serializer& s) { |
| 314 | if (parent != this) return; |
| 315 | Netlist* netlist = interm->getNetlist(); |
| 316 | if (netlist) { |
| 317 | if (netlist->cont_assigns() || netlist->process_stmts() || |
| 318 | netlist->array_nets() || netlist->param_assigns() || |
| 319 | netlist->array_vars() || netlist->nets() || netlist->variables() || |
| 320 | netlist->interface_arrays() || netlist->interfaces()) |
| 321 | return; |
| 322 | } |
| 323 | |
| 324 | Netlist* child_netlist = child->getNetlist(); |
| 325 | if (netlist->param_assigns()) { |
| 326 | auto params = child_netlist->param_assigns(); |
| 327 | if (params == nullptr) { |
| 328 | params = s.MakeParam_assignVec(); |
| 329 | } |
| 330 | child_netlist->param_assigns(params); |
| 331 | for (auto p : *netlist->param_assigns()) { |
| 332 | params->push_back(p); |
| 333 | } |
| 334 | } |
| 335 | |
| 336 | // Loop indexes |
| 337 | for (auto& param : interm->getMappedValues()) { |
| 338 | const std::string_view name = param.first; |
| 339 | Value* val = param.second.first; |
| 340 | auto params = child_netlist->param_assigns(); |
| 341 | if (params == nullptr) { |
| 342 | params = s.MakeParam_assignVec(); |
| 343 | } |
| 344 | child_netlist->param_assigns(params); |
| 345 | bool found = false; |
| 346 | for (auto p : *params) { |
| 347 | if (p->VpiName() == name) { |
| 348 | found = true; |
| 349 | break; |
| 350 | } |
| 351 | } |
| 352 | if (!found) { |
| 353 | UHDM::parameter* p = s.MakeParameter(); |
| 354 | p->VpiName(name); |
| 355 | if (val && val->isValid()) p->VpiValue(val->uhdmValue()); |
| 356 | p->VpiLineNo(param.second.second); |
| 357 | p->VpiLocalParam(true); |
| 358 | UHDM::int_typespec* ts = s.MakeInt_typespec(); |
| 359 | UHDM::ref_typespec* rt = s.MakeRef_typespec(); |
| 360 | rt->VpiParent(p); |
| 361 | p->Typespec(rt); |
| 362 | rt->Actual_typespec(ts); |
| 363 | UHDM::param_assign* pass = s.MakeParam_assign(); |
| 364 | pass->Lhs(p); |
| 365 | UHDM::constant* c = s.MakeConstant(); |
| 366 | c->VpiValue(val->uhdmValue()); |
| 367 | pass->Rhs(c); |
no test coverage detected