Implement interrupt
This commit is contained in:
parent
b39e56b9c4
commit
4dae299008
38
src/simulator/interrupt.rs
Normal file
38
src/simulator/interrupt.rs
Normal file
@ -0,0 +1,38 @@
|
||||
|
||||
|
||||
struct Interrupt {
|
||||
level: InterruptStatus
|
||||
}
|
||||
|
||||
impl Interrupt {
|
||||
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
level: InterruptStatus::InterruptOff
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_status(&mut self, newStatus: InterruptStatus) -> InterruptStatus {
|
||||
let old = self.level;
|
||||
self.level = newStatus;
|
||||
if newStatus == InterruptStatus::InterruptOn && old == InterruptStatus::InterruptOff {
|
||||
self.one_tick(1);
|
||||
}
|
||||
old
|
||||
}
|
||||
|
||||
fn one_tick(&self, nb_cycle: i32) {
|
||||
todo!();
|
||||
}
|
||||
|
||||
pub fn get_status(&self) -> InterruptStatus {
|
||||
self.level
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Clone, Copy)]
|
||||
pub enum InterruptStatus {
|
||||
InterruptOff,
|
||||
InterruptOn
|
||||
}
|
@ -2,7 +2,7 @@ pub mod machine;
|
||||
pub mod decode;
|
||||
pub mod print;
|
||||
pub mod mem_cmp;
|
||||
|
||||
pub mod interrupt;
|
||||
|
||||
pub mod global {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user