// Number of zero crosses between two prescaler values. int64_t GPTimer::numberofticksbetween(sc_core::sc_time a, sc_core::sc_time b, int counter, sc_core::sc_time cycletime) { int64_t reload = r[SCRELOAD] + 1; int64_t val_a = valueof(a, 0, cycletime); //int val_b = valueof(b, 0, cycletime); int64_t val_b = valueof(b, counter, cycletime); int64_t num_a = val_a / reload + (val_a > 0 && val_b < 0); int64_t num_b = val_b / reload; return std::abs(num_a - num_b); }
list<pair<char, double> >& ArithmeticCalculator::to_rpn(string const& expr, list<pair<char, double> >& rpnExpr) { string::const_iterator p = expr.begin(); stack<string::const_iterator> ops; while (p != expr.end()) { if (*p == '(') ops.push(p); else if (isop(p)) { while (!ops.empty() && priority(ops.top()) >= priority(p)) { rpnExpr.push_back(make_pair(*(ops.top()), 0.0)); ops.pop(); } ops.push(p); } else if (isdigit(*p) || *p == '.') rpnExpr.push_back(make_pair('\0', valueof(p))); else if (*p == 'x' || *p == 'X' || *p == 'y' || *p == 'Y' || *p == 'z' || *p == 'Z') rpnExpr.push_back(make_pair(*p, 0.0)); else if (*p == ')') { while(*(ops.top()) != '(') { rpnExpr.push_back(make_pair(*(ops.top()), 0.0)); ops.pop(); } // махаме и ( ops.pop(); } p++; } // изпразваме стека while (!ops.empty()) { rpnExpr.push_back(make_pair(*(ops.top()), 0.0)); ops.pop(); } return rpnExpr; }
void Mob::updatemovement() { MoveMobPacket( oid, 1, 0, 0, 0, 0, 0, 0, getposition(), Movement(phobj, valueof(stance, flip)) ).dispatch(); }
// Calback for scaler register. Updates register value before reads. void GPTimer::scaler_read() { sc_core::sc_time now = sc_core::sc_time_stamp(); int64_t reload = r[SCRELOAD] + 1; int64_t value = valueof(now, 0, clock_cycle) - (reload); //if (reload) { value = value % (reload); //} // if (value < 0) { r[SCALER] = reload + value - 1; } else { r[SCALER] = reload - value; } }