// Exercise B4, chip-level version: the chip and wires of schematic 2 and
// of the breadboard.  Same ports as d_flip_flop.sv.
//
// Generated by tools/bb_lib.py from the checked breadboard wire list;
// change the layout in tools/bb_b4.py, not this file.  Synthesizable.

module d_flip_flop_chips
(
    input  logic       clk,
    input  logic       rst,
    input  logic       d,
    output logic       q,
    output logic       q_n
);

    // The power rails of the breadboard, for tied-off inputs

    wire gnd = 1'b0;

    // Outputs that go nowhere

    wire unused_u1_q2_n;
    wire unused_u1_q2;

    //------------------------------------------------------------------------

    // U1: CD4013 dual D flip-flop with set and reset, pin 1 in column 18

    cd4013 i_u1
    (
        .q1     ( q              ),  // Pin 1 -> Q
        .q1_n   ( q_n            ),  // Pin 2 -> ~Q
        .clock1 ( clk            ),  // Pin 3 <- 555 clock module
        .reset1 ( rst            ),  // Pin 4 <- reset button
        .d1     ( d              ),  // Pin 5 <- button D
        .set1   ( gnd            ),  // Pin 6 <- GND
        .set2   ( gnd            ),  // Pin 8 <- GND, unused input
        .d2     ( gnd            ),  // Pin 9 <- GND, unused input
        .reset2 ( gnd            ),  // Pin 10 <- GND, unused input
        .clock2 ( gnd            ),  // Pin 11 <- GND, unused input
        .q2_n   ( unused_u1_q2_n ),  // Pin 12, unused output
        .q2     ( unused_u1_q2   )   // Pin 13, unused output
    );

endmodule
