cpu/
types.rs

1//! Simple types used in several places in the crate.
2use std::fmt::Debug;
3
4use serde::Serialize;
5
6use base::prelude::*;
7
8/// Signals that a flag has changed (and why).
9#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
10pub enum FlagChange {
11    Raise(&'static str),
12}
13
14/// A value of which bits 0..width are significant (0 being the least
15/// significant bit).  Hence a six-bit value would be `MaskedWord {
16/// width: 6, value: u13!(0o77) }`
17#[derive(Debug, Clone, Copy, PartialEq, Eq)]
18pub struct MaskedWord {
19    // TODO: code and doc comment seem to be in disagreement, fix this.
20    pub bits: Unsigned36Bit,
21    pub mask: Unsigned36Bit,
22}
23
24impl MaskedWord {
25    #[must_use]
26    pub fn apply(&self, dest: Unsigned36Bit) -> Unsigned36Bit {
27        (dest & !self.mask) | (self.bits & self.mask)
28    }
29}
30
31/// Determines how TSD instructions for Lincoln Writer seuenced behave.
32#[derive(Debug, Clone, Copy, PartialEq, Eq)]
33pub enum TransferMode {
34    /// TSD instructions use the exchange unit (but not sign extension).
35    Exchange,
36    /// TSD instructions use assembly mode.
37    Assembly,
38}
39
40/// Determines whether a memory operation updates the E register.
41#[derive(Debug)]
42pub enum UpdateE {
43    No,
44    Yes,
45}