feat: migrate to parking_lot mutex and add system control architecture

This commit is contained in:
Jan-Peter von Hunnius 2026-02-28 18:27:27 +01:00
parent 14060e15e5
commit 54144d10e9
29 changed files with 2387 additions and 1130 deletions

View file

@ -32,8 +32,8 @@ fn create_test_ram() -> Intel4002 {
let phi1_pin = ram.get_pin("PHI1").unwrap();
let phi2_pin = ram.get_pin("PHI2").unwrap();
{
let mut phi1_guard = phi1_pin.lock().unwrap();
let mut phi2_guard = phi2_pin.lock().unwrap();
let mut phi1_guard = phi1_pin.lock();
let mut phi2_guard = phi2_pin.lock();
phi1_guard.set_driver(Some("TEST".to_string()), PinValue::Low);
phi2_guard.set_driver(Some("TEST".to_string()), PinValue::Low);
}
@ -55,7 +55,7 @@ fn set_data_bus(ram: &Intel4002, value: u8) {
for i in 0..4 {
if let Ok(pin) = ram.get_pin(&format!("D{}", i)) {
if let Ok(mut pin_guard) = pin.lock() {
if let Some(mut pin_guard) = pin.try_lock() {
let bit_value = (nibble >> i) & 1;
let pin_value = if bit_value == 1 {
PinValue::High
@ -74,7 +74,7 @@ fn set_data_bus(ram: &Intel4002, value: u8) {
fn clear_data_bus_drivers(ram: &Intel4002) {
for i in 0..4 {
if let Ok(pin) = ram.get_pin(&format!("D{}", i)) {
if let Ok(mut pin_guard) = pin.lock() {
if let Some(mut pin_guard) = pin.try_lock() {
pin_guard.remove_driver("TEST");
}
}
@ -90,8 +90,8 @@ fn generate_clock_edge(ram: &mut Intel4002, phi1_high: bool, phi2_high: bool) {
// Set clock pins
{
let mut phi1_guard = phi1_pin.lock().unwrap();
let mut phi2_guard = phi2_pin.lock().unwrap();
let mut phi1_guard = phi1_pin.lock();
let mut phi2_guard = phi2_pin.lock();
phi1_guard.set_driver(
Some("TEST".to_string()),
@ -217,16 +217,16 @@ fn test_ram_read_state_progression() {
// Read data bus value
let mut data_value = 0;
if d0_pin.lock().unwrap().read() == PinValue::High {
if d0_pin.lock().read() == PinValue::High {
data_value |= 1 << 0;
}
if d1_pin.lock().unwrap().read() == PinValue::High {
if d1_pin.lock().read() == PinValue::High {
data_value |= 1 << 1;
}
if d2_pin.lock().unwrap().read() == PinValue::High {
if d2_pin.lock().read() == PinValue::High {
data_value |= 1 << 2;
}
if d3_pin.lock().unwrap().read() == PinValue::High {
if d3_pin.lock().read() == PinValue::High {
data_value |= 1 << 3;
}
@ -470,7 +470,7 @@ fn test_reset_functionality() {
// Assert RESET (active low)
let reset_pin = ram.get_pin("RESET").unwrap();
{
let mut reset_guard = reset_pin.lock().unwrap();
let mut reset_guard = reset_pin.lock();
reset_guard.set_driver(Some("TEST".to_string()), PinValue::Low);
}
wait_for_pin_settlement();