feat: Add real-time data display for CPU registers, RAM, and ROM

This commit is contained in:
Jan-Peter von Hunnius 2026-02-26 19:36:59 +01:00
parent 3530ea5f28
commit 6636417d18
22 changed files with 1233 additions and 188 deletions

View file

@ -1,3 +1,4 @@
use std::any::Any;
use std::collections::HashMap;
use std::sync::{Arc, Mutex};
use std::thread;
@ -47,22 +48,6 @@ pub struct Intel4002 {
pending_operation: PendingOperation,
}
/// RAM register operations (for WRM/WRR instructions)
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum RamOperation {
Read, // Read from RAM register
Write, // Write to RAM register
WriteOr, // Write to RAM register with OR operation
WriteAnd, // Write to RAM register with AND operation
}
/// RAM access modes (for SRC/SRC instructions)
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum RamAccessMode {
Direct, // Direct access to RAM
Indirect, // Indirect access via register pair
}
impl Intel400xClockHandling for Intel4002 {
fn get_base(&self) -> &BaseComponent {
&self.base
@ -403,17 +388,6 @@ impl Intel4002 {
}
}
/// Read from a specific I/O port
/// Parameters: port - I/O port number (0-3)
/// Returns: 4-bit value from I/O port
pub fn read_io_port(&self, port: usize) -> u8 {
if port < 4 {
self.io_ports[port]
} else {
0
}
}
/// Write to a specific I/O port
/// Parameters: port - I/O port number (0-3), data - 4-bit data to write
/// Returns: Ok(()) on success, Err(String) on failure
@ -453,25 +427,6 @@ impl Intel4002 {
}
}
/// Drive status character on status pins
fn drive_status_character(&self) {
let status = self.status_character & 0x7F; // Ensure only 7 bits
for i in 0..4 {
if let Ok(pin) = self.base.get_pin(&format!("S{}", i)) {
if let Ok(mut pin_guard) = pin.lock() {
let bit_value = (status >> i) & 1;
let pin_value = if bit_value == 1 {
PinValue::High
} else {
PinValue::Low
};
pin_guard.set_driver(Some(self.base.name()), pin_value);
}
}
}
}
/// Handle Φ1 rising edge - Address and control phase
/// Hardware: Φ1 high = CPU drives bus with address/control information
/// Memory operations start when SYNC goes high during Φ1 rising edge
@ -699,13 +654,6 @@ impl Intel4002 {
self.on_state_entry(new_state);
}
}
/// Helper function to execute unified state machine logic
fn execute_state_machine(&mut self) {
// Execute the current state logic using the unified state machine
let current_state = self.state_machine.get_state();
self.execute_state_logic(current_state);
}
}
impl Component for Intel4002 {
@ -800,6 +748,10 @@ impl Component for Intel4002 {
fn is_running(&self) -> bool {
self.base.is_running()
}
fn as_any(&self) -> &dyn Any {
self
}
}
impl RunnableComponent for Intel4002 {}