1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// This file is part of zinc64.
// Copyright (c) 2016-2019 Sebastian Jastrzebski. All rights reserved.
// Licensed under the GPLv3. See LICENSE file in the project root for full license text.

use bit_field::BitField;
// use log::LogLevel;

pub struct IrqLine {
    #[allow(unused)]
    kind: &'static str,
    signal: u8,
}

impl IrqLine {
    pub fn new(kind: &'static str) -> Self {
        Self { kind, signal: 0 }
    }

    pub fn is_low(&self) -> bool {
        self.signal != 0
    }

    pub fn reset(&mut self) {
        self.signal = 0;
    }

    pub fn set_low(&mut self, source: usize, value: bool) {
        /* if log_enabled!(LogLevel::Trace) {
            trace!(
                target: "cpu::int", "{}.{:?} {}",
                self.kind,
                source,
                if value { "set " } else { "cleared " }
            );
        } */
        self.signal.set_bit(source, value);
    }
}