libttl 0.1.1

A library for simulating TTL logic chips
Documentation
use libttl::chips::{Chip, Chip7400, PinType};
use libttl::logic_level::nand;
mod chip_tests_common; // Import common test functions
use chip_tests_common::*;

#[test]
fn test_7400_pin_types() {
    let chip = Chip7400::new();
    let expected = [
        (1, PinType::Input), (2, PinType::Input), (3, PinType::Output),
        (4, PinType::Input), (5, PinType::Input), (6, PinType::Output),
        (8, PinType::Output), (9, PinType::Input), (10, PinType::Input),
        (11, PinType::Output), (12, PinType::Input), (13, PinType::Input),
        // Vcc/Gnd tested in common helper
    ];
    test_pin_types(&chip, &expected);
     assert_eq!(chip.pin_count(), 14);
     assert_eq!(chip.name(), "7400");
}

#[test]
fn test_7400_logic() {
    let mut chip = Chip7400::new();

    // Gate 1: Inputs 1, 2 -> Output 3
    test_logic_2_input_1_output(&mut chip, 1, 2, 3, nand);

    // Gate 2: Inputs 4, 5 -> Output 6
    test_logic_2_input_1_output(&mut chip, 4, 5, 6, nand);

    // Gate 3: Inputs 9, 10 -> Output 8
    test_logic_2_input_1_output(&mut chip, 9, 10, 8, nand);

    // Gate 4: Inputs 12, 13 -> Output 11
    test_logic_2_input_1_output(&mut chip, 12, 13, 11, nand);
}