| 1 | // Copyright © 2004-2006 University of Helsinki, Department of Computer Science | |
| 2 | // Copyright © 2012 various contributors | |
| 3 | // This software is released under GNU Lesser General Public License 2.1. | |
| 4 | // The license text is at http://www.gnu.org/licenses/lgpl-2.1.html | |
| 5 | ||
| 6 | package fi.helsinki.cs.titokone.devices; | |
| 7 | ||
| 8 | import fi.helsinki.cs.titokone.*; | |
| 9 | ||
| 10 | /** | |
| 11 | * an "RTC" , though not recording real time but clocks since reset | |
| 12 | */ | |
| 13 | public class RTC | |
| 14 | implements IODevice, InterruptGenerator { | |
| 15 | protected Interruptable pic; | |
| 16 | 3 | protected int count = 0; |
| 17 | 3 | protected int watchdog = 0; |
| 18 | ||
| 19 | public int getPortCount() { | |
| 20 | 3 | return 1; |
| 21 | } | |
| 22 | ||
| 23 | @Override | |
| 24 | public int getPort(int n) { | |
| 25 | 1 | if (n == 0) { |
| 26 | 1 | return count; |
| 27 | } | |
| 28 | 5 | throw new RuntimeException("should not be possible " + n); |
| 29 | } | |
| 30 | ||
| 31 | @Override | |
| 32 | public void setPort(int n, int value) { | |
| 33 | 1 | if (n == 0) { |
| 34 | 1 | watchdog = value; |
| 35 | return; | |
| 36 | } | |
| 37 | 5 | throw new RuntimeException("should not be possible " + n); |
| 38 | } | |
| 39 | ||
| 40 | public void reset() { | |
| 41 | 4 | watchdog = count = 0; |
| 42 | } | |
| 43 | ||
| 44 | public void update() { | |
| 45 | 4 | count++; |
| 46 | 2 | if (watchdog > 0) { |
| 47 | 4 | watchdog--; |
| 48 | 1 | if (watchdog == 0) { |
| 49 | 1 | pic.flagInterrupt(this); |
| 50 | } | |
| 51 | } | |
| 52 | } | |
| 53 | ||
| 54 | public void link(Interruptable pic) { | |
| 55 | 1 | this.pic = pic; |
| 56 | } | |
| 57 | } | |
Mutations | ||
| 16 |
Substituted 0 with 1 : SURVIVED Removed assignment to member variable count : SURVIVED Substituted 0 with 1 : SURVIVED |
|
| 17 |
Substituted 0 with 1 : SURVIVED Substituted 0 with 1 : SURVIVED Removed assignment to member variable watchdog : SURVIVED |
|
| 20 |
Substituted 1 with 0 : SURVIVED replaced return of integer sized value with (x == 0 ? 1 : 0) : SURVIVED Substituted 1 with 0 : SURVIVED |
|
| 25 |
negated conditional : NO_COVERAGE |
|
| 26 |
replaced return of integer sized value with (x == 0 ? 1 : 0) : NO_COVERAGE |
|
| 28 |
removed call to java/lang/StringBuilder::append : NO_COVERAGE removed call to java/lang/RuntimeException::<init> : NO_COVERAGE removed call to java/lang/StringBuilder::toString : NO_COVERAGE removed call to java/lang/StringBuilder::append : NO_COVERAGE removed call to java/lang/StringBuilder::<init> : NO_COVERAGE |
|
| 33 |
negated conditional : NO_COVERAGE |
|
| 34 |
Removed assignment to member variable watchdog : NO_COVERAGE |
|
| 37 |
removed call to java/lang/StringBuilder::append : NO_COVERAGE removed call to java/lang/StringBuilder::append : NO_COVERAGE removed call to java/lang/StringBuilder::toString : NO_COVERAGE removed call to java/lang/RuntimeException::<init> : NO_COVERAGE removed call to java/lang/StringBuilder::<init> : NO_COVERAGE |
|
| 41 |
Removed assignment to member variable count : SURVIVED Removed assignment to member variable watchdog : SURVIVED Substituted 0 with 1 : SURVIVED Substituted 0 with 1 : SURVIVED |
|
| 45 |
Removed assignment to member variable count : NO_COVERAGE Substituted 1 with 0 : NO_COVERAGE Replaced integer addition with subtraction : NO_COVERAGE Substituted 1 with 0 : NO_COVERAGE |
|
| 46 |
negated conditional : NO_COVERAGE changed conditional boundary : NO_COVERAGE |
|
| 47 |
Substituted 1 with 0 : NO_COVERAGE Replaced integer subtraction with addition : NO_COVERAGE Removed assignment to member variable watchdog : NO_COVERAGE Substituted 1 with 0 : NO_COVERAGE |
|
| 48 |
negated conditional : NO_COVERAGE |
|
| 49 |
removed call to fi/helsinki/cs/titokone/Interruptable::flagInterrupt : NO_COVERAGE |
|
| 55 |
Removed assignment to member variable pic : SURVIVED |