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

Method getValue

src/DesignCompile/CompileExpression.cpp:841–1153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

839}
840
841any *CompileHelper::getValue(std::string_view name, DesignComponent *component,
842 CompileDesign *compileDesign, Reduce reduce,
843 ValuedComponentI *instance, PathId fileId,
844 uint32_t lineNumber, any *pexpr, bool muteErrors) {
845 Serializer &s = compileDesign->getSerializer();
846 Value *sval = nullptr;
847 any *result = nullptr;
848 if (loopDetected(fileId, lineNumber, compileDesign, instance)) {
849 return nullptr;
850 }
851 if (m_checkForLoops) {
852 m_stackLevel++;
853 }
854 if (name.find("::") != std::string::npos) {
855 std::vector<std::string_view> res;
856 StringUtils::tokenizeMulti(name, "::", res);
857 if (res.size() > 1) {
858 const std::string_view packName = res[0];
859 const std::string_view varName = res[1];
860 Design *design = compileDesign->getCompiler()->getDesign();
861 if (Package *pack = design->getPackage(packName)) {
862 if (expr *val = pack->getComplexValue(varName)) {
863 result = val;
864 if (result && (result->UhdmType() == uhdmoperation)) {
865 operation *op = (operation *)result;
866 const UHDM::typespec *opts = nullptr;
867 if (ref_typespec *rt = op->Typespec()) {
868 opts = rt->Actual_typespec();
869 }
870 UHDM::ExprEval eval;
871 if (expr *res = eval.flattenPatternAssignments(
872 s, opts, (UHDM::expr *)result)) {
873 if (res->UhdmType() == uhdmoperation) {
874 op->Operands(((operation *)res)->Operands());
875 }
876 }
877 }
878 }
879 if (result == nullptr) {
880 if (Value *sval = pack->getValue(varName)) {
881 UHDM::constant *c = s.MakeConstant();
882 c->VpiValue(sval->uhdmValue());
883 setRange(c, sval, compileDesign);
884 c->VpiDecompile(sval->decompiledValue());
885 c->VpiConstType(sval->vpiValType());
886 c->VpiSize(sval->getSize());
887 result = c;
888 }
889 }
890
891 if (UHDM::VectorOfparam_assign *param_assigns =
892 pack->getParam_assigns()) {
893 for (param_assign *param : *param_assigns) {
894 if (param && param->Lhs()) {
895 const std::string_view param_name = param->Lhs()->VpiName();
896 if (param_name == varName) {
897 if (substituteAssignedValue(param->Rhs(), compileDesign)) {
898 if (param->Rhs()->UhdmType() == uhdmoperation) {

Callers 10

importPackageMethod · 0.45
elaborateInstance_Method · 0.45
collectParams_Method · 0.45
bindVariable_Method · 0.45
lateBindingMethod · 0.45
getObjectMethod · 0.45
compileExpressionMethod · 0.45
elab_parameters_Method · 0.45
bind_net_Method · 0.45

Calls 15

getDesignMethod · 0.80
uhdmValueMethod · 0.80
decompiledValueMethod · 0.80
vpiValTypeMethod · 0.80
getParam_assignsMethod · 0.80
param_assignsMethod · 0.80
variablesMethod · 0.80
ExprMethod · 0.80
getCompilerMethod · 0.45
getPackageMethod · 0.45
getComplexValueMethod · 0.45
getSizeMethod · 0.45

Tested by

no test coverage detected