summaryrefslogtreecommitdiff
path: root/src/sim/cell/cell.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/sim/cell/cell.rs')
-rw-r--r--src/sim/cell/cell.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/sim/cell/cell.rs b/src/sim/cell/cell.rs
index d567893..edb2402 100644
--- a/src/sim/cell/cell.rs
+++ b/src/sim/cell/cell.rs
@@ -10,6 +10,7 @@ pub struct Cell {
impl Cell {
const FLAG_PARITY: u8 = 0b0000_0001;
const FLAG_RB: u8 = 0b0000_0010;
+ const MASK_SETTLED: u8 = 0b0001_1100;
#[inline]
pub fn parity(self) -> u8 {
@@ -33,6 +34,7 @@ impl Cell {
pub fn rb(self) -> bool {
(self.flags & Self::FLAG_RB) == Self::FLAG_RB
}
+ #[inline]
pub fn set_rb(&mut self, rb: bool) {
if rb {
self.flags |= Self::FLAG_RB
@@ -40,6 +42,28 @@ impl Cell {
self.flags = self.flags & !Self::FLAG_RB
}
}
+
+ #[inline]
+ pub fn settled(self) -> u8 {
+ (self.flags & Self::MASK_SETTLED) >> 2
+ }
+ #[inline]
+ fn set_settled(&mut self, settled: u8) {
+ debug_assert!(settled <= 7);
+ self.flags = (settled << 2) | (self.flags & !Self::MASK_SETTLED);
+ }
+ #[inline]
+ pub fn reset_settled(&mut self) {
+ self.flags &= !Self::MASK_SETTLED;
+ }
+
+ #[inline]
+ pub fn increment_settled(&mut self) {
+ let s = self.settled();
+ if s < 7 {
+ self.set_settled(s + 1);
+ }
+ }
}
impl Cell {