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

Function TEST

src/DesignCompile/Elaboration_test.cpp:55–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53namespace {
54#if 0
55TEST(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}
106TEST(Elaboration, ExprFromText) {
107 CompileHelper helper;
108 ElaboratorHarness eharness;

Callers

nothing calls this directly

Calls 12

compileExpressionMethod · 0.80
getUhdmDesignMethod · 0.80
ExprMethod · 0.80
elaborateMethod · 0.45
getDefinitionMethod · 0.45
getRootNodeMethod · 0.45
sl_collect_allMethod · 0.45
ChildMethod · 0.45
SymNameMethod · 0.45
SiblingMethod · 0.45
sl_collectMethod · 0.45
getCompilerMethod · 0.45

Tested by

no test coverage detected