sat_counter.hh (13962:9c1c64414fb7) | sat_counter.hh (14210:8f7626532f4d) |
---|---|
1/* 2 * Copyright (c) 2019 Inria 3 * All rights reserved. 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 221 unchanged lines hidden (view full) --- 230 231 /** 232 * Whether the counter has achieved its maximum value or not. 233 * 234 * @return True if the counter saturated. 235 */ 236 bool isSaturated() const { return counter == maxVal; } 237 | 1/* 2 * Copyright (c) 2019 Inria 3 * All rights reserved. 4 * 5 * The license below extends only to copyright in the software and shall 6 * not be construed as granting a license to any other intellectual 7 * property including but not limited to intellectual property relating 8 * to a hardware implementation of the functionality of the software --- 221 unchanged lines hidden (view full) --- 230 231 /** 232 * Whether the counter has achieved its maximum value or not. 233 * 234 * @return True if the counter saturated. 235 */ 236 bool isSaturated() const { return counter == maxVal; } 237 |
238 /** 239 * Saturate the counter. 240 * 241 * @return The value added to the counter to reach saturation. 242 */ 243 uint8_t saturate() 244 { 245 const uint8_t diff = maxVal - counter; 246 counter = maxVal; 247 return diff; 248 } 249 |
|
238 private: 239 uint8_t initialVal; 240 uint8_t maxVal; 241 uint8_t counter; 242}; 243 244#endif // __BASE_SAT_COUNTER_HH__ | 250 private: 251 uint8_t initialVal; 252 uint8_t maxVal; 253 uint8_t counter; 254}; 255 256#endif // __BASE_SAT_COUNTER_HH__ |