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

Method expandPatternAssignment

src/DesignCompile/CompileHelper.cpp:5008–5300  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5006}
5007
5008UHDM::expr* CompileHelper::expandPatternAssignment(const typespec* tps,
5009 UHDM::expr* rhs,
5010 DesignComponent* component,
5011 CompileDesign* compileDesign,
5012 ValuedComponentI* instance) {
5013 FileSystem* const fileSystem = FileSystem::getInstance();
5014 Serializer& s = compileDesign->getSerializer();
5015
5016 expr* result = rhs;
5017 VectorOfany* vars = nullptr;
5018 if (tps == nullptr) return result;
5019 if (tps->UhdmType() == uhdmpacked_array_typespec ||
5020 tps->UhdmType() == uhdmlogic_typespec ||
5021 tps->UhdmType() == uhdmstruct_typespec) {
5022 vars = s.MakeAnyVec();
5023 }
5024
5025 bool invalidValue = false;
5026 uint64_t size =
5027 Bits(tps, invalidValue, component, compileDesign, Reduce::Yes, instance,
5028 fileSystem->toPathId(rhs->VpiFile(),
5029 compileDesign->getCompiler()->getSymbolTable()),
5030 rhs->VpiLineNo(), false);
5031 uint64_t patternSize = 0;
5032
5033 UHDM::ExprEval eval(true);
5034 rhs = eval.flattenPatternAssignments(s, tps, rhs);
5035
5036 std::vector<int32_t> values(size, 0);
5037 if (rhs->UhdmType() == uhdmoperation) {
5038 operation* op = (operation*)rhs;
5039 int32_t opType = op->VpiOpType();
5040 if (opType == vpiConditionOp) {
5041 VectorOfany* ops = op->Operands();
5042 ops->at(1) = expandPatternAssignment(tps, (expr*)ops->at(1), component,
5043 compileDesign, instance);
5044 ops->at(2) = expandPatternAssignment(tps, (expr*)ops->at(2), component,
5045 compileDesign, instance);
5046 return result;
5047 } else if (opType == vpiAssignmentPatternOp) {
5048 VectorOfany* operands = op->Operands();
5049 if (operands) {
5050 // Get default
5051 int32_t defaultval = 0;
5052 bool taggedPattern = false;
5053 for (any* op : *operands) {
5054 if (op->UhdmType() == uhdmtagged_pattern) {
5055 taggedPattern = true;
5056 tagged_pattern* tp = (tagged_pattern*)op;
5057 if (const UHDM::ref_typespec* rt = tp->Typespec()) {
5058 if (const typespec* tpsi = rt->Actual_typespec()) {
5059 if (tpsi->VpiName() == "default") {
5060 bool invalidValue = false;
5061 UHDM::ExprEval eval;
5062 defaultval = eval.get_value(
5063 invalidValue,
5064 reduceExpr(
5065 tp->Pattern(), invalidValue, component, compileDesign,

Callers 4

collectParams_Method · 0.80
writeCont_assignMethod · 0.80
elab_parameters_Method · 0.80
high_conn_Method · 0.80

Calls 4

parseInt64Function · 0.85
toPathIdMethod · 0.80
getSymbolTableMethod · 0.45
getCompilerMethod · 0.45

Tested by

no test coverage detected