33 lines
No EOL
969 B
Rust
33 lines
No EOL
969 B
Rust
use std::thread;
|
|
use std::time::Duration;
|
|
use crate::component::Component;
|
|
use crate::components::clock::generic_clock::GenericClock;
|
|
use crate::components::cpu::intel_4004::Intel4004;
|
|
use crate::connection::connect_pins;
|
|
|
|
pub fn emulation() {
|
|
println!("Starting MCS-4 emulation with pin state resolution...");
|
|
|
|
// Create components
|
|
let mut clock = GenericClock::new("sys_clock".to_string(), 2); // 2Hz clock
|
|
let mut cpu = Intel4004::new("cpu4004".to_string());
|
|
|
|
// Connect clock to CPU using the connection macro
|
|
if let (Some(clock_out), Some(cpu_clk)) = (clock.out(), cpu.clk()) {
|
|
connect_pins(&clock_out, &cpu_clk).expect("Connection could not be made!");
|
|
println!("Connected clock to CPU");
|
|
}
|
|
|
|
// Start components
|
|
clock.run();
|
|
cpu.run();
|
|
|
|
// Let it run for a while
|
|
thread::sleep(Duration::from_secs(5));
|
|
|
|
// Stop components
|
|
clock.stop();
|
|
cpu.stop();
|
|
|
|
println!("Emulation completed");
|
|
} |