// CD40174B: hex D flip-flop with a common clock and a common clear.
//
// Ports in pin order, named as in the datasheet.  The power pins, VSS (8)
// and VDD (16), are left out.  Synthesizable.
//
// All six flip-flops store their D input at the rising edge of CLOCK.
// CLEAR is active low and asynchronous: 0 sets all Q to 0 at once.

module cd40174
(
    input  logic clear_n,  // Pin 1:  0 = all Q to 0 at once
    output logic q1,       // Pin 2
    input  logic d1,       // Pin 3
    input  logic d2,       // Pin 4
    output logic q2,       // Pin 5
    input  logic d3,       // Pin 6
    output logic q3,       // Pin 7
                           // Pin 8:  VSS
    input  logic clock,    // Pin 9
    output logic q4,       // Pin 10
    input  logic d4,       // Pin 11
    output logic q5,       // Pin 12
    input  logic d5,       // Pin 13
    input  logic d6,       // Pin 14
    output logic q6        // Pin 15
                           // Pin 16: VDD
);

    logic [6:1] q;

    always_ff @ (posedge clock or negedge clear_n)
        if (~ clear_n)
            q <= '0;
        else
            q <= { d6, d5, d4, d3, d2, d1 };

    assign { q6, q5, q4, q3, q2, q1 } = q;

endmodule
