Implement interrupt

This commit is contained in:
Quentin Legot 2023-03-01 17:18:45 +01:00 committed by François Autin
parent 621b0568b0
commit e4db7ec96b
No known key found for this signature in database
GPG Key ID: 343F5D382E1DD77C
2 changed files with 39 additions and 0 deletions

View 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
}

View File

@ -3,6 +3,7 @@ pub mod decode;
pub mod print;
pub mod mem_cmp;
pub mod loader;
pub mod interrupt;
pub mod global {