summaryrefslogtreecommitdiff
path: root/src/sim/cell
diff options
context:
space:
mode:
Diffstat (limited to 'src/sim/cell')
-rw-r--r--src/sim/cell/cell.rs21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/sim/cell/cell.rs b/src/sim/cell/cell.rs
index 2664721..c4b0a8f 100644
--- a/src/sim/cell/cell.rs
+++ b/src/sim/cell/cell.rs
@@ -9,6 +9,7 @@ pub struct Cell {
impl Cell {
const FLAG_PARITY: u8 = 0b0000_0001;
+ const FLAG_RB: u8 = 0b0000_0010;
#[inline]
pub fn parity(self) -> u8 {
@@ -20,8 +21,24 @@ impl Cell {
}
#[inline]
pub fn match_parity(&mut self, seqno: u64) {
- // TODO this will break with more flags
- self.flags = (seqno as u8) & 0b1;
+ let parity = seqno % 2 != 0;
+ if parity {
+ self.flags |= Self::FLAG_PARITY;
+ } else {
+ self.flags = self.flags & !Self::FLAG_PARITY
+ }
+ }
+
+ #[inline]
+ pub fn rb(self) -> bool {
+ self.flags & Self::FLAG_RB == 1
+ }
+ pub fn set_rb(&mut self, rb: bool) {
+ if rb {
+ self.flags |= Self::FLAG_RB
+ } else {
+ self.flags = self.flags & !Self::FLAG_RB
+ }
}
}