// Pin-connected model. state observes the counter outputs without adding hardware.
// Q7 self-reset is an asynchronous feedback path: use the generic core on FPGA/ASIC.
// Simulation checks settled states, not physical reset pulse widths or hazards.

module traffic_light_chips
(
    input              clk,
    input              rst,

    output             red,
    output             yellow,
    output             green,
    output       [9:0] state
);

    logic rst_counter;

    cd4017b u1
    (
        .p1_q5        (state [5]),
        .p2_q1        (state [1]),
        .p3_q0        (state [0]),
        .p4_q2        (state [2]),
        .p5_q6        (state [6]),
        .p6_q7        (state [7]),
        .p7_q3        (state [3]),
        .p9_q8        (state [8]),
        .p10_q4       (state [4]),
        .p11_q9       (state [9]),
        .p12_carry    (),
        .p13_inhibit  (1'b0),
        .p14_clock    (clk),
        .p15_reset    (rst_counter)
    );

    cd4075b u2
    (
        .p1_c         (state [0]),
        .p2_b         (state [1]),
        .p3_f         (state [4]),
        .p4_e         (state [5]),
        .p5_d         (state [6]),
        .p6_k         (red),
        .p8_a         (state [2]),
        .p9_j         (green),
        .p10_l        (rst_counter),
        .p11_i        (state [7]),
        .p12_h        (rst),
        .p13_g        (1'b0)
    );

    assign yellow = state [3];

endmodule
