void Stream::WriteMembers(const uint8* object, ClassType* pType) { for (uint i = 0; i < pType->m_pScope->m_orderedDecls.size(); i++) { Declarator* decl = pType->m_pScope->m_orderedDecls[i]; if (!decl->get_IsStatic() && !decl->get_IsTypedef()) { Type* pType = decl->m_pType->GetStripped(); Type_type kind = pType->get_Kind(); if (kind == type_array) { ArrayType* array = static_cast<ArrayType*>(pType); size_t count = array->get_ElemCount(); for (size_t i = 0; i < count; ++i) { WriteMember(object + decl->m_offset + i*array->get_ElemType()->get_sizeof(), array->get_ElemType()); } } else if (kind != type_function) { WriteMember(object + decl->m_offset, pType); /* switch (kind) { case type_int: case type_long: case type_unsigned_int: case type_unsigned_long: case type_float: case type_double: case type_long_long: } */ } } } }
/****************************************************************************** Function: DDR_training_test Description: training DDR Input: none Output: none Return: 1 success 0 fail ******************************************************************************/ UINT32 DDR_training_test(void) { volatile UINT32 dwResult; volatile UINT32 dwData; volatile UINT32 i,j,k; unsigned long value = 0; // test 1 #if 0 PRINT_INFO("**** tc1: check training\n"); i = readl( +0xd4) & 0xffff; j = readl(REG_BASE_DDRC_CFG+0xd8) & 0xffff; k = readl(REG_BASE_DDRC_CFG+0x250); if (i == 0xf00 && j == 0xf00 && k != 0) PRINT_INFO("**** tc1: ok\n"); else { PRINT_INFO("**** tc1: failed, 0xd4 = 0x%x, 0xd8 = 0x%x, 0x250 = %d\n", i, j, k); return 0; } PRINT_INFO("------------------------------------------------------\n"); #endif PRINT_INFO("**** tc2: write 64k '0'\n"); dwData = 0x00000000; WriteMember64k(dwData); dwResult = CmpMember64k(dwData); if(0xFFFFFFFF != dwResult) { PRINT_INFO("**** tc2: failed\n"); return 0; } else { PRINT_INFO("**** tc2:ok\n"); } PRINT_INFO("------------------------------------------------------\n"); PRINT_INFO("**** tc3: write 64k '1'\n"); dwData = 0xffffffff; WriteMember64k(dwData); dwResult = CmpMember64k(dwData); if(0xFFFFFFFF != dwResult) { PRINT_INFO("**** tc3: failed\n"); return 0; } else { PRINT_INFO("**** tc3:ok\n"); } PRINT_INFO("------------------------------------------------------\n"); PRINT_INFO("**** tc4: write 1 giga '0'\n"); dwData = 0x00000000; WriteMember(dwData); dwResult = CmpAndWriteMember(dwData, 0xFFFFFFFF); if(0xFFFFFFFF != dwResult) { PRINT_INFO("**** tc4: failed\n"); return 0; } else { PRINT_INFO("**** tc4:ok\n"); } PRINT_INFO("------------------------------------------------------\n"); PRINT_INFO("**** tc5: cmp 1 giga '1'\n"); dwData = 0xFFFFFFFF; dwResult = CmpMember(dwData); if(0xFFFFFFFF != dwResult) { PRINT_INFO("**** tc5: failed\n"); return 0; } else { PRINT_INFO("**** tc5:ok\n"); } PRINT_INFO("------------------------------------------------------\n"); PRINT_INFO("**** tc6: write 1 giga 'addr'\n"); /* second write address test */ WriteMemberAddr(); dwResult = CmpAndWriteMemberAddr(); if(0xFFFFFFFF != dwResult) { PRINT_INFO("**** tc6: failed\n"); return 0; } else { PRINT_INFO("**** tc6:ok\n"); } PRINT_INFO("------------------------------------------------------\n"); PRINT_INFO("**** tc7: cmd 1 giga 'addr'\n"); dwResult = CmpMemberRevAddr(); if(0xFFFFFFFF != dwResult) { PRINT_INFO("**** tc7: failed\n"); return 0; } else { PRINT_INFO("**** tc7:ok\n"); } PRINT_INFO("------------------------------------------------------\n"); PRINT_INFO("training test OK\n"); return 1; }
bool Attribute::SetMember (std::string expr, const vector<Attribute*>& obs_attribs, bool verbose){ //set my own symbol m_symbol_name = m_prototype->GetName()+"x"+m_name; //attribute represents a std::string //if (GetTypeID()==typeid(std::string*).name()) { WriteMember(expr); return true; } //attribute represents a PulseAxis if (GetTypeID()==typeid(PulseAxis*).name()) { if (expr=="RF") { WriteMember(AXIS_RF); return true; } if (expr=="GX") { WriteMember(AXIS_GX); return true; } if (expr=="GY") { WriteMember(AXIS_GY); return true; } if (expr=="GZ") { WriteMember(AXIS_GZ); return true; } else { WriteMember(AXIS_VOID); return true; } } //GiNaC expressions Prototype::ReplaceString(expr,"step","csgn"); if (expr.find("I", 0)!=std::string::npos) m_complex = true; m_subjects.clear(); m_symlist.remove_all(); //GiNaC::symbol d(m_sym_diff); //loop over all possibly observed subjects for (unsigned int i=0; i<obs_attribs.size() ; i++) { //convert string "a1","a2", ... to the matching symbol name Attribute* subject_attrib = obs_attribs.at(i); std::string SymbolName = subject_attrib->GetPrototype()->GetName() + "x" + subject_attrib->GetName(); stringstream key; key << "a" << i+1; if (!Prototype::ReplaceString(expr,key.str(),SymbolName)) continue; //still here? the attribute was in the expression, so it is an observed subject AttachSubject( subject_attrib ); m_symlist.append( get_symbol(SymbolName) ); } //cout << "!!! " << GetPrototype()->GetName() << " : " << expr << " , " << m_symlist << endl; m_formula = expr; //stop for strings if (GetTypeID()==typeid(std::string*).name()) { EvalExpression (); return true; } //build GiNaC expression (maybe not successful at first call, if subjects still missing) try { m_expression = GiNaC::ex(m_formula,m_symlist); //differentiation of expression? if (m_diff>0) { m_expression = m_expression.diff(get_symbol(m_sym_diff),m_diff); stringstream se; se << m_expression; m_formula = se.str(); } //test the expression evaluation once EvalExpression (); } catch (exception &p) { if ( verbose ) { cout << "Warning in " << m_prototype->GetName() << ": attribute " << GetName() << " can not evaluate its GiNaC expression E = " << expr << ". Reason: " << p.what() << endl; } return false; } return true; }
void Attribute::EvalExpression () { if (m_formula.empty()) return; //strings: simply replace attribute symbol by its value if (GetTypeID()==typeid(std::string*).name()) { std::string expr = m_formula; for (unsigned int i=0; i<m_subjects.size() ; i++) { Attribute* a = m_subjects.at(i); stringstream key; if (a->GetTypeID()==typeid( double*).name()) key << a->GetMember <double>() ; if (a->GetTypeID()==typeid( int*).name()) key << a->GetMember <int>() ; if (a->GetTypeID()==typeid( long*).name()) key << a->GetMember <long>() ; if (a->GetTypeID()==typeid(unsigned*).name()) key << a->GetMember<unsigned>() ; if (a->GetTypeID()==typeid( bool*).name()) key << a->GetMember <bool>() ; std::string SymbolName = a->GetPrototype()->GetName() + "x" + a->GetName(); Prototype::ReplaceString(expr,SymbolName,key.str()); } WriteMember(expr); //if (GetName()=="Filename") cout << " Eval: " << expr << endl; return; } //collect symbols and corresponding member-values from observed attributes GiNaC::lst numlist; for (unsigned int i=0; i<m_subjects.size() ; i++) { Attribute* a = m_subjects.at(i); if (a->GetTypeID()==typeid( double*).name()) { numlist.append(a->GetMember <double>() ); continue; } if (a->GetTypeID()==typeid( int*).name()) { numlist.append(a->GetMember <int>() ); continue; } if (a->GetTypeID()==typeid( long*).name()) { numlist.append(a->GetMember <long>() ); continue; } if (a->GetTypeID()==typeid(unsigned*).name()) { numlist.append(a->GetMember<unsigned>() ); continue; } if (a->GetTypeID()==typeid( bool*).name()) { numlist.append(a->GetMember <bool>() ); continue; } } //numeric evaluation of GiNaC expression GiNaC::ex e = m_expression.subs(m_symlist,numlist); m_static_vector = m_prototype->GetVector(); // static pointer to evaluate the Vector function e = GiNaC::evalf(e); double d = 0.0; if (GiNaC::is_a<GiNaC::numeric>(e)) { if ( m_complex ) m_imaginary = -0.5 * GiNaC::ex_to<GiNaC::numeric>( (e-e.conjugate())*GiNaC::I ).to_double(); d = GiNaC::ex_to<GiNaC::numeric>( e ).to_double();//default is real-part } //overwrite private member if (m_datatype==typeid( double*).name() ) WriteMember((double) d ); if (m_datatype==typeid( int*).name() ) WriteMember((int) d ); if (m_datatype==typeid( long*).name() ) WriteMember((long) d ); if (m_datatype==typeid(unsigned*).name() ) WriteMember((unsigned) d ); if (m_datatype==typeid( bool*).name() ) WriteMember((bool) d ); // for dynamic change of runtime compiled attributes after notification! if (m_ginac_excomp && m_cur_fp==m_num_fp && m_num_fp>0) { //cout << "!!! " << GetName() << " : NFP =" << GetNumberFunctionPointers() << endl; //cout << "!!! " << GetName() << " : CFP =" << GetCurrentFunctionPointer() << endl; //cout << "!!! " << GetName() << " : size=" << m_compiled.size() << endl; if (m_compiled.size() == m_cur_fp ) m_compiled.push_back(false); } }