| 53 | namespace { |
| 54 | #if 0 |
| 55 | TEST(Elaboration, ExprFromPpTree) { |
| 56 | CompileHelper helper; |
| 57 | ElaboratorHarness eharness; |
| 58 | |
| 59 | // Preprocess, Parse, Compile, Elaborate |
| 60 | Design* design; |
| 61 | FileContent* fC; |
| 62 | CompileDesign* compileDesign; |
| 63 | std::tie(design, fC, compileDesign) = eharness.elaborate( |
| 64 | "`define A {1'b1, 2'b10}\n" |
| 65 | "\n" |
| 66 | "`define B '{1'b1, 2'b10}\n" |
| 67 | "\n" |
| 68 | "module top();\n" |
| 69 | "parameter p1 = `A;\n" |
| 70 | "parameter p2 = `B;\n" |
| 71 | "endmodule\n"); |
| 72 | |
| 73 | // Get handles |
| 74 | auto insts = design->getTopLevelModuleInstances(); |
| 75 | ModuleInstance* top = nullptr; |
| 76 | DesignComponent* component = nullptr; |
| 77 | if (!insts.empty()) { |
| 78 | top = insts.at(0); |
| 79 | component = top->getDefinition(); |
| 80 | } |
| 81 | NodeId root = fC->getRootNode(); |
| 82 | EXPECT_NE(top, nullptr); |
| 83 | |
| 84 | std::vector<NodeId> assigns = |
| 85 | fC->sl_collect_all(root, VObjectType::paParam_assignment); |
| 86 | EXPECT_EQ(assigns.size(), 2); |
| 87 | for (NodeId param_assign : assigns) { |
| 88 | NodeId param = fC->Child(param_assign); |
| 89 | const std::string_view name = fC->SymName(param); |
| 90 | NodeId rhs = fC->Sibling(param); |
| 91 | // Not reduced |
| 92 | UHDM::expr* exp1 = (UHDM::expr*)helper.compileExpression( |
| 93 | component, fC, rhs, compileDesign, Reduce::No, nullptr, top, true); |
| 94 | EXPECT_EQ(exp1->UhdmType(), UHDM::uhdmoperation); |
| 95 | // Reduced |
| 96 | UHDM::expr* exp2 = (UHDM::expr*)helper.compileExpression( |
| 97 | component, fC, rhs, compileDesign, Reduce::Yes, nullptr, top, true); |
| 98 | if (name == "p1") { |
| 99 | EXPECT_EQ(exp2->UhdmType(), UHDM::uhdmconstant); |
| 100 | bool invalidValue = false; |
| 101 | UHDM::ExprEval eval; |
| 102 | EXPECT_EQ(eval.get_value(invalidValue, exp2), 6); |
| 103 | } |
| 104 | } |
| 105 | } |
| 106 | TEST(Elaboration, ExprFromText) { |
| 107 | CompileHelper helper; |
| 108 | ElaboratorHarness eharness; |
nothing calls this directly
no test coverage detected