Added I/O demo system
CLean up of unused components and functions
This commit is contained in:
parent
77ede95bce
commit
7d06837608
20 changed files with 714 additions and 1924 deletions
|
|
@ -7,7 +7,6 @@
|
|||
use rusty_emu::component::Component;
|
||||
use rusty_emu::components::common::intel_400x::*;
|
||||
use rusty_emu::components::memory::intel_4001::Intel4001;
|
||||
use rusty_emu::pin::PinValue;
|
||||
use std::time::Duration;
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
@ -88,9 +87,6 @@ mod intel_4001_integration_tests {
|
|||
assert_eq!(rom.get_address_latch_time(), Some(test_time));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_common_functionality_with_real_component() {
|
||||
let mut rom = Intel4001::new_with_access_time("ROM_4001".to_string(), 1);
|
||||
|
|
@ -202,7 +198,6 @@ mod intel_4001_integration_tests {
|
|||
assert_eq!(rom2.get_timing_state(), TimingState::Idle);
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_performance_characteristics() {
|
||||
// Test that the common functionality maintains expected performance characteristics
|
||||
|
|
@ -282,7 +277,6 @@ mod intel_4001_integration_tests {
|
|||
assert_eq!(base_for_reset.get_name(), "ROM_4001");
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_cross_component_compatibility() {
|
||||
// Test that components using the same traits are compatible
|
||||
|
|
@ -337,7 +331,6 @@ mod cross_component_integration_tests {
|
|||
assert_eq!(rom2.get_timing_state(), TimingState::AddressPhase);
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_timing_consistency_across_components() {
|
||||
// Test that timing behavior is consistent across different components
|
||||
|
|
|
|||
|
|
@ -1,47 +1,16 @@
|
|||
use rusty_emu::component::{BaseComponent, Component};
|
||||
use rusty_emu::components::common::intel_400x::*;
|
||||
use rusty_emu::pin::PinValue;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::time::{Duration, Instant};
|
||||
|
||||
// Mock component for testing trait implementations
|
||||
#[derive(Debug)]
|
||||
struct MockComponent {
|
||||
pins: HashMap<String, Arc<Mutex<TestPin>>>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct TestPin {
|
||||
value: PinValue,
|
||||
driver: Option<(String, PinValue)>,
|
||||
}
|
||||
|
||||
type Pin = TestPin;
|
||||
|
||||
impl Pin {
|
||||
fn set_driver(&mut self, driver: Option<String>, value: PinValue) {
|
||||
self.driver = driver.map(|name| (name, value));
|
||||
self.value = value;
|
||||
}
|
||||
}
|
||||
struct MockComponent {}
|
||||
|
||||
impl MockComponent {
|
||||
fn new() -> Self {
|
||||
Self {
|
||||
pins: HashMap::new(),
|
||||
}
|
||||
}
|
||||
|
||||
fn add_pin(&mut self, name: &str, pin: Arc<Mutex<Pin>>) {
|
||||
self.pins.insert(name.to_string(), pin);
|
||||
}
|
||||
|
||||
fn get_pin(&self, name: &str) -> Result<Arc<Mutex<TestPin>>, String> {
|
||||
self.pins
|
||||
.get(name)
|
||||
.cloned()
|
||||
.ok_or_else(|| format!("Pin {} not found", name))
|
||||
Self {}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -101,15 +70,11 @@ mod tests {
|
|||
#[test]
|
||||
fn test_assemble_full_address() {
|
||||
// Create a mock trait implementation for testing
|
||||
struct TestAddressHandler {
|
||||
base: MockComponent,
|
||||
}
|
||||
struct TestAddressHandler {}
|
||||
|
||||
impl TestAddressHandler {
|
||||
fn new() -> Self {
|
||||
Self {
|
||||
base: MockComponent::new(),
|
||||
}
|
||||
Self {}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -268,15 +233,11 @@ mod tests {
|
|||
let access_time = Duration::from_nanos(100);
|
||||
|
||||
// Mock address handler for testing the algorithm
|
||||
struct TestAddressHandler {
|
||||
base: MockComponent,
|
||||
}
|
||||
struct TestAddressHandler {}
|
||||
|
||||
impl TestAddressHandler {
|
||||
fn new() -> Self {
|
||||
Self {
|
||||
base: MockComponent::new(),
|
||||
}
|
||||
Self {}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,9 +24,13 @@ mod json_system_tests {
|
|||
// Test loading basic system configuration
|
||||
let result = factory.create_from_json("configs/mcs4_basic.json");
|
||||
|
||||
assert!(result.is_ok(), "Failed to create basic system: {:?}", result.err());
|
||||
assert!(
|
||||
result.is_ok(),
|
||||
"Failed to create basic system: {:?}",
|
||||
result.err()
|
||||
);
|
||||
|
||||
let mut system = result.unwrap();
|
||||
let system = result.unwrap();
|
||||
let info = system.get_system_info();
|
||||
|
||||
// Verify system properties
|
||||
|
|
@ -35,7 +39,6 @@ mod json_system_tests {
|
|||
assert_eq!(info.cpu_speed, 750000.0);
|
||||
}
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_system_component_access() {
|
||||
let factory = SystemFactory::new();
|
||||
|
|
@ -77,7 +80,10 @@ mod json_system_tests {
|
|||
|
||||
// Verify metadata is loaded correctly
|
||||
assert_eq!(info.name, "IntelMcs4");
|
||||
assert_eq!(info.description, "Basic MCS-4 System with CPU, Clock, 2 ROMs, and 1 RAM");
|
||||
assert_eq!(
|
||||
info.description,
|
||||
"Basic MCS-4 System with CPU, Clock, 2 ROMs, and 1 RAM"
|
||||
);
|
||||
assert_eq!(info.component_count, 5);
|
||||
assert_eq!(info.cpu_speed, 750000.0);
|
||||
assert_eq!(info.rom_size, 256);
|
||||
|
|
@ -105,7 +111,6 @@ mod system_execution_tests {
|
|||
let info = system.get_system_info();
|
||||
assert_eq!(info.name, "IntelMcs4");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
@ -137,12 +142,8 @@ mod fibonacci_program_tests {
|
|||
#[test]
|
||||
fn test_program_file_sizes() {
|
||||
// Test that program files have reasonable sizes
|
||||
let fibonacci_size = fs::metadata("programs/fibonacci.bin")
|
||||
.unwrap()
|
||||
.len();
|
||||
let fibonacci_output_size = fs::metadata("programs/fibonacci_output.bin")
|
||||
.unwrap()
|
||||
.len();
|
||||
let fibonacci_size = fs::metadata("programs/fibonacci.bin").unwrap().len();
|
||||
let fibonacci_output_size = fs::metadata("programs/fibonacci_output.bin").unwrap().len();
|
||||
|
||||
// Both should be non-zero and reasonable sizes
|
||||
assert!(fibonacci_size > 0);
|
||||
|
|
@ -156,7 +157,6 @@ mod fibonacci_program_tests {
|
|||
mod configuration_validation_tests {
|
||||
use super::*;
|
||||
|
||||
|
||||
#[test]
|
||||
fn test_component_naming_consistency() {
|
||||
let factory = SystemFactory::new();
|
||||
|
|
@ -167,4 +167,4 @@ mod configuration_validation_tests {
|
|||
assert_eq!(info.name, "IntelMcs4");
|
||||
assert_eq!(info.component_count, 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue